vigyasharma commented on a change in pull request #711:
URL: https://github.com/apache/lucene/pull/711#discussion_r817117987



##########
File path: 
lucene/core/src/java/org/apache/lucene/search/MaxScoreSumPropagator.java
##########
@@ -131,22 +131,28 @@ void setMinCompetitiveScore(float minScore) throws 
IOException {
   /** Return the minimum score that a Scorer must produce in order for a hit 
to be competitive. */
   private float getMinCompetitiveScore(float minScoreSum, double 
sumOfOtherMaxScores) {
     assert numClauses > 0;
-    if (minScoreSum <= sumOfOtherMaxScores) {
-      return 0f;
-    }
 
     // We need to find a value 'minScore' so that 'minScore + 
sumOfOtherMaxScores <= minScoreSum'
     // TODO: is there an efficient way to find the greatest value that meets 
this requirement?
     float minScore = (float) (minScoreSum - sumOfOtherMaxScores);
-    int iters = 0;
-    while (scoreSumUpperBound(minScore + sumOfOtherMaxScores) > minScoreSum) {
+    for (int iter = 0;
+        minScore > 0 && scoreSumUpperBound(minScore + sumOfOtherMaxScores) > 
minScoreSum;
+        ++iter) {
       // Important: use ulp of minScoreSum and not minScore to make sure that 
we
       // converge quickly.
       minScore -= Math.ulp(minScoreSum);
       // this should converge in at most two iterations:
       //  - one because of the subtraction rounding error
       //  - one because of the error introduced by sumUpperBound
-      assert ++iters <= 2 : iters;
+      if (iter > 2) {
+        throw new IllegalStateException(

Review comment:
       Also publish the last computed value of `minScore` here?




-- 
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

Reply via email to