jeho-rpls commented on code in PR #16403:
URL: https://github.com/apache/lucene/pull/16403#discussion_r3615578350


##########
lucene/core/src/test/org/apache/lucene/index/TestHnswGraphReuseDuringMerge.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.index;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.KnnFloatVectorField;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.tests.util.LuceneTestCase;
+import org.apache.lucene.tests.util.TestUtil;
+import org.apache.lucene.util.InfoStream;
+
+/**
+ * Tests that merging deletion-free segments under the default codec reuses 
their existing HNSW

Review Comment:
   Thanks for the review!
   
   You're right. As far as I can tell, a graph with deletions can still be 
selected as the base graph when its delete percentage is at most 
`DELETE_PCT_THRESHOLD` (40%) in `addReader`, and only deletion-free graphs are 
joined on top of it. 
   Deleted nodes are mapped to `-1` and skipped when 
`InitializedHnswGraphBuilder` copies the base graph, and nodes that lost too 
many neighbors get repaired (`repairDisconnectedNodes`) with the level 
hierarchy rebalanced afterwards.
   
   I agree it is worth a test. 
   Happy to add a case here that deletes some documents from the largest 
segment (staying below the threshold) and asserts the merge still takes the 
join path. 
   
   Please let me know if you had a different case in mind!
   
   
[2fadcb5](https://github.com/apache/lucene/pull/16403/commits/2fadcb5ce3b0e46b227cefbba20709224018ee5e)



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to