Class ReadOptions
- All Implemented Interfaces:
AutoCloseable
Note that dispose() must be called before an Options instance become out-of-scope to release the allocated memory in c++.
-
Field Summary
Fields inherited from class org.rocksdb.RocksObject
nativeHandle_Fields inherited from class org.rocksdb.AbstractImmutableNativeReference
owningHandle_ -
Constructor Summary
ConstructorsConstructorDescriptionReadOptions(boolean verifyChecksums, boolean fillCache) ReadOptions(ReadOptions other) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanasyncIo()If async_io is enabled, RocksDB will prefetch some of data asynchronously.booleanWhen true, by default use total_order_seek = true, and RocksDB can selectively enable prefix seek mode if won't generate a different result from total_order_seek, based on seek key, and iterator upper bound.booleanIf true, when PurgeObsoleteFile is called in CleanupIteratorState, we schedule a background job in the flush job queue and delete obsolete files in background.longdeadline()Deadline for completing an API call (Get/MultiGet/Seek/Next for now) in microseconds.protected final voiddisposeInternal(long handle) booleanFill the cache when loading the block-based sst formated db.booleanIf true, keys deleted using the DeleteRange() API will be visible to readers until they are naturally deleted during compaction.longA timeout in microseconds to be passed to the underlying FileSystem for reads.Returns the smallest key at which the backward iterator can return an entry.Returns the largest key at which the forward iterator can return an entry.Timestamp of operation.booleanmanaged()Deprecated.This options is not used anymore.longA threshold for the number of keys that can be skipped before failing an iterator seek as incomplete.booleanpinData()Returns whether the blocks loaded by the iterator will be pinned in memorybooleanReturns whether the iterator only iterates over the same prefix as the seeklongIf non-zero, NewIterator will create a new table reader which performs reads of the given size.readTier()Returns the current read tier.setAsyncIo(boolean asyncIo) If async_io is enabled, RocksDB will prefetch some of data asynchronously.setAutoPrefixMode(boolean mode) When true, by default use total_order_seek = true, and RocksDB can selectively enable prefix seek mode if won't generate a different result from total_order_seek, based on seek key, and iterator upper bound.setBackgroundPurgeOnIteratorCleanup(boolean backgroundPurgeOnIteratorCleanup) If true, when PurgeObsoleteFile is called in CleanupIteratorState, we schedule a background job in the flush job queue and delete obsolete files in background.setDeadline(long deadlineTime) Deadline for completing an API call (Get/MultiGet/Seek/Next for now) in microseconds.setFillCache(boolean fillCache) Fill the cache when loading the block-based sst formatted db.setIgnoreRangeDeletions(boolean ignoreRangeDeletions) If true, keys deleted using the DeleteRange() API will be visible to readers until they are naturally deleted during compaction.setIoTimeout(long ioTimeout) A timeout in microseconds to be passed to the underlying FileSystem for reads.setIterateLowerBound(AbstractSlice<?> iterateLowerBound) Defines the smallest key at which the backward iterator can return an entry.setIterateUpperBound(AbstractSlice<?> iterateUpperBound) Defines the extent up to which the forward iterator can return entries.setIterStartTs(AbstractSlice<?> iterStartTs) Timestamp of operation.setManaged(boolean managed) Deprecated.This options is not used anymore.setMaxSkippableInternalKeys(long maxSkippableInternalKeys) A threshold for the number of keys that can be skipped before failing an iterator seek as incomplete.setPinData(boolean pinData) Keep the blocks loaded by the iterator pinned in memory as long as the iterator is not deleted, If used when reading from tables created with BlockBasedTableOptions::use_delta_encoding = false, Iterator's property "rocksdb.iterator.is-key-pinned" is guaranteed to return 1.setPrefixSameAsStart(boolean prefixSameAsStart) Enforce that the iterator only iterates over the same prefix as the seek.setReadaheadSize(long readaheadSize) If non-zero, NewIterator will create a new table reader which performs reads of the given size.setReadTier(ReadTier readTier) Specify if this read request should process data that ALREADY resides on a particular cache.setSnapshot(Snapshot snapshot) If "snapshot" is non-nullptr, read as of the supplied snapshot (which must belong to the DB that is being read and which must not have been released).setTableFilter(AbstractTableFilter tableFilter) A callback to determine whether relevant keys for this scan exist in a given table based on the table's properties.setTailing(boolean tailing) Specify to create a tailing iterator -- a special iterator that has a view of the complete database (i.e.setTimestamp(AbstractSlice<?> timestamp) Timestamp of operation.setTotalOrderSeek(boolean totalOrderSeek) Enable a total order seek regardless of index format (e.g.setValueSizeSoftLimit(long valueSizeSoftLimit) It limits the maximum cumulative value size of the keys in batch while reading through MultiGet.setVerifyChecksums(boolean verifyChecksums) If true, all data read from underlying storage will be verified against corresponding checksums.snapshot()Returns the currently assigned Snapshot instance.booleantailing()Specify to create a tailing iterator -- a special iterator that has a view of the complete database (i.e.Timestamp of operation.booleanReturns whether a total seek order will be usedlongIt limits the maximum cumulative value size of the keys in batch while reading through MultiGet.booleanIf true, all data read from underlying storage will be verified against corresponding checksums.Methods inherited from class org.rocksdb.RocksObject
disposeInternal, getNativeHandleMethods inherited from class org.rocksdb.AbstractImmutableNativeReference
close, disOwnNativeHandle, isOwningHandle
-
Constructor Details
-
ReadOptions
public ReadOptions() -
ReadOptions
public ReadOptions(boolean verifyChecksums, boolean fillCache) - Parameters:
verifyChecksums- verification will be performed on every read when set to truefillCache- if true, then fill-cache behavior will be performed.
-
ReadOptions
Copy constructor.NOTE: This does a shallow copy, which means snapshot, iterate_upper_bound and other pointers will be cloned!
- Parameters:
other- The ReadOptions to copy.
-
-
Method Details
-
verifyChecksums
public boolean verifyChecksums()If true, all data read from underlying storage will be verified against corresponding checksums. Default: true- Returns:
- true if checksum verification is on.
-
setVerifyChecksums
If true, all data read from underlying storage will be verified against corresponding checksums. Default: true- Parameters:
verifyChecksums- if true, then checksum verification will be performed on every read.- Returns:
- the reference to the current ReadOptions.
-
fillCache
public boolean fillCache()Fill the cache when loading the block-based sst formated db. Callers may wish to set this field to false for bulk scans. Default: true- Returns:
- true if the fill-cache behavior is on.
-
setFillCache
Fill the cache when loading the block-based sst formatted db. Callers may wish to set this field to false for bulk scans. Default: true- Parameters:
fillCache- if true, then fill-cache behavior will be performed.- Returns:
- the reference to the current ReadOptions.
-
snapshot
Returns the currently assigned Snapshot instance.- Returns:
- the Snapshot assigned to this instance. If no Snapshot is assigned null.
-
setSnapshot
If "snapshot" is non-nullptr, read as of the supplied snapshot (which must belong to the DB that is being read and which must not have been released). If "snapshot" is nullptr, use an implicit snapshot of the state at the beginning of this read operation.
Default: null
- Parameters:
snapshot-Snapshotinstance- Returns:
- the reference to the current ReadOptions.
-
readTier
Returns the current read tier.- Returns:
- the read tier in use, by default
ReadTier.READ_ALL_TIER
-
setReadTier
Specify if this read request should process data that ALREADY resides on a particular cache. If the required data is not found at the specified cache, thenRocksDBExceptionis thrown.- Parameters:
readTier-ReadTierinstance- Returns:
- the reference to the current ReadOptions.
-
tailing
public boolean tailing()Specify to create a tailing iterator -- a special iterator that has a view of the complete database (i.e. it can also be used to read newly added data) and is optimized for sequential reads. It will return records that were inserted into the database after the creation of the iterator. Default: false- Returns:
- true if tailing iterator is enabled.
-
setTailing
Specify to create a tailing iterator -- a special iterator that has a view of the complete database (i.e. it can also be used to read newly added data) and is optimized for sequential reads. It will return records that were inserted into the database after the creation of the iterator. Default: false- Parameters:
tailing- if true, then tailing iterator will be enabled.- Returns:
- the reference to the current ReadOptions.
-
managed
Deprecated.This options is not used anymore.Returns whether managed iterators will be used.- Returns:
- the setting of whether managed iterators will be used, by default false
-
setManaged
Deprecated.This options is not used anymore.Specify to create a managed iterator -- a special iterator that uses less resources by having the ability to free its underlying resources on request.- Parameters:
managed- if true, then managed iterators will be enabled.- Returns:
- the reference to the current ReadOptions.
-
totalOrderSeek
public boolean totalOrderSeek()Returns whether a total seek order will be used- Returns:
- the setting of whether a total seek order will be used
-
setTotalOrderSeek
Enable a total order seek regardless of index format (e.g. hash index) used in the table. Some table format (e.g. plain table) may not support this option.- Parameters:
totalOrderSeek- if true, then total order seek will be enabled.- Returns:
- the reference to the current ReadOptions.
-
prefixSameAsStart
public boolean prefixSameAsStart()Returns whether the iterator only iterates over the same prefix as the seek- Returns:
- the setting of whether the iterator only iterates over the same prefix as the seek, default is false
-
setPrefixSameAsStart
Enforce that the iterator only iterates over the same prefix as the seek. This option is effective only for prefix seeks, i.e. prefix_extractor is non-null for the column family andtotalOrderSeek()is false. Unlike iterate_upper_bound,#setPrefixSameAsStart(boolean)only works within a prefix but in both directions.- Parameters:
prefixSameAsStart- if true, then the iterator only iterates over the same prefix as the seek- Returns:
- the reference to the current ReadOptions.
-
pinData
public boolean pinData()Returns whether the blocks loaded by the iterator will be pinned in memory- Returns:
- the setting of whether the blocks loaded by the iterator will be pinned in memory
-
setPinData
Keep the blocks loaded by the iterator pinned in memory as long as the iterator is not deleted, If used when reading from tables created with BlockBasedTableOptions::use_delta_encoding = false, Iterator's property "rocksdb.iterator.is-key-pinned" is guaranteed to return 1.- Parameters:
pinData- if true, the blocks loaded by the iterator will be pinned- Returns:
- the reference to the current ReadOptions.
-
backgroundPurgeOnIteratorCleanup
public boolean backgroundPurgeOnIteratorCleanup()If true, when PurgeObsoleteFile is called in CleanupIteratorState, we schedule a background job in the flush job queue and delete obsolete files in background.Default: false
- Returns:
- true when PurgeObsoleteFile is called in CleanupIteratorState
-
setBackgroundPurgeOnIteratorCleanup
If true, when PurgeObsoleteFile is called in CleanupIteratorState, we schedule a background job in the flush job queue and delete obsolete files in background.Default: false
- Parameters:
backgroundPurgeOnIteratorCleanup- true when PurgeObsoleteFile is called in CleanupIteratorState- Returns:
- the reference to the current ReadOptions.
-
readaheadSize
public long readaheadSize()If non-zero, NewIterator will create a new table reader which performs reads of the given size. Using a large size (> 2MB) can improve the performance of forward iteration on spinning disks.Default: 0
- Returns:
- The readahead size is bytes
-
setReadaheadSize
If non-zero, NewIterator will create a new table reader which performs reads of the given size. Using a large size (> 2MB) can improve the performance of forward iteration on spinning disks.Default: 0
- Parameters:
readaheadSize- The readahead size is bytes- Returns:
- the reference to the current ReadOptions.
-
maxSkippableInternalKeys
public long maxSkippableInternalKeys()A threshold for the number of keys that can be skipped before failing an iterator seek as incomplete.- Returns:
- the number of keys that can be skipped before failing an iterator seek as incomplete.
-
setMaxSkippableInternalKeys
A threshold for the number of keys that can be skipped before failing an iterator seek as incomplete. The default value of 0 should be used to never fail a request as incomplete, even on skipping too many keys.Default: 0
- Parameters:
maxSkippableInternalKeys- the number of keys that can be skipped before failing an iterator seek as incomplete.- Returns:
- the reference to the current ReadOptions.
-
ignoreRangeDeletions
public boolean ignoreRangeDeletions()If true, keys deleted using the DeleteRange() API will be visible to readers until they are naturally deleted during compaction. This improves read performance in DBs with many range deletions.Default: false
- Returns:
- true if keys deleted using the DeleteRange() API will be visible
-
setIgnoreRangeDeletions
If true, keys deleted using the DeleteRange() API will be visible to readers until they are naturally deleted during compaction. This improves read performance in DBs with many range deletions.Default: false
- Parameters:
ignoreRangeDeletions- true if keys deleted using the DeleteRange() API should be visible- Returns:
- the reference to the current ReadOptions.
-
setIterateLowerBound
Defines the smallest key at which the backward iterator can return an entry. Once the bound is passed,AbstractRocksIterator.isValid()will be false.The lower bound is inclusive i.e. the bound value is a valid entry.
If prefix_extractor is not null, the Seek target and `iterate_lower_bound` need to have the same prefix. This is because ordering is not guaranteed outside of prefix domain.
Default: null
- Parameters:
iterateLowerBound- Slice representing the lower bound- Returns:
- the reference to the current ReadOptions.
-
iterateLowerBound
Returns the smallest key at which the backward iterator can return an entry.The lower bound is inclusive i.e. the bound value is a valid entry.
- Returns:
- the smallest key, or null if there is no lower bound defined.
-
setIterateUpperBound
Defines the extent up to which the forward iterator can return entries. Once the bound is reached,AbstractRocksIterator.isValid()will be false.The upper bound is exclusive i.e. the bound value is not a valid entry.
If prefix_extractor is not null, the Seek target and iterate_upper_bound need to have the same prefix. This is because ordering is not guaranteed outside of prefix domain.
Default: null
- Parameters:
iterateUpperBound- Slice representing the upper bound- Returns:
- the reference to the current ReadOptions.
-
iterateUpperBound
Returns the largest key at which the forward iterator can return an entry.The upper bound is exclusive i.e. the bound value is not a valid entry.
- Returns:
- the largest key, or null if there is no upper bound defined.
-
setTableFilter
A callback to determine whether relevant keys for this scan exist in a given table based on the table's properties. The callback is passed the properties of each table during iteration. If the callback returns false, the table will not be scanned. This option only affects Iterators and has no impact on point lookups.Default: null (every table will be scanned)
- Parameters:
tableFilter- the table filter for the callback.- Returns:
- the reference to the current ReadOptions.
-
autoPrefixMode
public boolean autoPrefixMode()When true, by default use total_order_seek = true, and RocksDB can selectively enable prefix seek mode if won't generate a different result from total_order_seek, based on seek key, and iterator upper bound. Default: false- Returns:
- true if auto prefix mode is set.
-
setAutoPrefixMode
When true, by default use total_order_seek = true, and RocksDB can selectively enable prefix seek mode if won't generate a different result from total_order_seek, based on seek key, and iterator upper bound. Default: false- Parameters:
mode- auto prefix mode- Returns:
- the reference to the current ReadOptions.
-
timestamp
Timestamp of operation. Read should return the latest data visible to the specified timestamp. All timestamps of the same database must be of the same length and format. The user is responsible for providing a customized compare function via Comparator to order >key, timestamp> tuples. For iterator, iter_start_ts is the lower bound (older) and timestamp serves as the upper bound. Versions of the same record that fall in the timestamp range will be returned. If iter_start_ts is nullptr, only the most recent version visible to timestamp is returned. The user-specified timestamp feature is still under active development, and the API is subject to change.Default: null
- Returns:
- Reference to timestamp or null if there is no timestamp defined.
- See Also:
-
setTimestamp
Timestamp of operation. Read should return the latest data visible to the specified timestamp. All timestamps of the same database must be of the same length and format. The user is responsible for providing a customized compare function via Comparator to order<key, timestamp>tuples. For iterator,iter_start_tsis the lower bound (older) and timestamp serves as the upper bound. Versions of the same record that fall in the timestamp range will be returned. If iter_start_ts is nullptr, only the most recent version visible to timestamp is returned. The user-specified timestamp feature is still under active development, and the API is subject to change.Default: null
- Parameters:
timestamp- Slice representing the timestamp- Returns:
- the reference to the current ReadOptions.
- See Also:
-
iterStartTs
Timestamp of operation. Read should return the latest data visible to the specified timestamp. All timestamps of the same database must be of the same length and format. The user is responsible for providing a customized compare function via Comparator to order<key, timestamp>tuples. For iterator,iter_start_tsis the lower bound (older) and timestamp serves as the upper bound. Versions of the same record that fall in the timestamp range will be returned. If iter_start_ts is nullptr, only the most recent version visible to timestamp is returned. The user-specified timestamp feature is still under active development, and the API is subject to change.Default: null
- Returns:
- Reference to lower bound timestamp or null if there is no lower bound timestamp defined.
-
setIterStartTs
Timestamp of operation. Read should return the latest data visible to the specified timestamp. All timestamps of the same database must be of the same length and format. The user is responsible for providing a customized compare function via Comparator to order<key, timestamp>tuples. For iterator,iter_start_tsis the lower bound (older) and timestamp serves as the upper bound. Versions of the same record that fall in the timestamp range will be returned. If iter_start_ts is nullptr, only the most recent version visible to timestamp is returned. The user-specified timestamp feature is still under active development, and the API is subject to change.Default: null
- Parameters:
iterStartTs- Reference to lower bound timestamp or null if there is no lower bound timestamp defined- Returns:
- the reference to the current ReadOptions.
-
deadline
public long deadline()Deadline for completing an API call (Get/MultiGet/Seek/Next for now) in microseconds. It should be set to microseconds since epoch, i.e,gettimeofdayor equivalent plus allowed duration in microseconds. The best way is to useenv->NowMicros() + some timeout. This is best efforts. The call may exceed the deadline if there is IO involved and the file system doesn't support deadlines, or due to checking for deadline periodically rather than for every key if processing a batch- Returns:
- deadline time in microseconds
-
setDeadline
Deadline for completing an API call (Get/MultiGet/Seek/Next for now) in microseconds. It should be set to microseconds since epoch, i.e,gettimeofdayor equivalent plus allowed duration in microseconds. The best way is to useenv->NowMicros() + some timeout. This is best efforts. The call may exceed the deadline if there is IO involved and the file system doesn't support deadlines, or due to checking for deadline periodically rather than for every key if processing a batch- Parameters:
deadlineTime- deadline time in microseconds.- Returns:
- the reference to the current ReadOptions.
-
ioTimeout
public long ioTimeout()A timeout in microseconds to be passed to the underlying FileSystem for reads. As opposed to deadline, this determines the timeout for each individual file read request. If a MultiGet/Get/Seek/Next etc call results in multiple reads, each read can last up to io_timeout us.- Returns:
- ioTimeout time in microseconds
-
setIoTimeout
A timeout in microseconds to be passed to the underlying FileSystem for reads. As opposed to deadline, this determines the timeout for each individual file read request. If a MultiGet/Get/Seek/Next etc call results in multiple reads, each read can last up to io_timeout us.- Parameters:
ioTimeout- time in microseconds.- Returns:
- the reference to the current ReadOptions.
-
valueSizeSoftLimit
public long valueSizeSoftLimit()It limits the maximum cumulative value size of the keys in batch while reading through MultiGet. Once the cumulative value size exceeds this soft limit then all the remaining keys are returned with status Aborted.Default:
std::numeric_limits<uint64_t>::max()- Returns:
- actual valueSizeSofLimit
-
setValueSizeSoftLimit
It limits the maximum cumulative value size of the keys in batch while reading through MultiGet. Once the cumulative value size exceeds this soft limit then all the remaining keys are returned with status Aborted.Default:
std::numeric_limits<uint64_t>::max()- Parameters:
valueSizeSoftLimit- the maximum cumulative value size of the keys- Returns:
- the reference to the current ReadOptions
-
asyncIo
If async_io is enabled, RocksDB will prefetch some of data asynchronously. RocksDB apply it if reads are sequential and its internal automatic prefetching.Default: false
- Returns:
- true if async_io is enabled.
-
setAsyncIo
@Experimental("Caution: this option is experimental") public ReadOptions setAsyncIo(boolean asyncIo) If async_io is enabled, RocksDB will prefetch some of data asynchronously. RocksDB apply it if reads are sequential and its internal automatic prefetching.- Parameters:
asyncIo- async_io enabled or not.- Returns:
- the reference to the current ReadOptions.
-
disposeInternal
protected final void disposeInternal(long handle) - Specified by:
disposeInternalin classRocksObject
-