@@ -785,12 +785,27 @@ public synchronized long removeDeletedNodes() {
785785 /**
786786 * Convenience method to build a new graph from an existing one, with the addition of new nodes.
787787 * This is useful when we want to merge a new set of vectors into an existing graph that is already on disk.
788+ *
789+ * @param onDiskGraphIndex the on-disk representation of the graph index to be processed and converted.
790+ * @param perLevelNeighborsScoreCache the cache containing pre-computed neighbor scores,
791+ * @param newVectors a super set RAVV containing the new vectors to be added to the graph as well as the old ones that are already in the graph
792+ * @param buildScoreProvider the provider responsible for calculating build scores.
793+ * @param startingNodeOffset the offset in the newVectors RAVV where the new vectors start
794+ * @param graphToRavvOrdMap a mapping from the old graph's node ids to the newVectors RAVV node ids
795+ * @param beamWidth the width of the beam used during the graph building process.
796+ * @param overflowRatio the ratio of extra neighbors to allow temporarily when inserting a node.
797+ * @param alpha the weight factor for balancing score computations.
798+ * @param addHierarchy whether to add hierarchical structures while building the graph.
799+ *
800+ * @return the in-memory representation of the graph index.
801+ * @throws IOException if an I/O error occurs during the graph loading or conversion process.
788802 */
789803 public static OnHeapGraphIndex buildAndMergeNewNodes (OnDiskGraphIndex onDiskGraphIndex ,
790804 NeighborsScoreCache perLevelNeighborsScoreCache ,
791805 RandomAccessVectorValues newVectors ,
792806 BuildScoreProvider buildScoreProvider ,
793- int startingNodeId ,
807+ int startingNodeOffset ,
808+ int [] graphToRavvOrdMap ,
794809 int beamWidth ,
795810 float overflowRatio ,
796811 float alpha ,
@@ -811,9 +826,9 @@ public static OnHeapGraphIndex buildAndMergeNewNodes(OnDiskGraphIndex onDiskGrap
811826
812827 // Add each new vector incrementally
813828 final List <ForkJoinTask <?>> forkJoinTask = new ArrayList <>(newVectors .size ());
814- for (int i = 0 ; i < newVectors .size (); i ++) {
815- final int nodeId = startingNodeId + i ;
816- final VectorFloat <?> vector = newVectors .getVector (i );
829+ for (int i = startingNodeOffset ; i < newVectors .size (); i ++) {
830+ final int nodeId = i ;
831+ final VectorFloat <?> vector = newVectors .getVector (graphToRavvOrdMap [ nodeId ] );
817832
818833 // The GraphIndexBuilder can add nodes to an existing index
819834 forkJoinTask .add (PhysicalCoreExecutor .pool ().submit (() -> builder .addGraphNode (nodeId , vector )));
0 commit comments