shubhamvishu commented on code in PR #15560:
URL: https://github.com/apache/lucene/pull/15560#discussion_r2677960091
##########
lucene/core/src/java/org/apache/lucene/codecs/lucene99/Lucene99HnswVectorsReader.java:
##########
@@ -335,15 +335,15 @@ private void search(
// Take into account if quantized? E.g. some scorer cost?
// Use approximate cardinality as this is good enough, but ensure we don't
exceed the graph
// size as that is illogical
- HnswGraph graph = getGraph(fieldEntry);
- int filteredDocCount = Math.min(acceptDocs.cost(), graph.size());
+ int graphSize = (fieldEntry.vectorIndexLength() == 0) ? 0 :
fieldEntry.size();
+ int filteredDocCount = Math.min(acceptDocs.cost(), graphSize);
Bits accepted = acceptDocs.bits();
final Bits acceptedOrds = scorer.getAcceptOrds(accepted);
int numVectors = scorer.maxOrd();
boolean doHnsw = knnCollector.k() < numVectors;
// The approximate number of vectors that would be visited if we did not
filter
- int unfilteredVisit =
HnswGraphSearcher.expectedVisitedNodes(knnCollector.k(), graph.size());
- if (unfilteredVisit >= filteredDocCount || graph.size() == 0) {
+ int unfilteredVisit =
HnswGraphSearcher.expectedVisitedNodes(knnCollector.k(), graphSize);
+ if (unfilteredVisit >= filteredDocCount || graphSize == 0) {
Review Comment:
We are already checking that on L338. So in case of delayed graph building
`graphSize` will be 0 because `fieldEntry.vectorIndexLength == 0` (same as
current) or else the size of graph (when `fieldEntry.vectorIndexLength != 0`) .
This tries to replicate the `getGraph` logic but without having to
initialize the graph unnecessarily.
--
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]