jpountz commented on code in PR #14751: URL: https://github.com/apache/lucene/pull/14751#discussion_r2128822718
########## lucene/core/src/java/org/apache/lucene/search/ScorerUtil.java: ########## @@ -120,11 +120,22 @@ public int length() { } } + /** + * Filters competitive hits from the provided {@link DocAndScoreAccBuffer}. + * + * <p>This method removes documents from the buffer that cannot possibly have a score competitive + * enough to exceed the minimum competitive score, given the maximum remaining score and the + * number of scorers. + */ static void filterCompetitiveHits( DocAndScoreAccBuffer buffer, double maxRemainingScore, float minCompetitiveScore, int numScorers) { + if ((float) MathUtil.sumUpperBound(maxRemainingScore, numScorers) > minCompetitiveScore) { Review Comment: nit: the equal case would be ok too ```suggestion if ((float) MathUtil.sumUpperBound(maxRemainingScore, numScorers) >= minCompetitiveScore) { ``` ########## lucene/core/src/java/org/apache/lucene/search/BlockMaxConjunctionBulkScorer.java: ########## @@ -81,30 +83,30 @@ private float computeMaxScore(int windowMin, int windowMax) throws IOException { public int score(LeafCollector collector, Bits acceptDocs, int min, int max) throws IOException { collector.setScorer(scorable); - int windowMin = Math.max(lead.docID(), min); + int windowMin = scoreDocFirstUntilDynamicPruning(collector, acceptDocs, min, max); + while (windowMin < max) { // Use impacts of the least costly scorer to compute windows // NOTE: windowMax is inclusive int windowMax = Math.min(scorers[0].advanceShallow(windowMin), max - 1); + // Ensure the scoring window not too big, this especially works for the default implementation + // of `Scorer#advanceShallow` which may return `DocIdSetIterator#NO_MORE_DOCS`. + windowMax = (int) Math.min(windowMax, windowMin + MAX_WINDOW_SIZE); Review Comment: nit: you could store MAX_WINDOW_SIZE as an int and do `windowMax = MathUtil.unsignedMin(windowMax, windowMin + MAX_WINDO_SIZE)` -- 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. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org