LUCENE-8142: Fix AssertingImpactsEnum and add missing javadoc.

This commit is contained in:
Adrien Grand 2018-05-02 17:20:42 +02:00
parent e00c4cede2
commit 46ecb73976
6 changed files with 18 additions and 1 deletions

View File

@ -23,6 +23,9 @@ import java.util.List;
*/
public abstract class Impacts {
/** Sole constructor. Typically invoked by sub classes. */
protected Impacts() {}
/**
* Return the number of levels on which we have impacts.
* The returned value is always greater than 0 and may not always be the

View File

@ -53,6 +53,7 @@ final class DisjunctionMaxScorer extends DisjunctionScorer {
float scoreMax = 0;
double otherScoreSum = 0;
for (Scorer scorer : subScorers) {
scorer.advanceShallow(0);
float subScore = scorer.getMaxScore(DocIdSetIterator.NO_MORE_DOCS);
if (subScore >= scoreMax) {
otherScoreSum += scoreMax;

View File

@ -36,6 +36,7 @@ final class DisjunctionSumScorer extends DisjunctionScorer {
super(weight, subScorers, needsScores);
double maxScore = 0;
for (Scorer scorer : subScorers) {
scorer.advanceShallow(0);
maxScore += scorer.getMaxScore(DocIdSetIterator.NO_MORE_DOCS);
}
// The error of sums depends on the order in which values are summed up. In

View File

@ -76,6 +76,11 @@ class ReqExclScorer extends Scorer {
return reqScorer.score(); // reqScorer may be null when next() or skipTo() already return false
}
@Override
public int advanceShallow(int target) throws IOException {
return reqScorer.advanceShallow(target);
}
@Override
public float getMaxScore(int upTo) throws IOException {
return reqScorer.getMaxScore(upTo);

View File

@ -52,6 +52,7 @@ class ReqOptSumScorer extends Scorer {
this.reqScorer = reqScorer;
this.optScorer = optScorer;
reqScorer.advanceShallow(0);
this.reqMaxScore = reqScorer.getMaxScore(DocIdSetIterator.NO_MORE_DOCS);
this.maxScorePropagator = new MaxScoreSumPropagator(Arrays.asList(reqScorer, optScorer));
@ -209,6 +210,12 @@ class ReqOptSumScorer extends Scorer {
return score;
}
@Override
public int advanceShallow(int target) throws IOException {
optScorer.advanceShallow(target);
return reqScorer.advanceShallow(target);
}
@Override
public float getMaxScore(int upTo) throws IOException {
float maxScore = reqScorer.getMaxScore(upTo);

View File

@ -40,7 +40,7 @@ public class AssertingScorer extends Scorer {
IteratorState state = IteratorState.ITERATING;
int doc;
float minCompetitiveScore = 0;
int lastShallowTarget;
int lastShallowTarget = -1;
private AssertingScorer(Random random, Scorer in, ScoreMode scoreMode) {
super(in.weight);