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


##########
lucene/core/src/java/org/apache/lucene/util/hnsw/OnHeapHnswGraph.java:
##########
@@ -158,50 +185,82 @@ public int entryNode() {
     return entryNode;
   }
 
+  /**
+   * WARN: calling this method will essentially iterate through all nodes at 
level 0 (even if you're
+   * not getting node at level 0), we have built some caching mechanism such 
that if graph is not
+   * changed only the first non-zero level call will pay the cost. So it is 
highly NOT recommended
+   * to call this method while the graph is still building.
+   *
+   * <p>NOTE: if the node is not inserted in order (e.g. we're init'd from 
another graph) such that
+   * there are some node in middle are not inserted. (e.g. the largest node 
inserted is 10 but node
+   * 5 is not yet inserted) Calling getNodesOnLevel(0) will lead to a wrong 
behavior because it is a
+   * simple iterating over range(size) TODO: maybe we should fix the above 
behavior?

Review Comment:
   As I mentioned above, I used a more accurate `maxNodeId` to record that such 
that we can assert it.



-- 
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