Class SegmentRowIdOrdinalPairs

java.lang.Object
org.apache.cassandra.index.sai.disk.v1.vector.SegmentRowIdOrdinalPairs

public class SegmentRowIdOrdinalPairs extends Object
A specialized data structure that stores segment row id to ordinal pairs efficiently. Implemented as an array of int pairs that avoids boxing.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new SegmentRowIdOrdinalPairs with the given capacity.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(int segmentRowId, int ordinal)
    Add a pair to the array.
    void
    Calls the consumer for each right value in each pair of the array.
    int
    getOrdinal(int index)
    Get the ordinal at the given index.
    int
    getSegmentRowId(int index)
    Get the row id at the given index.
    io.github.jbellis.jvector.graph.NeighborQueue
    mapToIndexScoreIterator(io.github.jbellis.jvector.graph.NeighborSimilarity.ScoreFunction scoreFunction)
    Create an iterator over the index and scored ordinal pairs in the array.
    io.github.jbellis.jvector.graph.NeighborQueue
    mapToSegmentRowIdScoreHeap(io.github.jbellis.jvector.graph.NeighborSimilarity.ScoreFunction scoreFunction)
    Create an iterator over the segment row id and scored ordinal pairs in the array.
    int
    The number of pairs in the array.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SegmentRowIdOrdinalPairs

      public SegmentRowIdOrdinalPairs(int capacity)
      Create a new SegmentRowIdOrdinalPairs with the given capacity.
      Parameters:
      capacity - the capacity
  • Method Details

    • add

      public void add(int segmentRowId, int ordinal)
      Add a pair to the array.
      Parameters:
      segmentRowId - the first value
      ordinal - the second value
    • getSegmentRowId

      public int getSegmentRowId(int index)
      Get the row id at the given index.
      Parameters:
      index - the index
      Returns:
      the row id
    • getOrdinal

      public int getOrdinal(int index)
      Get the ordinal at the given index.
      Parameters:
      index - the index
      Returns:
      the ordinal
    • size

      public int size()
      The number of pairs in the array.
      Returns:
      the number of pairs in the array
    • mapToSegmentRowIdScoreHeap

      public io.github.jbellis.jvector.graph.NeighborQueue mapToSegmentRowIdScoreHeap(io.github.jbellis.jvector.graph.NeighborSimilarity.ScoreFunction scoreFunction)
      Create an iterator over the segment row id and scored ordinal pairs in the array.
      Parameters:
      scoreFunction - the score function to use to compute the next score based on the ordinal
      Returns:
      a NeighborQueue
    • mapToIndexScoreIterator

      public io.github.jbellis.jvector.graph.NeighborQueue mapToIndexScoreIterator(io.github.jbellis.jvector.graph.NeighborSimilarity.ScoreFunction scoreFunction)
      Create an iterator over the index and scored ordinal pairs in the array.
      Parameters:
      scoreFunction - the score function to use to compute the next score based on the ordinal
    • forEachOrdinal

      public void forEachOrdinal(IntConsumer consumer)
      Calls the consumer for each right value in each pair of the array.
      Parameters:
      consumer - the consumer to call for each right value