Skip to content

Implement ConstantScoreScorer#nextDocsAndScores #14772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lucene/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ Optimizations

* GITHUB#14753: Implement IndexedDISI#docIDRunEnd. (Ge Song)

* GITHUB#14772: Implement ConstantScoreScorer#nextDocsAndScores. (Ge Song)

Bug Fixes
---------------------
* GITHUB#14654: ValueSource.fromDoubleValuesSource(dvs).getSortField() would throw errors when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package org.apache.lucene.search;

import java.io.IOException;
import java.util.Arrays;
import org.apache.lucene.util.Bits;

/**
* A constant-scoring {@link Scorer}.
Expand Down Expand Up @@ -144,4 +146,21 @@ public int docID() {
public float score() throws IOException {
return score;
}

@Override
public void nextDocsAndScores(int upTo, Bits liveDocs, DocAndFloatFeatureBuffer buffer)
throws IOException {
int batchSize = 64;
buffer.growNoCopy(batchSize);
int size = 0;
DocIdSetIterator iterator = iterator();
for (int doc = iterator.docID(); doc < upTo && size < batchSize; doc = iterator.nextDoc()) {
if (liveDocs == null || liveDocs.get(doc)) {
buffer.docs[size] = doc;
++size;
}
}
Arrays.fill(buffer.features, 0, size, score);
buffer.size = size;
}
}