benwtrent commented on code in PR #15011:
URL: https://github.com/apache/lucene/pull/15011#discussion_r2270727974
##########
lucene/core/src/java/org/apache/lucene/codecs/lucene99/Lucene99HnswVectorsReader.java:
##########
@@ -332,20 +332,19 @@ private void search(
final RandomVectorScorer scorer = scorerSupplier.get();
final KnnCollector collector =
new OrdinalTranslatedKnnCollector(knnCollector, scorer::ordToDoc);
- final Bits acceptedOrds = scorer.getAcceptOrds(acceptDocs);
+ Bits accepted = acceptDocs.bits();
+ final Bits acceptedOrds = scorer.getAcceptOrds(accepted);
HnswGraph graph = getGraph(fieldEntry);
boolean doHnsw = knnCollector.k() < scorer.maxOrd();
// Take into account if quantized? E.g. some scorer cost?
int filteredDocCount = 0;
// The approximate number of vectors that would be visited if we did not
filter
int unfilteredVisit =
HnswGraphSearcher.expectedVisitedNodes(knnCollector.k(), graph.size());
- if (acceptDocs instanceof BitSet bitSet) {
- // Use approximate cardinality as this is good enough, but ensure we
don't exceed the graph
- // size as that is illogical
- filteredDocCount = Math.min(bitSet.approximateCardinality(),
graph.size());
- if (unfilteredVisit >= filteredDocCount) {
- doHnsw = false;
- }
+ // Use approximate cardinality as this is good enough, but ensure we don't
exceed the graph
+ // size as that is illogical
+ filteredDocCount = Math.min(acceptDocs.cost(), graph.size());
+ if (unfilteredVisit >= filteredDocCount) {
+ doHnsw = false;
Review Comment:
❤️
--
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]