Skip to content

Commit

Permalink
Advoid the use of ImpactsDISI when no minimum competitive score has b…
Browse files Browse the repository at this point in the history
…een set (#13343)

Co-authored-by: zhongshanhao <[email protected]>
  • Loading branch information
2 people authored and jpountz committed May 10, 2024
1 parent 05ca9d5 commit adf3d83
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,29 @@ final class BlockMaxConjunctionBulkScorer extends BulkScorer {
scorer1 = this.scorers[0];
scorer2 = this.scorers[1];
this.sumOfOtherClauses = new double[this.scorers.length];
for (int i = 0; i < sumOfOtherClauses.length; i++) {
sumOfOtherClauses[i] = Double.POSITIVE_INFINITY;
}
this.maxDoc = maxDoc;
}

private float computeMaxScore(int windowMin, int windowMax) throws IOException {
for (int i = 0; i < scorers.length; ++i) {
scorers[i].advanceShallow(windowMin);
}

float maxWindowScore = 0;
for (int i = 0; i < scorers.length; ++i) {
float maxClauseScore = scorers[i].getMaxScore(windowMax);
sumOfOtherClauses[i] = maxClauseScore;
maxWindowScore += maxClauseScore;
}
for (int i = sumOfOtherClauses.length - 2; i >= 0; --i) {
sumOfOtherClauses[i] += sumOfOtherClauses[i + 1];
}
return maxWindowScore;
}

@Override
public int score(LeafCollector collector, Bits acceptDocs, int min, int max) throws IOException {
collector.setScorer(scorable);
Expand All @@ -68,20 +88,12 @@ public int score(LeafCollector collector, Bits acceptDocs, int min, int max) thr
// Use impacts of the least costly scorer to compute windows
// NOTE: windowMax is inclusive
int windowMax = Math.min(scorers[0].advanceShallow(windowMin), max - 1);
for (int i = 1; i < scorers.length; ++i) {
scorers[i].advanceShallow(windowMin);
}

double maxWindowScore = 0;
for (int i = 0; i < scorers.length; ++i) {
double maxClauseScore = scorers[i].getMaxScore(windowMax);
sumOfOtherClauses[i] = maxClauseScore;
maxWindowScore += maxClauseScore;
}
for (int i = sumOfOtherClauses.length - 2; i >= 0; --i) {
sumOfOtherClauses[i] += sumOfOtherClauses[i + 1];
float maxWindowScore = Float.POSITIVE_INFINITY;
if (0 < scorable.minCompetitiveScore) {
maxWindowScore = computeMaxScore(windowMin, windowMax);
}
scoreWindow(collector, acceptDocs, windowMin, windowMax + 1, (float) maxWindowScore);
scoreWindow(collector, acceptDocs, windowMin, windowMax + 1, maxWindowScore);
windowMin = Math.max(lead1.docID(), windowMax + 1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,13 @@ public long cost() {
}

private void moveToNextBlock(int target) throws IOException {
upTo = advanceShallow(target);
maxScore = getMaxScore(upTo);
if (minScore == 0) {
upTo = target;
maxScore = Float.POSITIVE_INFINITY;
} else {
upTo = advanceShallow(target);
maxScore = getMaxScore(upTo);
}
}

private int advanceTarget(int target) throws IOException {
Expand Down

0 comments on commit adf3d83

Please sign in to comment.