You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2025/07/03 21:06:11 UTC
(lucene) branch main updated: Improve test and address more test failures.
This is an automated email from the ASF dual-hosted git repository.
jpountz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/main by this push:
new 3f71b54c47a Improve test and address more test failures.
3f71b54c47a is described below
commit 3f71b54c47adecee6490d3c6c8f8041b062ebec6
Author: Adrien Grand <jp...@gmail.com>
AuthorDate: Thu Jul 3 23:05:02 2025 +0200
Improve test and address more test failures.
---
.../core/src/java/org/apache/lucene/search/ScorerUtil.java | 4 +---
.../src/test/org/apache/lucene/search/TestScorerUtil.java | 12 ++++++++----
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/lucene/core/src/java/org/apache/lucene/search/ScorerUtil.java b/lucene/core/src/java/org/apache/lucene/search/ScorerUtil.java
index d26dd5af67b..bf1b145bc6d 100644
--- a/lucene/core/src/java/org/apache/lucene/search/ScorerUtil.java
+++ b/lucene/core/src/java/org/apache/lucene/search/ScorerUtil.java
@@ -130,9 +130,7 @@ class ScorerUtil {
// note: we want the float ulp in order to converge faster, not the double ulp
double subtraction = Math.ulp(minCompetitiveScore);
while (minRequiredScore > 0
- && (float)
- MathUtil.sumUpperBound(
- minRequiredScore - subtraction + maxRemainingScore, numScorers)
+ && (float) MathUtil.sumUpperBound(minRequiredScore + maxRemainingScore, numScorers)
>= minCompetitiveScore) {
minRequiredScore -= subtraction;
}
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestScorerUtil.java b/lucene/core/src/test/org/apache/lucene/search/TestScorerUtil.java
index 360d797953d..fb3f031ef8d 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestScorerUtil.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestScorerUtil.java
@@ -96,7 +96,7 @@ public class TestScorerUtil extends LuceneTestCase {
}
public void testMinRequiredScore() {
- int iters = atLeast(100);
+ int iters = atLeast(10000);
for (int iter = 0; iter < iters; iter++) {
double maxRemainingScore = random().nextDouble();
float minCompetitiveScore = random().nextFloat();
@@ -107,9 +107,13 @@ public class TestScorerUtil extends LuceneTestCase {
if (minCompetitiveScore < maxRemainingScore) {
assertTrue(minRequiredScore <= 0);
} else {
- assertTrue(
- (float) MathUtil.sumUpperBound(minRequiredScore + maxRemainingScore, numScorers)
- <= minCompetitiveScore);
+ // The value before minRequiredScore must not be able to produce a score >=
+ // minCompetitiveScore.
+ assertFalse(
+ (float)
+ MathUtil.sumUpperBound(
+ Math.nextDown(minRequiredScore) + maxRemainingScore, numScorers)
+ >= minCompetitiveScore);
}
// NOTE: we need to assert the internal while loop ends within an acceptable iterations. But