Class OnHeapGraph<T>

java.lang.Object
org.apache.cassandra.index.sai.disk.v1.vector.OnHeapGraph<T>

public class OnHeapGraph<T> extends Object
  • Field Details

  • Constructor Details

    • OnHeapGraph

      public OnHeapGraph(AbstractType<?> termComparator, IndexWriterConfig indexWriterConfig, Memtable memtable)
      Parameters:
      termComparator - the vector type
      indexWriterConfig - the IndexWriterConfig for the graph
      memtable - should be provided if attached to a memtable, null otherwise (i.e. compaction). Allows us to configure concurrent search and provide more meaningful trace logging. Concurrent search while building the graph; non-concurrent allows us to avoid synchronization costs.
  • Method Details

    • size

      public int size()
    • isEmpty

      public boolean isEmpty()
    • add

      public long add(ByteBuffer term, T key, OnHeapGraph.InvalidVectorBehavior behavior)
      Returns:
      the incremental bytes ysed by adding the given vector to the index
    • checkInBounds

      public static void checkInBounds(float[] v)
    • validateIndexable

      public static void validateIndexable(float[] vector, io.github.jbellis.jvector.vector.VectorSimilarityFunction similarityFunction)
    • keysFromOrdinal

      public Collection<T> keysFromOrdinal(int node)
    • vectorForKey

      public float[] vectorForKey(T key)
    • remove

      public long remove(ByteBuffer term, T key)
    • search

      public CloseableIterator<io.github.jbellis.jvector.graph.SearchResult.NodeScore> search(float[] queryVector, int limit, io.github.jbellis.jvector.util.Bits toAccept)
      Returns:
      keys (PrimaryKey or segment row id) associated with the topK vectors near the query
    • writeData

      public SegmentMetadata.ComponentMetadataMap writeData(IndexDescriptor indexDescriptor, IndexIdentifier indexIdentifier, Function<T,Integer> postingTransformer) throws IOException
      Throws:
      IOException