Class SegmentRowIdOrdinalPairs
java.lang.Object
org.apache.cassandra.index.sai.disk.v1.vector.SegmentRowIdOrdinalPairs
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
ConstructorsConstructorDescriptionSegmentRowIdOrdinalPairs(int capacity) Create a new SegmentRowIdOrdinalPairs with the given capacity. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(int segmentRowId, int ordinal) Add a pair to the array.voidforEachOrdinal(IntConsumer consumer) Calls the consumer for each right value in each pair of the array.intgetOrdinal(int index) Get the ordinal at the given index.intgetSegmentRowId(int index) Get the row id at the given index.io.github.jbellis.jvector.graph.NeighborQueuemapToIndexScoreIterator(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.NeighborQueuemapToSegmentRowIdScoreHeap(io.github.jbellis.jvector.graph.NeighborSimilarity.ScoreFunction scoreFunction) Create an iterator over the segment row id and scored ordinal pairs in the array.intsize()The number of pairs in the array.
-
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 valueordinal- 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
Calls the consumer for each right value in each pair of the array.- Parameters:
consumer- the consumer to call for each right value
-