add infostream status messages to HnswGraphBuilder.connectComponents (#13849)

This commit is contained in:
Michael Sokolov 2024-10-02 11:27:48 -04:00 committed by GitHub
parent 4a1653c220
commit 3f6e91e87b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 1 deletions

View File

@ -439,7 +439,11 @@ public class HnswGraphBuilder implements HnswBuilder {
maxConn *= 2;
}
List<Component> components = HnswUtil.components(hnsw, level, notFullyConnected, maxConn);
// System.out.println("HnswGraphBuilder.connectComponents level=" + level + ": " + components);
if (infoStream.isEnabled(HNSW_COMPONENT)) {
infoStream.message(
HNSW_COMPONENT, "connect " + components.size() + " components on level=" + level);
}
// System.out.println("HnswGraphBuilder. level=" + level + ": " + components);
boolean result = true;
if (components.size() > 1) {
// connect other components to the largest one
@ -457,6 +461,10 @@ public class HnswGraphBuilder implements HnswBuilder {
if (c.start() == NO_MORE_DOCS) {
continue;
}
if (infoStream.isEnabled(HNSW_COMPONENT)) {
infoStream.message(HNSW_COMPONENT, "connect component " + c + " to " + c0);
}
beam.clear();
eps[0] = c0.start();
RandomVectorScorer scorer = scorerSupplier.scorer(c.start());
@ -475,8 +483,14 @@ public class HnswGraphBuilder implements HnswBuilder {
// System.out.println("link " + c0 + "." + c0node + " to " + c + "." + c.start());
link(level, c0node, c.start(), score, notFullyConnected);
linked = true;
if (infoStream.isEnabled(HNSW_COMPONENT)) {
infoStream.message(HNSW_COMPONENT, "connected ok " + c0node + " -> " + c.start());
}
}
if (!linked) {
if (infoStream.isEnabled(HNSW_COMPONENT)) {
infoStream.message(HNSW_COMPONENT, "not connected; no free nodes found");
}
result = false;
}
}