msokolov commented on code in PR #12651: URL: https://github.com/apache/lucene/pull/12651#discussion_r1356041142
########## lucene/core/src/java/org/apache/lucene/util/hnsw/OnHeapHnswGraph.java: ########## @@ -40,31 +41,29 @@ public final class OnHeapHnswGraph extends HnswGraph implements Accountable { // to vectors // added to HnswBuilder, and the node values are the ordinals of those vectors. // Thus, on all levels, neighbors expressed as the level 0's nodes' ordinals. - private final List<NeighborArray> graphLevel0; Review Comment: I was thinking maybe for the immutable case we can use `List.of(new NeighborArray[size])`? Just to avoid having to write all the array-resizing code ourselves and still have the convenience of ArrayList for the single-threaded case? Oh now I see you are using the 2d dimension for the level. Hmm that is interesting but since it will usually be sparse we will still have a lot of mutations to do -- I think it might be cleaner to keep the "upper" levels in a separate data structure that we can modify under lock. That way the level0 can still be accessed lock-free (at least the array of rows -- we will still need locks for the rows) ########## lucene/core/src/java/org/apache/lucene/util/hnsw/HnswGraphSearcher.java: ########## @@ -232,7 +231,6 @@ void searchLevel( graphSeek(graph, level, topCandidateNode); int friendOrd; while ((friendOrd = graphNextNeighbor(graph)) != NO_MORE_DOCS) { - assert friendOrd < size : "friendOrd=" + friendOrd + "; size=" + size; Review Comment: can we keep? I think we will need all the assertions we can get to try to ensure thread-safety?! ########## 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: why are we deleting these assertions? -- 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