Class SkinnyPrimaryKeyMap
- java.lang.Object
-
- org.apache.cassandra.index.sai.disk.v1.SkinnyPrimaryKeyMap
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,PrimaryKeyMap
- Direct Known Subclasses:
WidePrimaryKeyMap
@NotThreadSafe public class SkinnyPrimaryKeyMap extends java.lang.Object implements PrimaryKeyMap
APrimaryKeyMap
for skinny tables (those with no clustering columns).This uses the following on-disk structures:
- A block-packed structure for rowId to token value lookups using
BlockPackedReader
. Uses theIndexComponent.ROW_TO_TOKEN
component - A monotonic block packed structure for rowId to partitionId lookups using
MonotonicBlockPackedReader
. Uses theIndexComponent.ROW_TO_PARTITION
component - A key store for rowId to
PrimaryKey
andPrimaryKey
to rowId lookups usingKeyLookup
. Uses theIndexComponent.PARTITION_KEY_BLOCKS
andIndexComponent.PARTITION_KEY_BLOCK_OFFSETS
components
SkinnyPrimaryKeyMap.Factory
is threadsafe, individual instances of theSkinnyPrimaryKeyMap
are not.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SkinnyPrimaryKeyMap.Factory
-
Field Summary
Fields Modifier and Type Field Description protected KeyLookup.Cursor
partitionKeyCursor
protected PrimaryKey.Factory
primaryKeyFactory
protected LongArray
rowIdToPartitionIdArray
protected LongArray
rowIdToTokenArray
-
Constructor Summary
Constructors Modifier Constructor Description protected
SkinnyPrimaryKeyMap(LongArray rowIdToTokenArray, LongArray rowIdToPartitionIdArray, KeyLookup.Cursor partitionKeyCursor, PrimaryKey.Factory primaryKeyFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
ceiling(Token token)
void
close()
long
floor(Token token)
PrimaryKey
primaryKeyFromRowId(long sstableRowId)
Returns aPrimaryKey
for a row IDprotected DecoratedKey
readPartitionKey(long sstableRowId)
long
rowIdFromPrimaryKey(PrimaryKey primaryKey)
Returns a row ID for aPrimaryKey
protected long
tokenCollisionDetection(PrimaryKey primaryKey, long rowId)
-
-
-
Field Detail
-
rowIdToTokenArray
protected final LongArray rowIdToTokenArray
-
rowIdToPartitionIdArray
protected final LongArray rowIdToPartitionIdArray
-
partitionKeyCursor
protected final KeyLookup.Cursor partitionKeyCursor
-
primaryKeyFactory
protected final PrimaryKey.Factory primaryKeyFactory
-
-
Constructor Detail
-
SkinnyPrimaryKeyMap
protected SkinnyPrimaryKeyMap(LongArray rowIdToTokenArray, LongArray rowIdToPartitionIdArray, KeyLookup.Cursor partitionKeyCursor, PrimaryKey.Factory primaryKeyFactory)
-
-
Method Detail
-
primaryKeyFromRowId
public PrimaryKey primaryKeyFromRowId(long sstableRowId)
Description copied from interface:PrimaryKeyMap
Returns aPrimaryKey
for a row ID- Specified by:
primaryKeyFromRowId
in interfacePrimaryKeyMap
- Parameters:
sstableRowId
- the row ID to lookup- Returns:
- the
PrimaryKey
associated with the row ID
-
rowIdFromPrimaryKey
public long rowIdFromPrimaryKey(PrimaryKey primaryKey)
Description copied from interface:PrimaryKeyMap
Returns a row ID for aPrimaryKey
- Specified by:
rowIdFromPrimaryKey
in interfacePrimaryKeyMap
- Parameters:
primaryKey
- thePrimaryKey
to lookup- Returns:
- the row ID associated with the
PrimaryKey
-
ceiling
public long ceiling(Token token)
Description copied from interface:PrimaryKeyMap
Returns the first row ID of the nearestToken
greater than or equal to the givenToken
, or a negative value if not found- Specified by:
ceiling
in interfacePrimaryKeyMap
- Parameters:
token
- theToken
to lookup- Returns:
- the ceiling row ID associated with the
Token
or a negative value
-
floor
public long floor(Token token)
Description copied from interface:PrimaryKeyMap
Returns the last row ID of the nearestToken
less than or equal to the givenToken
, or a negative value if theToken
is at its minimum value- Specified by:
floor
in interfacePrimaryKeyMap
- Parameters:
token
- theToken
to lookup- Returns:
- the floor row ID associated with the
Token
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in interfacePrimaryKeyMap
-
tokenCollisionDetection
protected long tokenCollisionDetection(PrimaryKey primaryKey, long rowId)
-
readPartitionKey
protected DecoratedKey readPartitionKey(long sstableRowId)
-
-