private RangeAndValue<T> getLatestEntry() { return RangeAndValue.fromMapEntry(rangeMapView() .asDescendingMapOfRanges() .entrySet() .iterator() .next()); }
private void copyOldRangesFromPreviousMap( RangeAndValue latestRangeAndValue, @Output ImmutableRangeMap.Builder<Long, T> builder) { timestampMappings() .stream() .filter(rangeAndValue -> !rangeAndValue.equals(latestRangeAndValue)) .forEach(rangeAndValue -> builder.put(rangeAndValue.longRange(), rangeAndValue.value())); }
static <T> RangeAndValue<T> fromMapEntry(Map.Entry<Range<Long>, T> entry) { return of(entry.getKey(), entry.getValue()); } }
static <T> RangeAndValue<T> fromMapEntry(Map.Entry<Range<Long>, T> entry) { return of(entry.getKey(), entry.getValue()); } }
public static <T> TimestampPartitioningMap<T> of(RangeMap<Long, T> initialState) { return ImmutableTimestampPartitioningMap.of( initialState.asMapOfRanges() .entrySet() .stream() .map(entry -> RangeAndValue.of(entry.getKey(), entry.getValue())) .collect(Collectors.toSet())); }
private RangeAndValue<T> getLatestEntry() { return RangeAndValue.fromMapEntry(rangeMapView() .asDescendingMapOfRanges() .entrySet() .iterator() .next()); }
private void copyOldRangesFromPreviousMap( RangeAndValue latestRangeAndValue, @Output ImmutableRangeMap.Builder<Long, T> builder) { timestampMappings() .stream() .filter(rangeAndValue -> !rangeAndValue.equals(latestRangeAndValue)) .forEach(rangeAndValue -> builder.put(rangeAndValue.longRange(), rangeAndValue.value())); }
private void addNewRanges( long lowerBoundForNewVersion, T newValue, RangeAndValue<T> latestRangeAndValue, @Output ImmutableRangeMap.Builder<Long, T> builder) { builder.put(Range.closedOpen(latestRangeAndValue.longRange().lowerEndpoint(), lowerBoundForNewVersion), latestRangeAndValue.value()); builder.put(Range.atLeast(lowerBoundForNewVersion), newValue); }
private static <T> void validateProvidedTimestampBounds(long lowerBoundForNewValue, T newValue, RangeAndValue<T> latestEntry) { if (lowerBoundForNewValue < latestEntry.longRange().lowerEndpoint()) { throw new SafeIllegalArgumentException("Cannot install a new value at an earlier timestamp;" + " attempted to install version {} at {}, but the newest interval is at {}.", SafeArg.of("attemptedNewValue", newValue), SafeArg.of("attemptedLowerBound", lowerBoundForNewValue), SafeArg.of("existingInterval", latestEntry)); } }
public static <T> TimestampPartitioningMap<T> of(RangeMap<Long, T> initialState) { return ImmutableTimestampPartitioningMap.of( initialState.asMapOfRanges() .entrySet() .stream() .map(entry -> RangeAndValue.of(entry.getKey(), entry.getValue())) .collect(Collectors.toSet())); }
private void addNewRanges( long lowerBoundForNewVersion, T newValue, RangeAndValue<T> latestRangeAndValue, @Output ImmutableRangeMap.Builder<Long, T> builder) { builder.put(Range.closedOpen(latestRangeAndValue.longRange().lowerEndpoint(), lowerBoundForNewVersion), latestRangeAndValue.value()); builder.put(Range.atLeast(lowerBoundForNewVersion), newValue); }
private static <T> void validateProvidedTimestampBounds(long lowerBoundForNewValue, T newValue, RangeAndValue<T> latestEntry) { if (lowerBoundForNewValue < latestEntry.longRange().lowerEndpoint()) { throw new SafeIllegalArgumentException("Cannot install a new value at an earlier timestamp;" + " attempted to install version {} at {}, but the newest interval is at {}.", SafeArg.of("attemptedNewValue", newValue), SafeArg.of("attemptedLowerBound", lowerBoundForNewValue), SafeArg.of("existingInterval", latestEntry)); } }