Class HnswConcurrentMergeBuilder.ConcurrentMergeWorker

    • Field Detail

      • workProgress

        private final java.util.concurrent.atomic.AtomicInteger workProgress
        A common AtomicInteger shared among all workers, used for tracking what's the next vector to be added to the graph.
      • initializedNodes

        private final BitSet initializedNodes
      • batchSize

        private int batchSize
    • Constructor Detail

      • ConcurrentMergeWorker

        private ConcurrentMergeWorker​(RandomVectorScorerSupplier scorerSupplier,
                                      int M,
                                      int beamWidth,
                                      long seed,
                                      OnHeapHnswGraph hnsw,
                                      BitSet initializedNodes,
                                      java.util.concurrent.atomic.AtomicInteger workProgress)
                               throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • run

        private void run​(int maxOrd)
                  throws java.io.IOException
        This method first try to "reserve" part of work by calling getStartPos(int) and then calling HnswGraphBuilder.addVectors(int, int) to actually add the nodes to the graph. By doing this we are able to dynamically allocate the work to multiple workers and try to make all of them finishing around the same time.
        Throws:
        java.io.IOException
      • getStartPos

        private int getStartPos​(int maxOrd)
        Reserve the work by atomically increment the workProgress