LUCENE-10555: avoid NumericLeafComparator#iteratorCost repeated initialization when NumericLeafComparator#setScorer is called (#864)

This commit is contained in:
xiaoping 2022-05-10 19:07:41 +08:00 committed by GitHub
parent 3edfeb5eb2
commit f431511cb7
2 changed files with 5 additions and 2 deletions

View File

@ -118,6 +118,9 @@ Improvements
Optimizations
---------------------
* LUCENE-10555: avoid NumericLeafComparator#iteratorCost repeated initialization
when NumericLeafComparator#setScorer is called. (Jianping Weng)
* LUCENE-10452: Hunspell: call checkCanceled less frequently to reduce the overhead (Peter Gromov)
* LUCENE-10451: Hunspell: don't perform potentially expensive spellchecking after timeout (Peter Gromov)

View File

@ -91,7 +91,7 @@ public abstract class NumericComparator<T extends Number> extends FieldComparato
private final byte[] maxValueAsBytes;
private DocIdSetIterator competitiveIterator;
private long iteratorCost;
private long iteratorCost = -1;
private int maxDocVisited = -1;
private int updateCounter = 0;
@ -165,7 +165,7 @@ public abstract class NumericComparator<T extends Number> extends FieldComparato
@Override
public void setScorer(Scorable scorer) throws IOException {
if (scorer instanceof Scorer) {
if (iteratorCost == -1 && scorer instanceof Scorer) {
iteratorCost =
((Scorer) scorer).iterator().cost(); // starting iterator cost is the scorer's cost
updateCompetitiveIterator(); // update an iterator when we have a new segment