A graph builder that is used during segments' merging.
This builder uses a smart algorithm to merge multiple graphs into a single graph. The
algorithm is based on the idea that if we know where we want to insert a node, we have a good
idea of where we want to insert its neighbors.
The algorithm is based on the following steps:
Get all graphs that don't have deletions and sort them by size desc.
Copy the largest graph to the new graph (gL).
For each remaining small graph (gS):
Find the nodes that best cover gS: join set `j`. These nodes will be inserted into gL
as usual: by searching gL to find the best candidates `w` to which connect the nodes.
For each remaining node in gS:
We provide eps to search in gL. We form `eps` by the union of the node's
neighbors in gS and the node's neighbors' neighbors in gL. We also limit
beamWidth (efConstruction to M*3)
We expect the size of join set `j` to be small, around 1/5 to 1/2 of the size of gS. For the
rest of the nodes in gS, we expect savings by performing lighter searches in gL.
Java: fromGraphs(org.apache.lucene.util.hnsw.RandomVectorScorerSupplier scorerSupplier, int M, int beamWidth, long seed, org.apache.lucene.util.hnsw.HnswGraph[] graphs, int[][] ordMaps, int totalNumberOfVectors, org.apache.lucene.util.BitSet initializedNodes)
Create a new HnswGraphBuilder that is initialized with the provided HnswGraph.