LUCENE-10555: fix iteratorCost initial logic error (#878)

This commit is contained in:
xiaoping 2022-05-11 14:36:24 +08:00 committed by GitHub
parent 8476ac1f6a
commit 6c6bb00cec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 4 deletions

View File

@ -126,7 +126,6 @@ public abstract class NumericComparator<T extends Number> extends FieldComparato
this.minValueAsBytes =
reverse ? new byte[bytesCount] : topValueSet ? new byte[bytesCount] : null;
this.competitiveIterator = DocIdSetIterator.all(maxDoc);
this.iteratorCost = maxDoc;
} else {
this.enableSkipping = false;
this.maxDoc = 0;
@ -165,9 +164,13 @@ public abstract class NumericComparator<T extends Number> extends FieldComparato
@Override
public void setScorer(Scorable scorer) throws IOException {
if (iteratorCost == -1 && scorer instanceof Scorer) {
iteratorCost =
((Scorer) scorer).iterator().cost(); // starting iterator cost is the scorer's cost
if (iteratorCost == -1) {
if (scorer instanceof Scorer) {
iteratorCost =
((Scorer) scorer).iterator().cost(); // starting iterator cost is the scorer's cost
} else {
iteratorCost = maxDoc;
}
updateCompetitiveIterator(); // update an iterator when we have a new segment
}
}