mayya-sharipova commented on code in PR #947:
URL: https://github.com/apache/lucene/pull/947#discussion_r923807979
##########
lucene/core/src/java/org/apache/lucene/codecs/KnnVectorsReader.java:
##########
@@ -89,4 +123,67 @@ public abstract TopDocs search(
public KnnVectorsReader getMergeInstance() {
return this;
}
+
+ /** {@link #searchExhaustively} */
+ protected static TopDocs exhaustiveSearch(
+ VectorValues vectorValues,
+ DocIdSetIterator acceptDocs,
+ VectorSimilarityFunction similarityFunction,
+ float[] target,
+ int k)
+ throws IOException {
+ HitQueue queue = new HitQueue(k, true);
+ ScoreDoc topDoc = queue.top();
+ int doc;
+ while ((doc = acceptDocs.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
+ int vectorDoc = vectorValues.advance(doc);
+ assert vectorDoc == doc;
+ float score = similarityFunction.compare(vectorValues.vectorValue(),
target);
+ if (score >= topDoc.score) {
+ topDoc.score = score;
+ topDoc.doc = doc;
+ topDoc = queue.updateTop();
+ }
+ }
+ return topDocsFromHitQueue(queue, acceptDocs.cost());
+ }
+
+ /** {@link #searchExhaustively} */
+ protected static TopDocs exhaustiveSearch(
+ VectorValues vectorValues,
+ DocIdSetIterator acceptDocs,
+ VectorSimilarityFunction similarityFunction,
Review Comment:
looks like `similarityFunction` is not necessary here, as we always use
`dotProductScore`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]