Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,9 @@ public VectorScorer scorer(byte[] bytes) throws IOException {
if (scorer == null) {
return null;
}
DocIdSetIterator scorerIterator = scorer.iterator();
return new VectorScorer() {
private final DocIdSetIterator iterator = new ExitableDocSetIterator(scorer.iterator(), queryCancellation);
private final DocIdSetIterator iterator = exitableIterator(scorerIterator, queryCancellation);

@Override
public float score() throws IOException {
Expand Down Expand Up @@ -637,8 +638,9 @@ public VectorScorer scorer(float[] target) throws IOException {
if (scorer == null) {
return null;
}
DocIdSetIterator scorerIterator = scorer.iterator();
return new VectorScorer() {
private final DocIdSetIterator iterator = new ExitableDocSetIterator(scorer.iterator(), queryCancellation);
private final DocIdSetIterator iterator = exitableIterator(scorerIterator, queryCancellation);

@Override
public float score() throws IOException {
Expand All @@ -663,6 +665,15 @@ public FloatVectorValues copy() throws IOException {
}
}

/** Wraps the iterator in an exitable iterator, specializing for KnnVectorValues.DocIndexIterator. */
static DocIdSetIterator exitableIterator(DocIdSetIterator iterator, QueryCancellation queryCancellation) {
if (iterator instanceof KnnVectorValues.DocIndexIterator docIndexIterator) {
return createExitableIterator(docIndexIterator, queryCancellation);
} else {
return new ExitableDocSetIterator(iterator, queryCancellation);
}
}

private static KnnVectorValues.DocIndexIterator createExitableIterator(
KnnVectorValues.DocIndexIterator delegate,
QueryCancellation queryCancellation
Expand Down