Struct rocksdb::ReadOptions

source ·
pub struct ReadOptions { /* private fields */ }

Implementations§

source§

impl ReadOptions

source

pub fn fill_cache(&mut self, v: bool)

Specify whether the “data block”/“index block”/“filter block” read for this iteration should be cached in memory? Callers may wish to set this field to false for bulk scans.

Default: true

source

pub fn set_snapshot<D: DBAccess>( &mut self, snapshot: &SnapshotWithThreadMode<'_, D>, )

Sets the snapshot which should be used for the read. The snapshot must belong to the DB that is being read and must not have been released.

source

pub fn set_iterate_lower_bound<K: Into<Vec<u8>>>(&mut self, key: K)

Sets the lower bound for an iterator.

source

pub fn set_iterate_upper_bound<K: Into<Vec<u8>>>(&mut self, key: K)

Sets the upper bound for an iterator. The upper bound itself is not included on the iteration result.

source

pub fn set_iterate_range(&mut self, range: impl IterateBounds)

Sets lower and upper bounds based on the provided range. This is similar to setting lower and upper bounds separately except that it also allows either bound to be reset.

The argument can be a regular Rust range, e.g. lower..upper. However, since RocksDB upper bound is always excluded (i.e. range can never be fully closed) inclusive ranges (lower..=upper and ..=upper) are not supported. For example:

let mut options = rocksdb::ReadOptions::default();
options.set_iterate_range("xy".as_bytes().."xz".as_bytes());

In addition, crate::PrefixRange can be used to specify a range of keys with a given prefix. In particular, the above example is equivalent to:

let mut options = rocksdb::ReadOptions::default();
options.set_iterate_range(rocksdb::PrefixRange("xy".as_bytes()));

Note that setting range using this method is separate to using prefix iterators. Prefix iterators use prefix extractor configured for a column family. Setting bounds via crate::PrefixRange is more akin to using manual prefix.

Using this method clears any previously set bounds. In other words, the bounds can be reset by setting the range to .. as in:

let mut options = rocksdb::ReadOptions::default();
options.set_iterate_range(..);
source

pub fn set_read_tier(&mut self, tier: ReadTier)

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, then Status::Incomplete is returned.

Default: ::All

source

pub fn set_prefix_same_as_start(&mut self, v: bool)

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 and total_order_seek is false. Unlike iterate_upper_bound, prefix_same_as_start only works within a prefix but in both directions.

Default: false

source

pub fn set_total_order_seek(&mut self, v: bool)

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.

If true when calling Get(), we also skip prefix bloom when reading from block based table. It provides a way to read existing data after changing implementation of prefix extractor.

source

pub fn set_max_skippable_internal_keys(&mut self, num: u64)

Sets 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

source

pub fn set_background_purge_on_iterator_cleanup(&mut self, v: bool)

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

source

pub fn set_ignore_range_deletions(&mut self, v: bool)

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

source

pub fn set_verify_checksums(&mut self, v: bool)

If true, all data read from underlying storage will be verified against corresponding checksums.

Default: true

source

pub fn set_readahead_size(&mut self, v: usize)

If non-zero, an iterator 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

use rocksdb::{ReadOptions};

let mut opts = ReadOptions::default();
opts.set_readahead_size(4_194_304); // 4mb
source

pub fn set_auto_readahead_size(&mut self, v: bool)

If auto_readahead_size is set to true, it will auto tune the readahead_size during scans internally. For this feature to be enabled, iterate_upper_bound must also be specified.

NOTE: - Recommended for forward Scans only. - If there is a backward scans, this option will be disabled internally and won’t be enabled again if the forward scan is issued again.

Default: true

source

pub fn set_tailing(&mut self, v: bool)

If true, create a tailing iterator. Note that tailing iterators only support moving in the forward direction. Iterating in reverse or seek_to_last are not supported.

source

pub fn set_pin_data(&mut self, v: bool)

Specifies the value of “pin_data”. If true, it keeps 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.

Default: false

source

pub fn set_async_io(&mut self, v: bool)

Asynchronously prefetch some data.

Used for sequential reads and internal automatic prefetching.

Default: false

Trait Implementations§

source§

impl Default for ReadOptions

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Drop for ReadOptions

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Send for ReadOptions

source§

impl Sync for ReadOptions

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.