@@ -787,12 +787,27 @@ public synchronized long removeDeletedNodes() {
787787 /**
788788 * Convenience method to build a new graph from an existing one, with the addition of new nodes.
789789 * This is useful when we want to merge a new set of vectors into an existing graph that is already on disk.
790+ *
791+ * @param onDiskGraphIndex the on-disk representation of the graph index to be processed and converted.
792+ * @param perLevelNeighborsScoreCache the cache containing pre-computed neighbor scores,
793+ * @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
794+ * @param buildScoreProvider the provider responsible for calculating build scores.
795+ * @param startingNodeOffset the offset in the newVectors RAVV where the new vectors start
796+ * @param graphToRavvOrdMap a mapping from the old graph's node ids to the newVectors RAVV node ids
797+ * @param beamWidth the width of the beam used during the graph building process.
798+ * @param overflowRatio the ratio of extra neighbors to allow temporarily when inserting a node.
799+ * @param alpha the weight factor for balancing score computations.
800+ * @param addHierarchy whether to add hierarchical structures while building the graph.
801+ *
802+ * @return the in-memory representation of the graph index.
803+ * @throws IOException if an I/O error occurs during the graph loading or conversion process.
790804 */
791805 public static OnHeapGraphIndex buildAndMergeNewNodes (OnDiskGraphIndex onDiskGraphIndex ,
792806 NeighborsScoreCache perLevelNeighborsScoreCache ,
793807 RandomAccessVectorValues newVectors ,
794808 BuildScoreProvider buildScoreProvider ,
795- int startingNodeId ,
809+ int startingNodeOffset ,
810+ int [] graphToRavvOrdMap ,
796811 int beamWidth ,
797812 float overflowRatio ,
798813 float alpha ,
@@ -813,9 +828,9 @@ public static OnHeapGraphIndex buildAndMergeNewNodes(OnDiskGraphIndex onDiskGrap
813828
814829 // Add each new vector incrementally
815830 final List <ForkJoinTask <?>> forkJoinTask = new ArrayList <>(newVectors .size ());
816- for (int i = 0 ; i < newVectors .size (); i ++) {
817- final int nodeId = startingNodeId + i ;
818- final VectorFloat <?> vector = newVectors .getVector (i );
831+ for (int i = startingNodeOffset ; i < newVectors .size (); i ++) {
832+ final int nodeId = i ;
833+ final VectorFloat <?> vector = newVectors .getVector (graphToRavvOrdMap [ nodeId ] );
819834
820835 // The GraphIndexBuilder can add nodes to an existing index
821836 forkJoinTask .add (PhysicalCoreExecutor .pool ().submit (() -> builder .addGraphNode (nodeId , vector )));
0 commit comments