You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2024/05/10 16:35:04 UTC
(lucene) branch branch_9x updated: Advoid the use of ImpactsDISI when no minimum competitive score has been set (#13343)
This is an automated email from the ASF dual-hosted git repository.
jpountz pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new adf3d83a131 Advoid the use of ImpactsDISI when no minimum competitive score has been set (#13343)
adf3d83a131 is described below
commit adf3d83a1316db7d6836c65e65adec535939bb68
Author: zhongshanhao <57...@qq.com>
AuthorDate: Sat May 11 00:27:00 2024 +0800
Advoid the use of ImpactsDISI when no minimum competitive score has been set (#13343)
Co-authored-by: zhongshanhao <zh...@bilibili.com>
---
.../search/BlockMaxConjunctionBulkScorer.java | 36 ++++++++++++++--------
.../lucene/search/BlockMaxConjunctionScorer.java | 9 ++++--
2 files changed, 31 insertions(+), 14 deletions(-)
diff --git a/lucene/core/src/java/org/apache/lucene/search/BlockMaxConjunctionBulkScorer.java b/lucene/core/src/java/org/apache/lucene/search/BlockMaxConjunctionBulkScorer.java
index 7b428791d1d..31046cee5e8 100644
--- a/lucene/core/src/java/org/apache/lucene/search/BlockMaxConjunctionBulkScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/BlockMaxConjunctionBulkScorer.java
@@ -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);
@@ -68,20 +88,12 @@ final class BlockMaxConjunctionBulkScorer extends BulkScorer {
// 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);
}
diff --git a/lucene/core/src/java/org/apache/lucene/search/BlockMaxConjunctionScorer.java b/lucene/core/src/java/org/apache/lucene/search/BlockMaxConjunctionScorer.java
index 127d6346edd..47ef5e07f19 100644
--- a/lucene/core/src/java/org/apache/lucene/search/BlockMaxConjunctionScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/BlockMaxConjunctionScorer.java
@@ -110,8 +110,13 @@ final class BlockMaxConjunctionScorer extends Scorer {
}
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 {