Package-level declarations

Types

Link copied to clipboard

AbstractHnswGraphSearcher is the base class for HnswGraphSearcher implementations.

Link copied to clipboard
class BlockingFloatHeap(maxSize: Int)

A blocking bounded min heap that stores floats. The top element is the lowest value of the heap.

Link copied to clipboard

A supplier that creates UpdateableRandomVectorScorer from an ordinal. Caller should be sure to close after use

Link copied to clipboard
class ConcurrentHnswMerger(fieldInfo: FieldInfo, scorerSupplier: RandomVectorScorerSupplier, M: Int, beamWidth: Int, taskExecutor: TaskExecutor, numWorker: Int) : IncrementalHnswGraphMerger

This merger merges graph in a concurrent manner, by using HnswConcurrentMergeBuilder

Link copied to clipboard

Searches an HNSW graph to find nearest neighbors to a query vector. This particular implementation is optimized for a filtered search, inspired by the ACORN-1 algorithm. https://arxiv.org/abs/2403.04871 However, this implementation is augmented in some ways, mainly:

Link copied to clipboard
class FloatHeap(maxSize: Int)

A bounded min heap that stores floats. The top element is the lowest value of the heap.

Link copied to clipboard
interface HnswBuilder

Interface for builder building the OnHeapHnswGraph

Link copied to clipboard
class HnswConcurrentMergeBuilder(taskExecutor: TaskExecutor, numWorker: Int, scorerSupplier: RandomVectorScorerSupplier, beamWidth: Int, hnsw: OnHeapHnswGraph, initializedNodes: BitSet?) : HnswBuilder

A graph builder that manages multiple workers, it only supports adding the whole graph all at once. It will spawn a thread for each worker and the workers will pick the work in batches.

Link copied to clipboard
abstract class HnswGraph

Hierarchical Navigable Small World graph. Provides efficient approximate nearest neighbor search for high dimensional vectors. See Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs 2018 paper for details.

Link copied to clipboard

Builder for HNSW graph. See HnswGraph for a gloss on the algorithm and the meaning of the hyper-parameters.

Link copied to clipboard
interface HnswGraphMerger

Abstraction of merging multiple graphs into one on-heap graph

Link copied to clipboard

Searches an HNSW graph to find nearest neighbors to a query vector. For more background on the search algorithm, see HnswGraph.

Link copied to clipboard
class HnswLock

Provide (read-and-write) striped locks for access to nodes of an OnHeapHnswGraph. For use by HnswConcurrentMergeBuilder and its HnswGraphBuilders.

Link copied to clipboard
object HnswUtil

Utilities for use in tests involving HNSW graphs

Link copied to clipboard
open class IncrementalHnswGraphMerger(fieldInfo: FieldInfo, scorerSupplier: RandomVectorScorerSupplier, M: Int, beamWidth: Int) : HnswGraphMerger

This selects the biggest Hnsw graph from the provided merge state and initializes a new HnswGraphBuilder with that graph as a starting point.

Link copied to clipboard
class InitializedHnswGraphBuilder(scorerSupplier: RandomVectorScorerSupplier, beamWidth: Int, seed: Long, initializedGraph: OnHeapHnswGraph, initializedNodes: BitSet) : HnswGraphBuilder

This creates a graph builder that is initialized with the provided HnswGraph. This is useful for merging HnswGraphs from multiple segments.

Link copied to clipboard
fun interface IntToIntFunction

Native int to int function

Link copied to clipboard
interface Lock

Platform-agnostic lock interface

Link copied to clipboard
class NeighborArray(maxSize: Int, scoresDescOrder: Boolean)

NeighborArray encodes the neighbors of a node and their mutual scores in the HNSW graph as a pair of growable arrays. Nodes are arranged in the sorted order of their scores in descending order (if scoresDescOrder is true), or in the ascending order of their scores (if scoresDescOrder is false)

Link copied to clipboard
class NeighborQueue(initialSize: Int, maxHeap: Boolean)

NeighborQueue uses a LongHeap to store lists of arcs in an HNSW graph, represented as a neighbor node id with an associated score packed together as a sortable long, which is sorted primarily by score. The queue provides both fixed-size and unbounded operations via .insertWithOverflow and .add, and provides MIN and MAX heap subclasses.

Link copied to clipboard

An HnswGraph where all nodes and connections are held in memory. This class is used to construct the HNSW graph before it's written to the index.

Link copied to clipboard
class OrdinalTranslatedKnnCollector(collector: KnnCollector, vectorOrdinalToDocId: (Int) -> Int) : KnnCollector.Decorator

Wraps a provided KnnCollector object, translating the provided vectorId ordinal to a documentId

Link copied to clipboard

A RandomVectorScorer for scoring random nodes in batches against an abstract query. This class isn't thread-safe and should be used by a single thread.

Link copied to clipboard

A supplier that creates RandomVectorScorer from an ordinal.

Link copied to clipboard

port of java.util.concurrent.locks.ReentrantReadWriteLock

Link copied to clipboard

Just like a RandomVectorScorer but allows the scoring ordinal to be changed. Useful during indexing operations