HUSTERGS commented on code in PR #14827: URL: https://github.com/apache/lucene/pull/14827#discussion_r2180356164
########## lucene/core/src/java/org/apache/lucene/search/ScorerUtil.java: ########## @@ -116,6 +116,25 @@ public int length() { } } + /** + * Compute a minimum required score, so that (float) MathUtil.sumUpperBound(minRequiredScore + + * maxRemainingScore, numScorers) <= minCompetitiveScore. The computed value may not be the + * greatest value that meets this condition, which means that we may fail to filter out some docs. + * However, this doesn't hurt correctness, it just means that these docs will be filtered out + * later, and the extra work required to compute an optimal value would unlikely result in a + * speedup. + */ + static double minRequiredScore( + double maxRemainingScore, float minCompetitiveScore, int numScorers) { + double minRequiredScore = minCompetitiveScore - maxRemainingScore; + double subtraction = Math.ulp((double) minCompetitiveScore); + while ((float) MathUtil.sumUpperBound(minRequiredScore + maxRemainingScore, numScorers) + > minCompetitiveScore) { + minRequiredScore -= subtraction; + } + return minRequiredScore; + } Review Comment: Of course! I was doing some benchmark about some subtle changes and final performance, will add UT soon -- 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