Class InitializedHnswGraphBuilder

java.lang.Object
org.apache.lucene.util.hnsw.HnswGraphBuilder
org.apache.lucene.util.hnsw.InitializedHnswGraphBuilder
All Implemented Interfaces:
HnswBuilder

public final class InitializedHnswGraphBuilder extends HnswGraphBuilder
This creates a graph builder that is initialized with the provided HnswGraph. This is useful for merging HnswGraphs from multiple segments.
WARNING: This API is experimental and might change in incompatible ways in the next release.
  • Constructor Details

  • Method Details

    • fromGraph

      public static InitializedHnswGraphBuilder fromGraph(RandomVectorScorerSupplier scorerSupplier, int M, int beamWidth, long seed, HnswGraph initializerGraph, int[] newOrdMap, BitSet initializedNodes, int totalNumberOfVectors) throws IOException
      Create a new HnswGraphBuilder that is initialized with the provided HnswGraph.
      Parameters:
      scorerSupplier - the scorer to use for vectors
      M - the number of connections to keep per node
      beamWidth - the number of nodes to explore in the search
      seed - the seed for the random number generator
      initializerGraph - the graph to initialize the new graph builder
      newOrdMap - a mapping from the old node ordinal to the new node ordinal
      initializedNodes - a bitset of nodes that are already initialized in the initializerGraph
      totalNumberOfVectors - the total number of vectors in the new graph, this should include all vectors expected to be added to the graph in the future
      Returns:
      a new HnswGraphBuilder that is initialized with the provided HnswGraph
      Throws:
      IOException - when reading the graph fails
    • initGraph

      public static OnHeapHnswGraph initGraph(int M, HnswGraph initializerGraph, int[] newOrdMap, int totalNumberOfVectors) throws IOException
      Throws:
      IOException
    • addGraphNode

      public void addGraphNode(int node) throws IOException
      Description copied from interface: HnswBuilder
      Inserts a doc with vector value to the graph
      Specified by:
      addGraphNode in interface HnswBuilder
      Overrides:
      addGraphNode in class HnswGraphBuilder
      Throws:
      IOException