Source:
public File merge(final Map<DataSegment, File> segments, final File outDir) throws Exception { VersionedIntervalTimeline<String, DataSegment> timeline = new VersionedIntervalTimeline<String, DataSegment>( Ordering.<String>natural().nullsFirst() ); for (DataSegment segment : segments.keySet()) { timeline.add(segment.getInterval(), segment.getVersion(), segment.getShardSpec().createChunk(segment)); } final List<SegmentToMergeHolder> segmentsToMerge = Lists.newArrayList( Iterables.concat( Iterables.transform( timeline.lookup(new Interval("1000-01-01/3000-01-01")), new Function<TimelineObjectHolder<String, DataSegment>, Iterable<SegmentToMergeHolder>>() { @Override public Iterable<SegmentToMergeHolder> apply(final TimelineObjectHolder<String, DataSegment> input) { return Iterables.transform( input.getObject(), new Function<PartitionChunk<DataSegment>, SegmentToMergeHolder>() { @Nullable @Override public SegmentToMergeHolder apply(PartitionChunk<DataSegment> chunkInput) { DataSegment segment = chunkInput.getObject(); return new SegmentToMergeHolder( segment, input.getInterval(), Preconditions.checkNotNull( segments.get(segment), "File for segment %s", segment.getIdentifier() ) ); } } ); } } ) ) ); List<IndexableAdapter> adapters = Lists.newArrayList(); for (final SegmentToMergeHolder holder : segmentsToMerge) { adapters.add( new RowboatFilteringIndexAdapter( new QueryableIndexIndexableAdapter( IndexIO.loadIndex(holder.getFile()) ), new Predicate<Rowboat>() { @Override public boolean apply(Rowboat input) { return holder.getInterval().contains(input.getTimestamp()); } } ) ); } return IndexMerger.append(adapters, outDir); }

Target:
public File merge(final Map<DataSegment, File> segments, final File outDir) throws Exception { VersionedIntervalTimeline<String, DataSegment> timeline = new VersionedIntervalTimeline<String, DataSegment>( Ordering.<String>natural().nullsFirst() ); for (DataSegment segment : segments.keySet()) { timeline.add(segment.getInterval(), segment.getVersion(), segment.getShardSpec().createChunk(segment)); } final Iterable<SegmentToMergeHolder> segmentsToMerge = Iterables.concat( Iterables.transform( timeline.lookup(new Interval("1000-01-01/3000-01-01")), new Function<TimelineObjectHolder<String, DataSegment>, Iterable<SegmentToMergeHolder>>() { @Override public Iterable<SegmentToMergeHolder> apply(final TimelineObjectHolder<String, DataSegment> input) { return Iterables.transform( input.getObject(), new Function<PartitionChunk<DataSegment>, SegmentToMergeHolder>() { @Nullable @Override public SegmentToMergeHolder apply(PartitionChunk<DataSegment> chunkInput) { DataSegment segment = chunkInput.getObject(); return new SegmentToMergeHolder( segment, input.getInterval(), Preconditions.checkNotNull( segments.get(segment), "File for segment %s", segment.getIdentifier() ) ); } } ); } } ) ); List<IndexableAdapter> adapters = Lists.newArrayList(); for (final SegmentToMergeHolder holder : segmentsToMerge) { adapters.add( new RowboatFilteringIndexAdapter( new QueryableIndexIndexableAdapter( IndexIO.loadIndex(holder.getFile()) ), new Predicate<Rowboat>() { @Override public boolean apply(Rowboat input) { return holder.getInterval().contains(input.getTimestamp()); } } ) ); } return IndexMerger.append(adapters, outDir); }