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 2024/12/03 18:27:19 UTC
(lucene) branch branch_10x updated: Simplify logic in ScoreCachingWrappingScorer (#14012)
This is an automated email from the ASF dual-hosted git repository.
jpountz pushed a commit to branch branch_10x
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/branch_10x by this push:
new c9c631f9d29 Simplify logic in ScoreCachingWrappingScorer (#14012)
c9c631f9d29 is described below
commit c9c631f9d29642cacb34c651f6ccacee41b74917
Author: Michael Froh <ms...@gmail.com>
AuthorDate: Tue Dec 3 10:24:41 2024 -0800
Simplify logic in ScoreCachingWrappingScorer (#14012)
This is functionally equivalent to the logic that was present, but
makes the behavior clearer.
---
.../org/apache/lucene/search/ScoreCachingWrappingScorer.java | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/lucene/core/src/java/org/apache/lucene/search/ScoreCachingWrappingScorer.java b/lucene/core/src/java/org/apache/lucene/search/ScoreCachingWrappingScorer.java
index e9a23921ece..9ebc053a660 100644
--- a/lucene/core/src/java/org/apache/lucene/search/ScoreCachingWrappingScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/ScoreCachingWrappingScorer.java
@@ -31,8 +31,7 @@ import java.util.Collections;
*/
public final class ScoreCachingWrappingScorer extends Scorable {
- private int lastDoc = -1;
- private int curDoc = -1;
+ private boolean scoreIsCached;
private float curScore;
private final Scorable in;
@@ -64,7 +63,8 @@ public final class ScoreCachingWrappingScorer extends Scorable {
@Override
public void collect(int doc) throws IOException {
if (scorer != null) {
- scorer.curDoc = doc;
+ // Invalidate cache when collecting a new doc
+ scorer.scoreIsCached = false;
}
super.collect(doc);
}
@@ -82,9 +82,9 @@ public final class ScoreCachingWrappingScorer extends Scorable {
@Override
public float score() throws IOException {
- if (lastDoc != curDoc) {
+ if (scoreIsCached == false) {
curScore = in.score();
- curDoc = lastDoc;
+ scoreIsCached = true;
}
return curScore;