Skip to content

Commit

Permalink
Fix test failure.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpountz committed Sep 25, 2023
1 parent 483d288 commit ce464c7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ final class BlockMaxConjunctionBulkScorer extends BulkScorer {
private final DocIdSetIterator lead;
private final DocAndScore scorable = new DocAndScore();
private final double[] sumOfOtherClauses;
private final int maxDoc;

BlockMaxConjunctionBulkScorer(List<Scorer> scorers) throws IOException {
BlockMaxConjunctionBulkScorer(int maxDoc, List<Scorer> scorers) throws IOException {
if (scorers.size() <= 1) {
throw new IllegalArgumentException("Expected 2 or more scorers, got " + scorers.size());
}
Expand All @@ -51,6 +52,7 @@ final class BlockMaxConjunctionBulkScorer extends BulkScorer {
Arrays.stream(this.scorers).map(Scorer::iterator).toArray(DocIdSetIterator[]::new);
lead = iterators[0];
this.sumOfOtherClauses = new double[this.scorers.length];
this.maxDoc = maxDoc;
}

@Override
Expand Down Expand Up @@ -79,7 +81,7 @@ public int score(LeafCollector collector, Bits acceptDocs, int min, int max) thr
windowMin = Math.max(lead.docID(), windowMax + 1);
}

return windowMin;
return windowMin >= maxDoc ? DocIdSetIterator.NO_MORE_DOCS : windowMin;
}

private void scoreWindow(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ private BulkScorer requiredBulkScorer(LeafReaderContext context) throws IOExcept
&& requiredScoring.size() > 1
// Only specialize top-level conjunctions for clauses that don't have a two-phase iterator.
&& requiredScoring.stream().map(Scorer::twoPhaseIterator).allMatch(Objects::isNull)) {
return new BlockMaxConjunctionBulkScorer(requiredScoring);
return new BlockMaxConjunctionBulkScorer(context.reader().maxDoc(), requiredScoring);
}
if (scoreMode == ScoreMode.TOP_SCORES && requiredScoring.size() > 1) {
requiredScoring =
Expand Down

0 comments on commit ce464c7

Please sign in to comment.