jimczi commented on a change in pull request #1351: LUCENE-9280: Collectors to skip noncompetitive documents URL: https://github.com/apache/lucene-solr/pull/1351#discussion_r394671963
########## File path: lucene/core/src/java/org/apache/lucene/search/Weight.java ########## @@ -201,20 +201,54 @@ public long cost() { @Override public int score(LeafCollector collector, Bits acceptDocs, int min, int max) throws IOException { collector.setScorer(scorer); + DocIdSetIterator scorerIterator = twoPhase == null? iterator: twoPhase.approximation(); + DocIdSetIterator combinedIterator = collector.iterator() == null ? scorerIterator: combineScorerAndCollectorIterators(scorerIterator, collector); if (scorer.docID() == -1 && min == 0 && max == DocIdSetIterator.NO_MORE_DOCS) { - scoreAll(collector, iterator, twoPhase, acceptDocs); + scoreAll(collector, combinedIterator, twoPhase, acceptDocs); return DocIdSetIterator.NO_MORE_DOCS; } else { int doc = scorer.docID(); - if (doc < min) { - if (twoPhase == null) { - doc = iterator.advance(min); - } else { - doc = twoPhase.approximation().advance(min); + if (doc < min) scorerIterator.advance(min); + return scoreRange(collector, combinedIterator, twoPhase, acceptDocs, doc, max); + } + } + + // conjunction iterator between scorer's iterator and collector's iterator Review comment: you can replace this with `ConjunctionDISI#intersectIterators` ? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org