Interface RocksIteratorInterface
- All Known Implementing Classes:
AbstractRocksIterator,RocksIterator,SstFileReaderIterator,WBWIRocksIterator
Defines the interface for an Iterator which provides access to data one entry at a time. Multiple implementations are provided by this library. In particular, iterators are provided to access the contents of a DB and Write Batch.
Multiple threads can invoke const methods on an RocksIterator without external synchronization, but if any of the threads may call a non-const method, all threads accessing the same RocksIterator must use external synchronization.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanisValid()An iterator is either positioned at an entry, or not valid.voidnext()Moves to the next entry in the source.voidprev()Moves to the previous entry in the source.voidrefresh()If supported, the DB state that the iterator reads from is updated to the latest state.voidSimilar torefresh()but the iterator will be reading the latest DB state under the given snapshot.voidseek(byte[] target) Position at the first entry in the source whose key is at or past target.voidseek(ByteBuffer target) Position at the first entry in the source whose key is that or past target.voidseekForPrev(byte[] target) Position at the first entry in the source whose key is that or before target.voidseekForPrev(ByteBuffer target) Position at the last key that is less than or equal to the target key.voidPosition at the first entry in the source.voidPosition at the last entry in the source.voidstatus()If an error has occurred, return it.
-
Method Details
-
isValid
boolean isValid()An iterator is either positioned at an entry, or not valid. This method returns true if the iterator is valid.
- Returns:
- true if iterator is valid.
-
seekToFirst
void seekToFirst()Position at the first entry in the source. The iterator is Valid() after this call if the source is not empty.
-
seekToLast
void seekToLast()Position at the last entry in the source. The iterator is valid after this call if the source is not empty.
-
seek
void seek(byte[] target) Position at the first entry in the source whose key is at or past target.
The iterator is valid after this call if the source contains a key that comes at or past target.
- Parameters:
target- byte array describing a key or a key prefix to seek for.
-
seekForPrev
void seekForPrev(byte[] target) Position at the first entry in the source whose key is that or before target.
The iterator is valid after this call if the source contains a key that comes at or before target.
- Parameters:
target- byte array describing a key or a key prefix to seek for.
-
seek
Position at the first entry in the source whose key is that or past target.
The iterator is valid after this call if the source contains a key that comes at or past target.
- Parameters:
target- byte array describing a key or a key prefix to seek for. Supports direct buffer only.
-
seekForPrev
Position at the last key that is less than or equal to the target key.
The iterator is valid after this call if the source contains a key that comes at or past target.
- Parameters:
target- byte array describing a key or a key prefix to seek for. Supports direct buffer only.
-
next
void next()Moves to the next entry in the source. After this call, Valid() is true if the iterator was not positioned at the last entry in the source.
REQUIRES:
isValid() -
prev
void prev()Moves to the previous entry in the source. After this call, Valid() is true if the iterator was not positioned at the first entry in source.
REQUIRES:
isValid() -
status
If an error has occurred, return it. Else return an ok status. If non-blocking IO is requested and this operation cannot be satisfied without doing some IO, then this returns Status::Incomplete().
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
refresh
If supported, the DB state that the iterator reads from is updated to the latest state. The iterator will be invalidated after the call. Regardless of whether the iterator was created/refreshed previously with or without a snapshot, the iterator will be reading the latest DB state after this call.
Note that you will need to call a Seek*() function to get the iterator back into a valid state before calling a function that assumes the state is already valid, like Next().
- Throws:
RocksDBException- thrown if the operation is not supported or an error happens in the underlying native library
-
refresh
Similar torefresh()but the iterator will be reading the latest DB state under the given snapshot.- Throws:
RocksDBException
-