mayya-sharipova commented on a change in pull request #287:
URL: https://github.com/apache/lucene/pull/287#discussion_r705421087



##########
File path: lucene/core/src/java/org/apache/lucene/util/hnsw/HnswGraph.java
##########
@@ -56,21 +58,27 @@
 public final class HnswGraph extends KnnGraphValues {
 
   private final int maxConn;
+  private int curMaxLevel; // the current max graph level
+  private int entryNode; // the current graph entry node on the top level
+
+  // Nodes by level expressed as the level 0's nodes' ordinals.
+  // As level 0 contains all nodes, nodesByLevel.get(0) is null.
+  private final List<int[]> nodesByLevel;
+
   // graph is a list of graph levels.
   // Each level is represented as List<NeighborArray> – nodes' connections on 
this level.
   // Each entry in the list has the top maxConn neighbors of a node. The nodes 
correspond to vectors
   // added to HnswBuilder, and the node values are the ordinals of those 
vectors.
+  // Thus, on all levels, neighbors expressed as the level 0's nodes' ordinals.
   private final List<List<NeighborArray>> graph;
-  private int curMaxLevel; // the current max graph level
-  private int entryNode; // the current graph entry node on the top level
 
   // KnnGraphValues iterator members
   private int upto;
   private NeighborArray cur;
 
   // used for iterating over graph values
   private int curLevel = -1;
-  private int curNode = -1;
+  private int curNodeOrd = -1;

Review comment:
       @jtibshirani Great comment, indeed it was confusing. In 
2c02db0c5dc0b290f7eb4d1b9c9e3d8d2691f364:
   -  In `KnnGraphValues` I removed `seekLevel(level)`, and instead adopted the 
previous `seek(level, target)` method.
   - In `HnswGraph`  I removed `curNodeOrd` and `curLevel` fields, we don't 
need them anymore. Added `getAllNodesOnLevel(level)` that allows to iterate 
over nodes on the given level. This is needed both for tests, and also later in 
`Lucene90HnswVectorsWriter`  when storing a graph on disk.




-- 
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]

Reply via email to