pub struct BlockBasedOptions { /* private fields */ }
Expand description

For configuring block-based file storage.

Implementations§

source§

impl BlockBasedOptions

source

pub fn set_block_size(&mut self, size: usize)

Approximate size of user data packed per block. Note that the block size specified here corresponds to uncompressed data. The actual size of the unit read from disk may be smaller if compression is enabled. This parameter can be changed dynamically.

source

pub fn set_metadata_block_size(&mut self, size: usize)

Block size for partitioned metadata. Currently applied to indexes when kTwoLevelIndexSearch is used and to filters when partition_filters is used. Note: Since in the current implementation the filters and index partitions are aligned, an index/filter block is created when either index or filter block size reaches the specified limit.

Note: this limit is currently applied to only index blocks; a filter partition is cut right after an index block is cut.

source

pub fn set_partition_filters(&mut self, size: bool)

Note: currently this option requires kTwoLevelIndexSearch to be set as well.

Use partitioned full filters for each SST file. This option is incompatible with block-based filters.

source

pub fn set_block_cache(&mut self, cache: &Cache)

Sets global cache for blocks (user data is stored in a set of blocks, and a block is the unit of reading from disk).

If set, use the specified cache for blocks. By default, rocksdb will automatically create and use an 8MB internal cache.

source

pub fn disable_cache(&mut self)

Disable block cache

source

pub fn set_bloom_filter(&mut self, bits_per_key: c_double, block_based: bool)

Sets a Bloom filter policy to reduce disk reads.

§Examples
use speedb::BlockBasedOptions;

let mut opts = BlockBasedOptions::default();
opts.set_bloom_filter(10.0, true);
source

pub fn set_ribbon_filter(&mut self, bloom_equivalent_bits_per_key: c_double)

Sets a Ribbon filter policy to reduce disk reads.

Ribbon filters use less memory in exchange for slightly more CPU usage compared to an equivalent bloom filter.

§Examples
use speedb::BlockBasedOptions;

let mut opts = BlockBasedOptions::default();
opts.set_ribbon_filter(10.0);
source

pub fn set_hybrid_ribbon_filter( &mut self, bloom_equivalent_bits_per_key: c_double, bloom_before_level: c_int )

Sets a hybrid Ribbon filter policy to reduce disk reads.

Uses Bloom filters before the given level, and Ribbon filters for all other levels. This combines the memory savings from Ribbon filters with the lower CPU usage of Bloom filters.

§Examples
use speedb::BlockBasedOptions;

let mut opts = BlockBasedOptions::default();
opts.set_hybrid_ribbon_filter(10.0, 2);
source

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

If cache_index_and_filter_blocks is enabled, cache index and filter blocks with high priority. If set to true, depending on implementation of block cache, index and filter blocks may be less likely to be evicted than data blocks.

source

pub fn set_index_type(&mut self, index_type: BlockBasedIndexType)

Defines the index type to be used for SS-table lookups.

§Examples
use speedb::{BlockBasedOptions, BlockBasedIndexType, Options};

let mut opts = Options::default();
let mut block_opts = BlockBasedOptions::default();
block_opts.set_index_type(BlockBasedIndexType::HashSearch);
source

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

If cache_index_and_filter_blocks is true and the below is true, then filter and index blocks are stored in the cache, but a reference is held in the “table reader” object so the blocks are pinned and only evicted from cache when the table reader is freed.

Default: false.

source

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

If cache_index_and_filter_blocks is true and the below is true, then the top-level index of partitioned filter and index blocks are stored in the cache, but a reference is held in the “table reader” object so the blocks are pinned and only evicted from cache when the table reader is freed. This is not limited to l0 in LSM tree.

Default: false.

source

pub fn set_format_version(&mut self, version: i32)

Format version, reserved for backward compatibility.

See full list of the supported versions.

Default: 5.

source

pub fn set_block_restart_interval(&mut self, interval: i32)

Number of keys between restart points for delta encoding of keys. This parameter can be changed dynamically. Most clients should leave this parameter alone. The minimum value allowed is 1. Any smaller value will be silently overwritten with 1.

Default: 16.

source

pub fn set_index_block_restart_interval(&mut self, interval: i32)

Same as block_restart_interval but used for the index block. If you don’t plan to run RocksDB before version 5.16 and you are using index_block_restart_interval > 1, you should probably set the format_version to >= 4 as it would reduce the index size.

Default: 1.

source

pub fn set_data_block_index_type(&mut self, index_type: DataBlockIndexType)

Set the data block index type for point lookups: DataBlockIndexType::BinarySearch to use binary search within the data block. DataBlockIndexType::BinaryAndHash to use the data block hash index in combination with the normal binary search.

The hash table utilization ratio is adjustable using set_data_block_hash_ratio, which is valid only when using DataBlockIndexType::BinaryAndHash.

Default: BinarySearch

§Examples
use speedb::{BlockBasedOptions, DataBlockIndexType, Options};

let mut opts = Options::default();
let mut block_opts = BlockBasedOptions::default();
block_opts.set_data_block_index_type(DataBlockIndexType::BinaryAndHash);
block_opts.set_data_block_hash_ratio(0.85);
source

pub fn set_data_block_hash_ratio(&mut self, ratio: f64)

Set the data block hash index utilization ratio.

The smaller the utilization ratio, the less hash collisions happen, and so reduce the risk for a point lookup to fall back to binary search due to the collisions. A small ratio means faster lookup at the price of more space overhead.

Default: 0.75

source

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

If false, place only prefixes in the filter, not whole keys.

Defaults to true.

source

pub fn set_checksum_type(&mut self, checksum_type: ChecksumType)

Use the specified checksum type. Newly created table files will be protected with this checksum type. Old table files will still be readable, even though they have different checksum type.

source

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

If true, generate Bloom/Ribbon filters that minimize memory internal fragmentation. See official wiki for more information.

Defaults to false.

§Examples
use speedb::BlockBasedOptions;

let mut opts = BlockBasedOptions::default();
opts.set_bloom_filter(10.0, true);
opts.set_optimize_filters_for_memory(true);

Trait Implementations§

source§

impl Default for BlockBasedOptions

source§

fn default() -> Self

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

impl Drop for BlockBasedOptions

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Send for BlockBasedOptions

source§

impl Sync for BlockBasedOptions

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.