@Override public GapAwareTrackingToken lowerBound(TrackingToken other) { Assert.isTrue(other instanceof GapAwareTrackingToken, () -> "Incompatible token type provided."); GapAwareTrackingToken otherToken = (GapAwareTrackingToken) other; SortedSet<Long> mergedGaps = new ConcurrentSkipListSet<>(this.gaps); mergedGaps.addAll(otherToken.gaps); long mergedIndex = calculateIndex(otherToken, mergedGaps); mergedGaps.removeIf(i -> i >= mergedIndex); return new GapAwareTrackingToken(mergedIndex, mergedGaps); }
@Override public GapAwareTrackingToken lowerBound(TrackingToken other) { Assert.isTrue(other instanceof GapAwareTrackingToken, () -> "Incompatible token type provided."); GapAwareTrackingToken otherToken = (GapAwareTrackingToken) other; SortedSet<Long> mergedGaps = new ConcurrentSkipListSet<>(this.gaps); mergedGaps.addAll(otherToken.gaps); long mergedIndex = calculateIndex(otherToken, mergedGaps); mergedGaps.removeIf(i -> i >= mergedIndex); return new GapAwareTrackingToken(mergedIndex, mergedGaps); }