Class AbstractRocksIterator<P extends RocksObject>
- Type Parameters:
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.
- All Implemented Interfaces:
AutoCloseable,RocksIteratorInterface
- Direct Known Subclasses:
RocksIterator,SstFileReaderIterator,WBWIRocksIterator
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:
-
Field Summary
Fields inherited from class org.rocksdb.RocksObject
nativeHandle_Fields inherited from class org.rocksdb.AbstractImmutableNativeReference
owningHandle_ -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidDeletes underlying C++ iterator pointer.booleanisValid()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 toRocksIteratorInterface.refresh()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.Methods inherited from class org.rocksdb.RocksObject
disposeInternal, getNativeHandleMethods inherited from class org.rocksdb.AbstractImmutableNativeReference
close, disOwnNativeHandle, isOwningHandle
-
Constructor Details
-
AbstractRocksIterator
-
-
Method Details
-
isValid
public boolean isValid()Description copied from interface:RocksIteratorInterfaceAn iterator is either positioned at an entry, or not valid. This method returns true if the iterator is valid.
- Specified by:
isValidin interfaceRocksIteratorInterface- Returns:
- true if iterator is valid.
-
seekToFirst
public void seekToFirst()Description copied from interface:RocksIteratorInterfacePosition at the first entry in the source. The iterator is Valid() after this call if the source is not empty.
- Specified by:
seekToFirstin interfaceRocksIteratorInterface
-
seekToLast
public void seekToLast()Description copied from interface:RocksIteratorInterfacePosition at the last entry in the source. The iterator is valid after this call if the source is not empty.
- Specified by:
seekToLastin interfaceRocksIteratorInterface
-
seek
public void seek(byte[] target) Description copied from interface: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.
- Specified by:
seekin interfaceRocksIteratorInterface- Parameters:
target- byte array describing a key or a key prefix to seek for.
-
seekForPrev
public void seekForPrev(byte[] target) Description copied from interface: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.
- Specified by:
seekForPrevin interfaceRocksIteratorInterface- Parameters:
target- byte array describing a key or a key prefix to seek for.
-
seek
Description copied from interface: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.
- Specified by:
seekin interfaceRocksIteratorInterface- Parameters:
target- byte array describing a key or a key prefix to seek for. Supports direct buffer only.
-
seekForPrev
Description copied from interface: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.
- Specified by:
seekForPrevin interfaceRocksIteratorInterface- Parameters:
target- byte array describing a key or a key prefix to seek for. Supports direct buffer only.
-
next
public void next()Description copied from interface: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()- Specified by:
nextin interfaceRocksIteratorInterface
-
prev
public void prev()Description copied from interface: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()- Specified by:
previn interfaceRocksIteratorInterface
-
refresh
Description copied from interface: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().
- Specified by:
refreshin interfaceRocksIteratorInterface- Throws:
RocksDBException- thrown if the operation is not supported or an error happens in the underlying native library
-
refresh
Description copied from interface:RocksIteratorInterfaceSimilar toRocksIteratorInterface.refresh()but the iterator will be reading the latest DB state under the given snapshot.- Specified by:
refreshin interfaceRocksIteratorInterface- Throws:
RocksDBException
-
status
Description copied from interface: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().
- Specified by:
statusin interfaceRocksIteratorInterface- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
disposeInternal
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.- Overrides:
disposeInternalin classRocksObject
-