public interface RocksIteratorInterface
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.
RocksObject
Modifier and Type | Method and Description |
---|---|
boolean |
isValid()
An iterator is either positioned at an entry, or
not valid.
|
void |
next()
Moves to the next entry in the source.
|
void |
prev()
Moves to the previous entry in the source.
|
void |
refresh()
If supported, renew the iterator to represent the latest state.
|
void |
seek(byte[] target)
Position at the first entry in the source whose key is at or
past target.
|
void |
seek(java.nio.ByteBuffer target)
Position at the first entry in the source whose key is that or
past target.
|
void |
seekForPrev(byte[] target)
Position at the first entry in the source whose key is that or
before target.
|
void |
seekForPrev(java.nio.ByteBuffer target)
Position at the last key that is less than or equal to the target key.
|
void |
seekToFirst()
Position at the first entry in the source.
|
void |
seekToLast()
Position at the last entry in the source.
|
void |
status()
If an error has occurred, return it.
|
boolean isValid()
An iterator is either positioned at an entry, or not valid. This method returns true if the iterator is valid.
void seekToFirst()
Position at the first entry in the source. The iterator is Valid() after this call if the source is not empty.
void seekToLast()
Position at the last entry in the source. The iterator is valid after this call if the source is not empty.
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.
target
- byte array describing a key or a
key prefix to seek for.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.
target
- byte array describing a key or a
key prefix to seek for.void seek(java.nio.ByteBuffer target)
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.
target
- byte array describing a key or a
key prefix to seek for. Supports direct buffer only.void seekForPrev(java.nio.ByteBuffer target)
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.
target
- byte array describing a key or a
key prefix to seek for. Supports direct buffer only.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()
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()
void status() throws RocksDBException
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().
RocksDBException
- thrown if error happens in underlying
native library.void refresh() throws RocksDBException
If supported, renew the iterator to represent the latest state. The iterator will be
invalidated after the call. Not supported if ReadOptions.setSnapshot(Snapshot)
was
specified when creating the iterator.
RocksDBException
- thrown if the operation is not supported or an error happens in the
underlying native library