mirror of https://github.com/apache/lucene.git
Simplify logic in ScoreCachingWrappingScorer (#14012)
This is functionally equivalent to the logic that was present, but makes the behavior clearer.
This commit is contained in:
parent
02db61ffb3
commit
c9c631f9d2
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue