OffsetAdjuster om = new OffsetAdjuster(); long lastOffset = 0; ArrayList<SegmentChunk> segmentChunks = new ArrayList<>(); om.set(concatInfo.getKey(), concatInfo.getValue()); } else { long offset = om.adjustOffset(Long.parseLong(entry.getKey())); SegmentChunk s = new SegmentChunk(entry.getValue(), offset); Preconditions.checkArgument(lastOffset <= s.getStartOffset(),
/** * Adjusts the given offset, if necessary. The offset will be adjusted by the amount specified by the last call * to set() if this method hasn't been called more than the specified number of times. * * @param offset The offset to adjust. * @return The adjusted offset. */ long adjustOffset(long offset) { if (offset != 0 && this.remainingCount == this.originalCount) { // We haven't done any adjustments, yet we encountered an unexpected offset: reset. set(0, 0); } else if (this.remainingCount > 0) { this.remainingCount--; offset += this.offsetAdjustment; } return offset; } }