P - The type of the Parent Object from which the Rocks Iterator was
created. This is used by disposeInternal to avoid double-free
issues with the underlying C++ object.public abstract class AbstractRocksIterator<P extends RocksObject> extends RocksObject implements RocksIteratorInterface
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.
RocksObjectnativeHandle_owningHandle_| Modifier | Constructor and Description |
|---|---|
protected |
AbstractRocksIterator(P parent,
long nativeHandle) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
disposeInternal()
Deletes underlying C++ iterator pointer.
|
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, the DB state that the iterator reads from is updated to
the latest state.
|
void |
refresh(Snapshot snapshot)
Similar to
RocksIteratorInterface.refresh() but the iterator will be reading the latest DB state under the
given snapshot. |
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.
|
disposeInternal, getNativeHandleclose, disOwnNativeHandle, isOwningHandleprotected AbstractRocksIterator(P parent, long nativeHandle)
public boolean isValid()
RocksIteratorInterfaceAn iterator is either positioned at an entry, or not valid. This method returns true if the iterator is valid.
isValid in interface RocksIteratorInterfacepublic void seekToFirst()
RocksIteratorInterfacePosition at the first entry in the source. The iterator is Valid() after this call if the source is not empty.
seekToFirst in interface RocksIteratorInterfacepublic void seekToLast()
RocksIteratorInterfacePosition at the last entry in the source. The iterator is valid after this call if the source is not empty.
seekToLast in interface RocksIteratorInterfacepublic void seek(byte[] target)
RocksIteratorInterfacePosition 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.
seek in interface RocksIteratorInterfacetarget - byte array describing a key or a
key prefix to seek for.public void seekForPrev(byte[] target)
RocksIteratorInterfacePosition 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.
seekForPrev in interface RocksIteratorInterfacetarget - byte array describing a key or a
key prefix to seek for.public void seek(java.nio.ByteBuffer target)
RocksIteratorInterfacePosition 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.
seek in interface RocksIteratorInterfacetarget - byte array describing a key or a
key prefix to seek for. Supports direct buffer only.public void seekForPrev(java.nio.ByteBuffer target)
RocksIteratorInterfacePosition 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.
seekForPrev in interface RocksIteratorInterfacetarget - byte array describing a key or a
key prefix to seek for. Supports direct buffer only.public void next()
RocksIteratorInterfaceMoves 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: RocksIteratorInterface.isValid()
next in interface RocksIteratorInterfacepublic void prev()
RocksIteratorInterfaceMoves 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: RocksIteratorInterface.isValid()
prev in interface RocksIteratorInterfacepublic void refresh()
throws RocksDBException
RocksIteratorInterfaceIf 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().
refresh in interface RocksIteratorInterfaceRocksDBException - thrown if the operation is not supported or an error happens in the
underlying native librarypublic void refresh(Snapshot snapshot) throws RocksDBException
RocksIteratorInterfaceRocksIteratorInterface.refresh() but the iterator will be reading the latest DB state under the
given snapshot.refresh in interface RocksIteratorInterfaceRocksDBExceptionpublic void status()
throws RocksDBException
RocksIteratorInterfaceIf 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().
status in interface RocksIteratorInterfaceRocksDBException - thrown if error happens in underlying
native library.protected void disposeInternal()
Deletes underlying C++ iterator pointer.
Note: the underlying handle can only be safely deleted if the parent
instance related to a certain RocksIterator is still valid and initialized.
Therefore disposeInternal() checks if the parent is initialized
before freeing the native handle.
disposeInternal in class RocksObject