jpountz commented on code in PR #13343: URL: https://github.com/apache/lucene/pull/13343#discussion_r1596001365
########## lucene/core/src/java/org/apache/lucene/search/BlockMaxConjunctionBulkScorer.java: ########## @@ -68,18 +88,10 @@ public int score(LeafCollector collector, Bits acceptDocs, int min, int max) thr // Use impacts of the least costly scorer to compute windows // NOTE: windowMax is inclusive int windowMax = Math.min(scorers[0].advanceShallow(windowMin), max - 1); - for (int i = 1; i < scorers.length; ++i) { - scorers[i].advanceShallow(windowMin); - } - double maxWindowScore = 0; - for (int i = 0; i < scorers.length; ++i) { - double maxClauseScore = scorers[i].getMaxScore(windowMax); - sumOfOtherClauses[i] = maxClauseScore; - maxWindowScore += maxClauseScore; - } - for (int i = sumOfOtherClauses.length - 2; i >= 0; --i) { - sumOfOtherClauses[i] += sumOfOtherClauses[i + 1]; + double maxWindowScore = Double.POSITIVE_INFINITY; Review Comment: We already cast before returning in `computeMaxScore`, so no need to make it a `double` here only to cast again on when calling `scoreWindow`. ```suggestion float maxWindowScore = Float.POSITIVE_INFINITY; ``` ########## lucene/core/src/java/org/apache/lucene/search/BlockMaxConjunctionBulkScorer.java: ########## @@ -68,18 +88,10 @@ public int score(LeafCollector collector, Bits acceptDocs, int min, int max) thr // Use impacts of the least costly scorer to compute windows // NOTE: windowMax is inclusive int windowMax = Math.min(scorers[0].advanceShallow(windowMin), max - 1); - for (int i = 1; i < scorers.length; ++i) { - scorers[i].advanceShallow(windowMin); - } - double maxWindowScore = 0; - for (int i = 0; i < scorers.length; ++i) { - double maxClauseScore = scorers[i].getMaxScore(windowMax); - sumOfOtherClauses[i] = maxClauseScore; - maxWindowScore += maxClauseScore; - } - for (int i = sumOfOtherClauses.length - 2; i >= 0; --i) { - sumOfOtherClauses[i] += sumOfOtherClauses[i + 1]; + double maxWindowScore = Double.POSITIVE_INFINITY; + if (0 < scorable.minCompetitiveScore) { + maxWindowScore = computeMaxScore(windowMin, windowMax); } scoreWindow(collector, acceptDocs, windowMin, windowMax + 1, (float) maxWindowScore); Review Comment: ```suggestion scoreWindow(collector, acceptDocs, windowMin, windowMax + 1, maxWindowScore); ``` ########## lucene/core/src/java/org/apache/lucene/search/BlockMaxConjunctionBulkScorer.java: ########## @@ -56,9 +56,29 @@ final class BlockMaxConjunctionBulkScorer extends BulkScorer { scorer1 = this.scorers[0]; scorer2 = this.scorers[1]; this.sumOfOtherClauses = new double[this.scorers.length]; + for (int i = 0; i < sumOfOtherClauses.length; i++) { + sumOfOtherClauses[i] = Double.POSITIVE_INFINITY; + } this.maxDoc = maxDoc; } + public float computeMaxScore(int windowMin, int windowMax) throws IOException { Review Comment: can you make it private? -- 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