jmazanec15 commented on code in PR #12050:
URL: https://github.com/apache/lucene/pull/12050#discussion_r1068562367


##########
lucene/core/src/java/org/apache/lucene/util/hnsw/OnHeapHnswGraph.java:
##########
@@ -94,36 +93,83 @@ public int size() {
   }
 
   /**
-   * Add node on the given level
+   * Add node on the given level. Nodes can be inserted out of order, but it 
requires that the nodes

Review Comment:
   Thinking about this more, one issue with a TreeSet based approach would be 
that we wouldnt be able to look up the index of a particular element (unless we 
converted the set to a list each time we need to do lookup). We need this index 
to query the OnHeapHnswGraph.graph to get the NeighborArray for a particular 
element 
([ref](https://github.com/jmazanec15/lucene/blob/hnsw-merge-from-graph/lucene/core/src/java/org/apache/lucene/util/hnsw/OnHeapHnswGraph.java#L87)).
 I am not sure if there is a good way around this - are you aware of any?
   
   Alternatively, I was thinking if we wanted to avoid the expensive copy for 
inserting when position < idx, we could switch from using an int[] to an 
ArrayList<Integer> to represent nodesByLevel for a particular level. This 
should avoid in most cases the extreme copy that out of order insertion would 
require.



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