LantaoJin commented on code in PR #16794:
URL: https://github.com/apache/lucene/pull/16794#discussion_r4236462133
##########
lucene/core/src/java/org/apache/lucene/util/hnsw/HnswConcurrentMergeBuilder.java:
##########
@@ -318,6 +529,56 @@ public void addGraphNode(int node) throws IOException {
}
super.addGraphNode(node);
}
+
+ /** Adds a node of the join set of a graph being joined, with a full
search. */
+ private void addJoinSetNode(int node, InsertedNodes inserted) throws
IOException {
+ // skip the initializedNodes check: the node is marked since it belongs
to a graph being
+ // joined
+ super.addGraphNode(node);
+ inserted.add(node);
+ }
+
+ /**
+ * Adds a node of a graph being joined that is not in its join set. Like
{@link
+ * MergingHnswGraphBuilder}, the search on level 0 enters from the node's
neighbors in that
+ * graph that are already inserted, which includes its join set neighbors,
and from their
+ * neighbors in the merged graph.
+ *
+ * @param u the node, as an ordinal of the graph being joined
+ */
+ private void addJoinedNode(JoinPlan plan, int u, InsertedNodes inserted)
throws IOException {
+ int numNeighbors = 0;
+ plan.graphLock.lock();
Review Comment:
fixed
##########
lucene/core/src/test/org/apache/lucene/util/hnsw/TestConcurrentHnswMerger.java:
##########
@@ -0,0 +1,408 @@
+/*
+ * 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.util.hnsw;
+
+import static org.apache.lucene.search.DocIdSetIterator.NO_MORE_DOCS;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.LongAdder;
+import org.apache.lucene.codecs.hnsw.DefaultFlatVectorScorer;
+import org.apache.lucene.codecs.lucene99.Lucene99HnswVectorsFormat;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.document.KnnFloatVectorField;
+import org.apache.lucene.document.StringField;
+import org.apache.lucene.index.CodecReader;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.FieldInfo;
+import org.apache.lucene.index.FloatVectorValues;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.LeafReaderContext;
+import org.apache.lucene.index.MergeState;
+import org.apache.lucene.index.NoMergePolicy;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.index.VectorSimilarityFunction;
+import org.apache.lucene.search.ScoreDoc;
+import org.apache.lucene.search.TaskExecutor;
+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.Bits;
+import org.apache.lucene.util.InfoStream;
+import org.apache.lucene.util.NamedThreadFactory;
+
+/**
+ * Compares {@link ConcurrentHnswMerger} with the single-threaded {@link
IncrementalHnswGraphMerger}
+ * when merging several graphs.
+ */
+public class TestConcurrentHnswMerger extends LuceneTestCase {
Review Comment:
done
--
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]