Skip to content

Commit

Permalink
Fix sneaky bug on iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosdelest committed Dec 5, 2024
1 parent ef8ac8c commit 4c65c8a
Showing 1 changed file with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,14 @@ public DoubleValues getValues(LeafReaderContext ctx, DoubleValues scores) throws
final KnnVectorValues.DocIndexIterator iterator = vectorValues.iterator();

return new DoubleValues() {
private int docId = -1;

@Override
public double doubleValue() throws IOException {
vectorOpsCount++;
return vectorSimilarityFunction.compare(target, vectorValues.vectorValue(docId));
return vectorSimilarityFunction.compare(target, vectorValues.vectorValue(iterator.index()));
}

@Override
public boolean advanceExact(int doc) throws IOException {
assert doc > iterator.docID();
docId = doc;
return doc >= iterator.docID() && iterator.docID() != DocIdSetIterator.NO_MORE_DOCS && iterator.advance(doc) == doc;
}
};
Expand Down

0 comments on commit 4c65c8a

Please sign in to comment.