Source:
<code>public void testMismatchedMetrics() throws IOException { <START> IncrementalIndex index1 = IncrementalIndexTest.createIndex(new AggregatorFactory[]{ <END> new LongSumAggregatorFactory("A", "A") }); IncrementalIndex index2 = IncrementalIndexTest.createIndex(new AggregatorFactory[]{ new LongSumAggregatorFactory("A", "A"), new LongSumAggregatorFactory("C", "C") }); IncrementalIndex index3 = IncrementalIndexTest.createIndex(new AggregatorFactory[]{ new LongSumAggregatorFactory("B", "B") }); Interval interval = new Interval(0, new DateTime().getMillis()); RoaringBitmapFactory factory = new RoaringBitmapFactory(); ArrayList<IndexableAdapter> toMerge = Lists.<IndexableAdapter>newArrayList( new IncrementalIndexAdapter(interval, index1, factory), new IncrementalIndexAdapter(interval, index2, factory), new IncrementalIndexAdapter(interval, index3, factory) ); final File tmpDirMerged = temporaryFolder.newFolder(); INDEX_MERGER.merge( toMerge, new AggregatorFactory[] { new LongSumAggregatorFactory("A", "A"), new LongSumAggregatorFactory("B", "B"), new LongSumAggregatorFactory("C", "C") }, tmpDirMerged, null, indexSpec ); }</code><technical_language>IncrementalIndex closed I put in io.druid.segment.CloserRule for occasions, a @Rule CloserRule testCloser testCloser.closeLater(index1)</technical_language>

Target:
public void testMismatchedMetrics() throws IOException { IncrementalIndex index1 = IncrementalIndexTest.createIndex(new AggregatorFactory[]{ new LongSumAggregatorFactory("A", "A") }); closer.closeLater(index1); IncrementalIndex index2 = IncrementalIndexTest.createIndex(new AggregatorFactory[]{ new LongSumAggregatorFactory("A", "A"), new LongSumAggregatorFactory("C", "C") }); closer.closeLater(index2); IncrementalIndex index3 = IncrementalIndexTest.createIndex(new AggregatorFactory[]{ new LongSumAggregatorFactory("B", "B") }); closer.closeLater(index3); IncrementalIndex index4 = IncrementalIndexTest.createIndex(new AggregatorFactory[]{ new LongSumAggregatorFactory("C", "C"), new LongSumAggregatorFactory("A", "A"), new LongSumAggregatorFactory("B", "B") }); closer.closeLater(index4); IncrementalIndex index5 = IncrementalIndexTest.createIndex(new AggregatorFactory[]{ new LongSumAggregatorFactory("C", "C"), new LongSumAggregatorFactory("B", "B") }); closer.closeLater(index5); Interval interval = new Interval(0, new DateTime().getMillis()); RoaringBitmapFactory factory = new RoaringBitmapFactory(); ArrayList<IndexableAdapter> toMerge = Lists.<IndexableAdapter>newArrayList( new IncrementalIndexAdapter(interval, index1, factory), new IncrementalIndexAdapter(interval, index2, factory), new IncrementalIndexAdapter(interval, index3, factory), new IncrementalIndexAdapter(interval, index4, factory), new IncrementalIndexAdapter(interval, index5, factory) ); final File tmpDirMerged = temporaryFolder.newFolder(); File merged = INDEX_MERGER.merge( toMerge, new AggregatorFactory[]{ new LongSumAggregatorFactory("A", "A"), new LongSumAggregatorFactory("B", "B"), new LongSumAggregatorFactory("C", "C"), new LongSumAggregatorFactory("D", "D") }, tmpDirMerged, indexSpec ); final QueryableIndexStorageAdapter adapter = new QueryableIndexStorageAdapter(closer.closeLater(INDEX_IO.loadIndex(merged))); Assert.assertEquals(ImmutableSet.of("A", "B", "C"), ImmutableSet.copyOf(adapter.getAvailableMetrics())); }