protected void init(int size, BitOut invertedFile) throws Exception{ queue = new PriorityQueue<RunIterator>(size, new PostingComparator()); bos = invertedFile; for(int i = 0; i < size; i++){ RunIterator run = runsSource.createRunIterator(i); run.next(); queue.add(run); } }
/** * 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(); } }
myRun.next(); queue.add(myRun); }else{