benwtrent commented on code in PR #13561:
URL: https://github.com/apache/lucene/pull/13561#discussion_r1672957009
##########
lucene/core/src/java/org/apache/lucene/util/hnsw/HnswGraphBuilder.java:
##########
@@ -156,14 +157,20 @@ public OnHeapHnswGraph build(int maxOrd) throws
IOException {
infoStream.message(HNSW_COMPONENT, "build graph from " + maxOrd + "
vectors");
}
addVectors(maxOrd);
- return hnsw;
Review Comment:
I think checking for `frozen` at the start of build is wise and prevents
info stream writing when we are already frozen.
##########
lucene/core/src/java/org/apache/lucene/util/hnsw/HnswGraphBuilder.java:
##########
@@ -156,14 +157,20 @@ public OnHeapHnswGraph build(int maxOrd) throws
IOException {
infoStream.message(HNSW_COMPONENT, "build graph from " + maxOrd + "
vectors");
}
addVectors(maxOrd);
- return hnsw;
+ return getCompletedGraph();
}
@Override
public void setInfoStream(InfoStream infoStream) {
this.infoStream = infoStream;
}
+ @Override
+ public OnHeapHnswGraph getCompletedGraph() {
+ frozen = true;
+ return getGraph();
+ }
+
@Override
public OnHeapHnswGraph getGraph() {
return hnsw;
Review Comment:
We should check for frozen directly in `addVectors` to prevent infoStream
writing if there is some sub-class calling this method erroneously
--
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]