zhaih commented on code in PR #12651:
URL: https://github.com/apache/lucene/pull/12651#discussion_r1357260551


##########
lucene/core/src/java/org/apache/lucene/util/hnsw/HnswGraphBuilder.java:
##########
@@ -288,7 +294,6 @@ private void selectAndLinkDiverse(
       // only adding it if it is closer to the target than to any of the other 
selected neighbors
       int cNode = candidates.node[i];
       float cScore = candidates.score[i];
-      assert cNode < hnsw.size();

Review Comment:
   Yeah the `size()` is actually a little bit broken after the initialize from 
graph change. Since when we init from another graph, the node Ids are not 
necessarily added in order, so in that change the `size()` actually returns 
`(the max node Id that is in the graph) + 1`. In this change I fixed the 
`size()` behavior back to `actual number of nodes inserted` and this assertion 
is broken.
   
   But you're right, it is still useful (especially on searcher side), so I'll 
introduce a new method `capacity` to indicate `(the max node Id that is in the 
graph) + 1` and use it here



-- 
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: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to