Call HnswGraphBuilder.getCompletedGraph() in 94/95 back-compat writers (#13654)

This commit is contained in:
Michael Sokolov 2024-08-14 08:55:21 -04:00 committed by GitHub
parent a40bb39195
commit 2b0c6cdcbc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 5 deletions

View File

@ -693,9 +693,9 @@ public final class Lucene94HnswVectorsWriter extends KnnVectorsWriter {
lastDocID = docID;
}
OnHeapHnswGraph getGraph() {
OnHeapHnswGraph getGraph() throws IOException {
if (vectors.size() > 0) {
return hnswGraphBuilder.getGraph();
return hnswGraphBuilder.getCompletedGraph();
} else {
return null;
}

View File

@ -732,9 +732,9 @@ public final class Lucene95HnswVectorsWriter extends KnnVectorsWriter {
lastDocID = docID;
}
OnHeapHnswGraph getGraph() {
OnHeapHnswGraph getGraph() throws IOException {
if (vectors.size() > 0) {
return hnswGraphBuilder.getGraph();
return hnswGraphBuilder.getCompletedGraph();
} else {
return null;
}

View File

@ -412,6 +412,7 @@ public class HnswGraphBuilder implements HnswBuilder {
}
void finish() throws IOException {
// System.out.println("finish " + frozen);
connectComponents();
frozen = true;
}
@ -438,7 +439,7 @@ public class HnswGraphBuilder implements HnswBuilder {
maxConn *= 2;
}
List<Component> components = HnswUtil.components(hnsw, level, notFullyConnected, maxConn);
// System.out.println("HnswGraphBuilder.connectComponents " + components);
// System.out.println("HnswGraphBuilder.connectComponents level=" + level + ": " + components);
boolean result = true;
if (components.size() > 1) {
// connect other components to the largest one