### Question:
ColumnIndexer implements SwiftColumnIndexer { @Override public void buildIndex() throws Exception { for (Segment segment : segments) { try { Column<T> column = getColumn(segment); buildColumnIndex(column, segment.getRowCount()); } finally { SegmentUtils.releaseHisSeg(segment); } } } ColumnIndexer(ColumnKey key, List<Segment> segments); @Override void buildIndex();  }### Answer:
@Test public void buildIndexViaExternalMap() throws Exception { BaseIntListExternalMap<Long> externalMap = mock(BaseIntListExternalMap.class); when(IntListExternalMapFactory.getIntListExternalMap(ArgumentMatchers.<ClassType>any(), ArgumentMatchers.<Comparator<Long>>any(), anyString(), anyBoolean())) .thenReturn(externalMap); IntList indexOf1 = IntListFactory.createIntList(); indexOf1.add(0); indexOf1.add(3); IntList indexOf3 = IntListFactory.createIntList(); indexOf3.add(2); when(externalMap.iterator()).thenReturn(Arrays.<Entry<Long, IntList>>asList( Pair.of(1L, indexOf1), Pair.of(3L, indexOf3)).iterator()); new ColumnIndexer<Object>(new ColumnKey("column"), Collections.singletonList(seg)).buildIndex(); verify(detailColumn).get(0); verify(detailColumn, never()).get(1); verify(detailColumn).get(2); verify(detailColumn).get(3); verify(externalMap).put(1L, 0); verify(externalMap).put(3L, 2); verify(externalMap).put(1L, 3); verify(dictColumn.putter()).putValue(0, null); verify(dictColumn.putter()).putValue(1, 1L); verify(dictColumn.putter()).putValue(2, 3L); verify(dictColumn.putter()).putIndex(0, 1); verify(dictColumn.putter()).putIndex(1, 0); verify(dictColumn.putter()).putIndex(2, 2); verify(dictColumn.putter()).putIndex(3, 1); verify(dictColumn.putter()).putSize(3); }
@Test public void buildIndexViaTreeMap() throws Exception { PerformancePlugManager performancePlugManager = PerformancePlugManager.getInstance(); when(performancePlugManager.isDiskSort()).thenReturn(false); TreeMap<Long, IntList> map = spy(new TreeMap<Long, IntList>()); whenNew(TreeMap.class).withAnyArguments().thenReturn(map); new ColumnIndexer<Object>(new ColumnKey("column"), Collections.singletonList(seg)).buildIndex(); verify(detailColumn).get(0); verify(detailColumn).get(2); verify(detailColumn).get(3); verify(map).put(eq(1L), ArgumentMatchers.<IntList>any()); verify(map).put(eq(3L), ArgumentMatchers.<IntList>any()); verify(dictColumn.putter()).putValue(0, null); verify(dictColumn.putter()).putValue(1, 1L); verify(dictColumn.putter()).putValue(2, 3L); verify(dictColumn.putter()).putIndex(0, 1); verify(dictColumn.putter()).putIndex(1, 0); verify(dictColumn.putter()).putIndex(2, 2); verify(dictColumn.putter()).putIndex(3, 1); verify(dictColumn.putter()).putSize(3); }