public void updateIndex() throws IOException, InterruptedException { IndexPhaseState state; DiskInvertedList activeIndex; DiskInvertedList inactiveIndex; synchronized (mutex) { state = activeIndexPhase.getAndSet(new IndexPhaseState()); activeIndex = index.getActiveList(); inactiveIndex = index.getInactiveList(); } // TODO: support merge in multiple passes (or not?) long newTotalDocuments = documentIndexBuilder.getTotalNumberOfDocuments() + state.size; int position = 0; InvertedList[] phaseLists = new InvertedList[2 + state.partialListsOnDisk.size()]; phaseLists[position++] = activeIndex; phaseLists[position++] = new MemoryInvertedList(state.aggregateState); for (InvertedList disk : state.partialListsOnDisk) { phaseLists[position++] = disk; } Map<Long, Float> tfIdfAccumulator = new HashMap<Long, Float>(); Iterator<Pair<DictionaryTerm, InvertedListPointer>> result = mergeInvertedLists( inactiveIndex.getOverwriteBuilder(), tfIdfAccumulator, newTotalDocuments, phaseLists); index.updateDictionaryEntries(result); documentIndexBuilder.updateIndex(tfIdfAccumulator); }
public int getIndexPhase() { return index.getActiveList().getIndexPhase(); }