Struct rocksdb::BlockBasedOptions
source · pub struct BlockBasedOptions { /* private fields */ }
Expand description
For configuring block-based file storage.
Implementations§
source§impl BlockBasedOptions
impl BlockBasedOptions
sourcepub fn set_block_size(&mut self, size: usize)
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.
sourcepub fn set_metadata_block_size(&mut self, size: usize)
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.
sourcepub fn set_partition_filters(&mut self, size: bool)
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.
sourcepub fn set_block_cache(&mut self, cache: &Cache)
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.
sourcepub fn disable_cache(&mut self)
pub fn disable_cache(&mut self)
Disable block cache
sourcepub fn set_bloom_filter(&mut self, bits_per_key: c_double, block_based: bool)
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 rocksdb::BlockBasedOptions;
let mut opts = BlockBasedOptions::default();
opts.set_bloom_filter(10.0, true);
sourcepub fn set_ribbon_filter(&mut self, bloom_equivalent_bits_per_key: c_double)
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 rocksdb::BlockBasedOptions;
let mut opts = BlockBasedOptions::default();
opts.set_ribbon_filter(10.0);
sourcepub fn set_hybrid_ribbon_filter(
&mut self,
bloom_equivalent_bits_per_key: c_double,
bloom_before_level: c_int,
)
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 rocksdb::BlockBasedOptions;
let mut opts = BlockBasedOptions::default();
opts.set_hybrid_ribbon_filter(10.0, 2);
sourcepub fn set_cache_index_and_filter_blocks(&mut self, v: bool)
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.
sourcepub fn set_index_type(&mut self, index_type: BlockBasedIndexType)
pub fn set_index_type(&mut self, index_type: BlockBasedIndexType)
Defines the index type to be used for SS-table lookups.
§Examples
use rocksdb::{BlockBasedOptions, BlockBasedIndexType, Options};
let mut opts = Options::default();
let mut block_opts = BlockBasedOptions::default();
block_opts.set_index_type(BlockBasedIndexType::HashSearch);
sourcepub fn set_pin_l0_filter_and_index_blocks_in_cache(&mut self, v: bool)
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.
sourcepub fn set_pin_top_level_index_and_filter(&mut self, v: bool)
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.
sourcepub fn set_format_version(&mut self, version: i32)
pub fn set_format_version(&mut self, version: i32)
Format version, reserved for backward compatibility.
See full list of the supported versions.
Default: 5.
sourcepub fn set_block_restart_interval(&mut self, interval: i32)
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.
sourcepub fn set_index_block_restart_interval(&mut self, interval: i32)
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.
sourcepub fn set_data_block_index_type(&mut self, index_type: DataBlockIndexType)
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 rocksdb::{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);
sourcepub fn set_data_block_hash_ratio(&mut self, ratio: f64)
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
sourcepub fn set_whole_key_filtering(&mut self, v: bool)
pub fn set_whole_key_filtering(&mut self, v: bool)
If false, place only prefixes in the filter, not whole keys.
Defaults to true.
sourcepub fn set_checksum_type(&mut self, checksum_type: ChecksumType)
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.
sourcepub fn set_optimize_filters_for_memory(&mut self, v: bool)
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 rocksdb::BlockBasedOptions;
let mut opts = BlockBasedOptions::default();
opts.set_bloom_filter(10.0, true);
opts.set_optimize_filters_for_memory(true);