msokolov commented on code in PR #14022: URL: https://github.com/apache/lucene/pull/14022#discussion_r1887226606
########## lucene/core/src/java/org/apache/lucene/util/hnsw/HnswUtil.java: ########## @@ -163,6 +164,10 @@ private static Component markRooted( throws IOException { // Start at entry point and search all nodes on this level // System.out.println("markRooted level=" + level + " entryPoint=" + entryPoint); + if (connectedNodes.get(entryPoint)) { + return new Component(entryPoint, 0); Review Comment: this should never happen, right? because we enter with the next non-connected node. Can we add an `assert false` here before the return statement so we catch during testing. ########## lucene/core/src/java/org/apache/lucene/util/hnsw/HnswUtil.java: ########## @@ -178,7 +183,10 @@ private static Component markRooted( int friendCount = 0; while ((friendOrd = hnswGraph.nextNeighbor()) != NO_MORE_DOCS) { ++friendCount; - stack.push(friendOrd); + if (connectedNodes.get(friendOrd) == false && nodesInStack.contains(friendOrd) == false) { Review Comment: yes, this change looks good! Thanks for re-surfacing it Vigya ########## lucene/core/src/java/org/apache/lucene/util/hnsw/HnswUtil.java: ########## @@ -163,6 +164,10 @@ private static Component markRooted( throws IOException { // Start at entry point and search all nodes on this level // System.out.println("markRooted level=" + level + " entryPoint=" + entryPoint); + if (connectedNodes.get(entryPoint)) { + return new Component(entryPoint, 0); Review Comment: oh wait, this can happen because we iterate over all the entryPoints. Q: do we need this zero-size component for anything? Can we recall what happens with these componentws when we're done - the only purpose is to use them for reconnecting the graph. Yeah it looks like we will try to connect them again, which we could skip. Let's not add these empty components to the list. -- 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