Class KeyLookup.Cursor
java.lang.Object
org.apache.cassandra.index.sai.disk.v1.keystore.KeyLookup.Cursor
- All Implemented Interfaces:
AutoCloseable
- Enclosing class:
- KeyLookup
Allows reading the keys from the keys file.
Can quickly seek to a random key by point id.
This object is stateful and not thread safe. It maintains a position to the current key as well as a buffer that can hold one key.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()longclusteredSeekToKey(ByteComparable key, long startingPointId, long endingPointId) Finds the pointId for a clustering key within a range of pointIds.voidreset()seekToPointId(long pointId) Positions the cursor on the target point id and reads the key at the target to the current key buffer.
-
Method Details
-
seekToPointId
Positions the cursor on the target point id and reads the key at the target to the current key buffer.It is allowed to position the cursor before the first item or after the last item; in these cases the internal buffer is cleared.
- Parameters:
pointId- point id to lookup- Returns:
- The
ByteSourcecontaining the key - Throws:
IndexOutOfBoundsException- if the target point id is less than -1 or greater than the number of keys
-
clusteredSeekToKey
Finds the pointId for a clustering key within a range of pointIds. The start and end of the range must not exceed the number of keys available. The keys within the range are expected to be in lexographical order.If the key is not in the block containing the start of the range a binary search is done to find the block containing the search key. That block is then searched to return the pointId that corresponds to the key that is either equal to or next highest to the search key.
- Parameters:
key- The key to seek for with the partitionstartingPointId- the inclusive starting point for the partitionendingPointId- the exclusive ending point for the partition. Note: this can be equal to the number of keys if this is the last partition- Returns:
- a
longrepresenting the pointId of the key that is >= to the key passed to the method, or -1 if the key passed is > all the keys.
-
reset
- Throws:
IOException
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-