@Override public int advance(int target) throws IOException { if ((target - skipInterval) >= doc && docFreq >= skipMinimum) { // There are enough docs in the posting to have // skip data, and its not too close if (skipper == null) { // This DocsEnum has never done any skipping skipper = new SepSkipListReader( skipIn.clone(), freqIn, docIn, posIn, maxSkipLevels, skipInterval); } if (!skipped) { // We haven't yet skipped for this posting skipper.init(skipFP, docIndex, freqIndex, posIndex, 0, docFreq, storePayloads); skipper.setIndexOptions(indexOptions); skipped = true; } final int newCount = skipper.skipTo(target); if (newCount > count) { // Skipper did move if (!omitTF) { skipper.getFreqIndex().seek(freqReader); } skipper.getDocIndex().seek(docReader); count = newCount; doc = accum = skipper.getDoc(); } } // Now, linear scan for the rest: do { if (nextDoc() == NO_MORE_DOCS) { return NO_MORE_DOCS; } } while (target > doc); return doc; }
@Override public int advance(int target) throws IOException { // System.out.println("SepD&P advance target=" + target + " vs current=" + doc + " this=" + // this); if ((target - skipInterval) >= doc && docFreq >= skipMinimum) { // There are enough docs in the posting to have // skip data, and its not too close if (skipper == null) { // System.out.println(" create skipper"); // This DocsEnum has never done any skipping skipper = new SepSkipListReader( skipIn.clone(), freqIn, docIn, posIn, maxSkipLevels, skipInterval); } if (!skipped) { // System.out.println(" init skip data skipFP=" + skipFP); // We haven't yet skipped for this posting skipper.init(skipFP, docIndex, freqIndex, posIndex, payloadFP, docFreq, storePayloads); skipper.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS); skipped = true; } final int newCount = skipper.skipTo(target); // System.out.println(" skip newCount=" + newCount + " vs " + count); if (newCount > count) { // Skipper did move skipper.getFreqIndex().seek(freqReader); skipper.getDocIndex().seek(docReader); // System.out.println(" doc seek'd to " + skipper.getDocIndex()); // NOTE: don't seek pos here; do it lazily // instead. Eg a PhraseQuery may skip to many // docs before finally asking for positions... posIndex.copyFrom(skipper.getPosIndex()); posSeekPending = true; count = newCount; doc = accum = skipper.getDoc(); // System.out.println(" moved to doc=" + doc); // payloadIn.seek(skipper.getPayloadPointer()); payloadFP = skipper.getPayloadPointer(); pendingPosCount = 0; pendingPayloadBytes = 0; payloadPending = false; payloadLength = skipper.getPayloadLength(); // System.out.println(" move payloadLen=" + payloadLength); } } // Now, linear scan for the rest: do { if (nextDoc() == NO_MORE_DOCS) { // System.out.println(" advance nextDoc=END"); return NO_MORE_DOCS; } // System.out.println(" advance nextDoc=" + doc); } while (target > doc); // System.out.println(" return doc=" + doc); return doc; }