mirror of
https://github.com/apache/lucene.git
synced 2025-02-08 02:58:58 +00:00
Make the HitQueue size more appropriate for KNN exact search (#13184)
Currently, when performing KNN exact search, we consistently set the HitQueue size to k. However, there may be instances where the number of candidates is actually lower than k.
This commit is contained in:
parent
d393b9d039
commit
7a08eeab47
@ -222,6 +222,7 @@ Optimizations
|
||||
|
||||
* GITHUB#13121: Speedup multi-segment HNSW graph search for diversifying child kNN queries. Builds on GITHUB#12962.
|
||||
(Ben Trent)
|
||||
* GITHUB#13184: Make the HitQueue size more appropriate for KNN exact search (Pan Guixin)
|
||||
|
||||
Bug Fixes
|
||||
---------------------
|
||||
|
@ -190,7 +190,8 @@ abstract class AbstractKnnVectorQuery extends Query {
|
||||
if (vectorScorer == null) {
|
||||
return NO_RESULTS;
|
||||
}
|
||||
HitQueue queue = new HitQueue(k, true);
|
||||
final int queueSize = Math.min(k, Math.toIntExact(acceptIterator.cost()));
|
||||
HitQueue queue = new HitQueue(queueSize, true);
|
||||
ScoreDoc topDoc = queue.top();
|
||||
int doc;
|
||||
while ((doc = acceptIterator.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
|
||||
|
@ -98,7 +98,8 @@ public class DiversifyingChildrenByteKnnVectorQuery extends KnnByteVectorQuery {
|
||||
parentBitSet,
|
||||
query,
|
||||
fi.getVectorSimilarityFunction());
|
||||
HitQueue queue = new HitQueue(k, true);
|
||||
final int queueSize = Math.min(k, Math.toIntExact(acceptIterator.cost()));
|
||||
HitQueue queue = new HitQueue(queueSize, true);
|
||||
ScoreDoc topDoc = queue.top();
|
||||
while (vectorScorer.nextParent() != DocIdSetIterator.NO_MORE_DOCS) {
|
||||
float score = vectorScorer.score();
|
||||
|
@ -98,7 +98,8 @@ public class DiversifyingChildrenFloatKnnVectorQuery extends KnnFloatVectorQuery
|
||||
parentBitSet,
|
||||
query,
|
||||
fi.getVectorSimilarityFunction());
|
||||
HitQueue queue = new HitQueue(k, true);
|
||||
final int queueSize = Math.min(k, Math.toIntExact(acceptIterator.cost()));
|
||||
HitQueue queue = new HitQueue(queueSize, true);
|
||||
ScoreDoc topDoc = queue.top();
|
||||
while (vectorScorer.nextParent() != DocIdSetIterator.NO_MORE_DOCS) {
|
||||
float score = vectorScorer.score();
|
||||
|
Loading…
x
Reference in New Issue
Block a user