mayya-sharipova commented on a change in pull request #267:
URL: https://github.com/apache/lucene/pull/267#discussion_r700584352
##########
File path: lucene/core/src/java/org/apache/lucene/util/hnsw/HnswGraph.java
##########
@@ -188,15 +244,28 @@ public int size() {
}
// TODO: optimize RAM usage so not to store references for all nodes for
levels > 0
+ // TODO: add extra levels if level >= numLevels
public void addNode(int level, int node) {
if (level > 0) {
+ // if the new node introduces a new level, make this node the graph's
new entry point
+ if (level > curMaxLevel) {
+ curMaxLevel = level;
+ entryNode = node;
+ // add more levels if needed
+ if (level >= graph.size()) {
+ for (int i = graph.size(); i <= level; i++) {
+ graph.add(new ArrayList<>());
+ }
+ }
+ }
// Levels above 0th don't contain all nodes,
Review comment:
@msokolov Are you suggesting this for the whole graph organization?
Instead of having a list of levels?
--
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]