/** * Ends the merging phase, writes the last entry and closes the streams. * @param lexStream LexiconOutputStream used to write the lexicon. * @throws IOException if an I/O error occurs. */ public void endMerge(LexiconOutputStream<String> lexStream) throws IOException{ termStatistics.setTermId(currentTerm++); ((BasicLexiconEntry)termStatistics).setOffset(startOffset); lexStream.writeNextEntry(lastTermWritten, termStatistics); //lexStream.writeNextEntry(lastTermWritten, new BasicLexiconEntry(currentTerm++, lastDocFreq, lastFreq, startOffset)); //startOffset.setPosition(this.getByteOffset(), this.getBitOffset()); numberOfPointers += lastDocFreq; bos.close(); myRun.close(); }
/** * Begins the multiway merging phase. * @param size number of runs to be merged. * @param fileName output filename. * @throws Exception if an I/O error occurs. */ public void beginMerge(int size, String fileName) throws Exception{ init(size, fileName); myRun = queue.poll(); while(myRun.current().getTerm().equals(" ")) myRun = queue.poll(); lastDocument = myRun.current().append(bos,-1); termStatistics = myRun.current().getLexiconEntry(); lastFreq = myRun.current().getTF(); lastDocFreq = myRun.current().getDf(); lastTermWritten = myRun.current().getTerm(); if(myRun.hasNext()){ myRun.next(); queue.add(myRun); }else{ myRun.close(); } }
queue.add(myRun); }else{ myRun.close();