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


##########
lucene/core/src/java/org/apache/lucene/util/hnsw/OnHeapHnswGraph.java:
##########
@@ -99,27 +122,31 @@ public void addNode(int level, int node) {
       entryNode = node;
     }
 
-    if (level > 0) {
-      // if the new node introduces a new level, add more levels to the graph,
-      // and make this node the graph's new entry point
-      if (level >= numLevels) {
-        for (int i = numLevels; i <= level; i++) {
-          graphUpperLevels.add(new HashMap<>());
-        }
-        numLevels = level + 1;
-        entryNode = node;
+    if (node >= graph.length) {
+      if (noGrowth) {
+        throw new AssertionError(

Review Comment:
   Ah let me throw `IllegalStateException` instead? (I think that's better than 
`IllegalArgumentException` maybe?)



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