private int doNext(int doc) throws IOException { for(;;) { if (doc == NO_MORE_DOCS) { // we need this check because it is only ok to call #matches when positioned return NO_MORE_DOCS; } advanceHead: for(;;) { for (DocIdSetIterator other : others) { // invariant: docsAndFreqs[i].doc <= doc at this point. // docsAndFreqs[i].doc may already be equal to doc if we "broke advanceHead" // on the previous iteration and the advance on the lead scorer exactly matched. if (other.docID() < doc) { final int next = other.advance(doc); if (next > doc) { // DocsEnum beyond the current doc - break and advance lead to the new highest doc. doc = lead.advance(next); break advanceHead; } } } if (matches()) { // success - all DocsEnums are on the same doc return doc; } else { doc = lead.nextDoc(); break advanceHead; } } } }
private int doNext(int doc) throws IOException { for(;;) { if (doc == NO_MORE_DOCS) { // we need this check because it is only ok to call #matches when positioned return NO_MORE_DOCS; } advanceHead: for(;;) { for (DocIdSetIterator other : others) { // invariant: docsAndFreqs[i].doc <= doc at this point. // docsAndFreqs[i].doc may already be equal to doc if we "broke advanceHead" // on the previous iteration and the advance on the lead scorer exactly matched. if (other.docID() < doc) { final int next = other.advance(doc); if (next > doc) { // DocsEnum beyond the current doc - break and advance lead to the new highest doc. doc = lead.advance(next); break advanceHead; } } } if (matches()) { // success - all DocsEnums are on the same doc return doc; } else { doc = lead.nextDoc(); break advanceHead; } } } }