pub struct Options { /* private fields */ }Expand description
Database-wide options around performance and behavior.
Please read the official tuning guide and most importantly, measure performance under realistic workloads with realistic hardware.
§Examples
use rust_rocksdb::{Options, DB};
use rust_rocksdb::DBCompactionStyle;
fn badly_tuned_for_somebody_elses_disk() -> DB {
let path = "path/for/rocksdb/storageX";
let mut opts = Options::default();
opts.create_if_missing(true);
opts.set_max_open_files(10000);
opts.set_use_fsync(false);
opts.set_bytes_per_sync(8388608);
opts.optimize_for_point_lookup(1024);
opts.set_table_cache_num_shard_bits(6);
opts.set_max_write_buffer_number(32);
opts.set_write_buffer_size(536870912);
opts.set_target_file_size_base(1073741824);
opts.set_min_write_buffer_number_to_merge(4);
opts.set_level_zero_stop_writes_trigger(2000);
opts.set_level_zero_slowdown_writes_trigger(0);
opts.set_compaction_style(DBCompactionStyle::Universal);
opts.set_disable_auto_compactions(true);
DB::open(&opts, path).unwrap()
}Implementations§
Source§impl Options
impl Options
Sourcepub fn load_latest<P: AsRef<Path>>(
path: P,
env: Env,
ignore_unknown_options: bool,
cache: Cache,
) -> Result<(Options, Vec<ColumnFamilyDescriptor>), Error>
pub fn load_latest<P: AsRef<Path>>( path: P, env: Env, ignore_unknown_options: bool, cache: Cache, ) -> Result<(Options, Vec<ColumnFamilyDescriptor>), Error>
Constructs the DBOptions and ColumnFamilyDescriptors by loading the latest RocksDB options file stored in the specified rocksdb database.
IMPORTANT:
ROCKSDB DOES NOT STORE cf ttl in the options file. If you have set it via
ColumnFamilyDescriptor::new_with_ttl then you need to set it again after loading the options file.
Tll will be set to ColumnFamilyTtl::Disabled for all column families for your safety.
Sourcepub fn get_options_from_string<S: AsRef<str>>(
&mut self,
opts_str: S,
) -> Result<Options, Error>
pub fn get_options_from_string<S: AsRef<str>>( &mut self, opts_str: S, ) -> Result<Options, Error>
Constructs a new DBOptions from self and a string opts_str with the syntax detailed in the blogpost
Reading RocksDB options from a file
Sourcepub fn increase_parallelism(&mut self, parallelism: i32)
pub fn increase_parallelism(&mut self, parallelism: i32)
By default, RocksDB uses only one background thread for flush and
compaction. Calling this function will set it up such that total of
total_threads is used. Good value for total_threads is the number of
cores. You almost definitely want to call this function if your system is
bottlenecked by RocksDB.
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.increase_parallelism(3);Sourcepub fn optimize_level_style_compaction(&mut self, memtable_memory_budget: usize)
pub fn optimize_level_style_compaction(&mut self, memtable_memory_budget: usize)
Optimize level style compaction.
Default values for some parameters in Options are not optimized for heavy
workloads and big datasets, which means you might observe write stalls under
some conditions.
This can be used as one of the starting points for tuning RocksDB options in such cases.
Internally, it sets write_buffer_size, min_write_buffer_number_to_merge,
max_write_buffer_number, level0_file_num_compaction_trigger,
target_file_size_base, max_bytes_for_level_base, so it can override if those
parameters were set before.
It sets buffer sizes so that memory consumption would be constrained by
memtable_memory_budget.
Sourcepub fn optimize_universal_style_compaction(
&mut self,
memtable_memory_budget: usize,
)
pub fn optimize_universal_style_compaction( &mut self, memtable_memory_budget: usize, )
Optimize universal style compaction.
Default values for some parameters in Options are not optimized for heavy
workloads and big datasets, which means you might observe write stalls under
some conditions.
This can be used as one of the starting points for tuning RocksDB options in such cases.
Internally, it sets write_buffer_size, min_write_buffer_number_to_merge,
max_write_buffer_number, level0_file_num_compaction_trigger,
target_file_size_base, max_bytes_for_level_base, so it can override if those
parameters were set before.
It sets buffer sizes so that memory consumption would be constrained by
memtable_memory_budget.
Sourcepub fn create_if_missing(&mut self, create_if_missing: bool)
pub fn create_if_missing(&mut self, create_if_missing: bool)
If true, the database will be created if it is missing.
Default: false
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.create_if_missing(true);Sourcepub fn create_missing_column_families(&mut self, create_missing_cfs: bool)
pub fn create_missing_column_families(&mut self, create_missing_cfs: bool)
If true, any column families that didn’t exist when opening the database will be created.
Default: false
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.create_missing_column_families(true);Sourcepub fn set_error_if_exists(&mut self, enabled: bool)
pub fn set_error_if_exists(&mut self, enabled: bool)
Specifies whether an error should be raised if the database already exists.
Default: false
Sourcepub fn set_paranoid_checks(&mut self, enabled: bool)
pub fn set_paranoid_checks(&mut self, enabled: bool)
Enable/disable paranoid checks.
If true, the implementation will do aggressive checking of the data it is processing and will stop early if it detects any errors. This may have unforeseen ramifications: for example, a corruption of one DB entry may cause a large number of entries to become unreadable or for the entire DB to become unopenable. If any of the writes to the database fails (Put, Delete, Merge, Write), the database will switch to read-only mode and fail all other Write operations.
Default: true
Sourcepub fn set_db_paths(&mut self, paths: &[DBPath])
pub fn set_db_paths(&mut self, paths: &[DBPath])
A list of paths where SST files can be put into, with its target size. Newer data is placed into paths specified earlier in the vector while older data gradually moves to paths specified later in the vector.
For example, you have a flash device with 10GB allocated for the DB, as well as a hard drive of 2TB, you should config it to be: [{“/flash_path”, 10GB}, {“/hard_drive”, 2TB}]
The system will try to guarantee data under each path is close to but not larger than the target size. But current and future file sizes used by determining where to place a file are based on best-effort estimation, which means there is a chance that the actual size under the directory is slightly more than target size under some workloads. User should give some buffer room for those cases.
If none of the paths has sufficient room to place a file, the file will be placed to the last path anyway, despite to the target size.
Placing newer data to earlier paths is also best-efforts. User should expect user files to be placed in higher levels in some extreme cases.
If left empty, only one path will be used, which is path passed when
opening the DB.
Default: empty
Sourcepub fn set_cf_paths(&mut self, paths: &[DBPath])
pub fn set_cf_paths(&mut self, paths: &[DBPath])
The same list of sized paths as Self::set_db_paths, but for one column family
rather than the whole DB.
When set, this wins over db_paths for the SST files of that column family, and
db_paths keeps covering everything else. Set it on the Options you pass in the
ColumnFamilyDescriptor, not on the DB-wide options.
More than one entry is only supported under level and universal compaction, and it
forces level_compaction_dynamic_level_bytes off because RocksDB cannot combine the
two. A path shared by several column families holds the files and counts the size of
all of them against its target, so size it for the total.
Default: empty, meaning the column family follows db_paths.
Sourcepub fn set_env(&mut self, env: &Env)
pub fn set_env(&mut self, env: &Env)
Use the specified object to interact with the environment, e.g. to read/write files, schedule background work, etc. In the near future, support for doing storage operations such as read/write files through env will be deprecated in favor of file_system.
Default: Env::default()
Sourcepub fn set_compression_type(&mut self, t: DBCompressionType)
pub fn set_compression_type(&mut self, t: DBCompressionType)
Sets the compression algorithm that will be used for compressing blocks.
Default: DBCompressionType::Lz4, falling back to
DBCompressionType::Snappy and then DBCompressionType::None when the
preceding one is not compiled in. RocksDB 11.5.0 changed this from
Snappy; it affects only column families that never set compression,
and only newly written SST files. Existing data stays readable, since
the decompressor is selected per block.
§Examples
use rust_rocksdb::{Options, DBCompressionType};
let mut opts = Options::default();
opts.set_compression_type(DBCompressionType::Snappy);Sourcepub fn get_compression_type(&self) -> Option<DBCompressionType>
pub fn get_compression_type(&self) -> Option<DBCompressionType>
The compression algorithm used for new blocks.
None covers a compression type this crate does not name: xpress, which is Windows
only, and the custom compression range a CompressionManager can hand out.
Sourcepub fn set_compression_options_parallel_threads(&mut self, num: i32)
pub fn set_compression_options_parallel_threads(&mut self, num: i32)
Number of threads for parallel compression. Parallel compression is enabled only if threads > 1. THE FEATURE IS STILL EXPERIMENTAL
See code for more information.
Default: 1
Examples
use rust_rocksdb::{Options, DBCompressionType};
let mut opts = Options::default();
opts.set_compression_type(DBCompressionType::Zstd);
opts.set_compression_options_parallel_threads(3);Sourcepub fn set_wal_compression_type(&mut self, t: DBCompressionType)
pub fn set_wal_compression_type(&mut self, t: DBCompressionType)
Sets the compression algorithm that will be used for compressing WAL.
At present, only ZSTD compression is supported!
Default: DBCompressionType::None
§Examples
use rust_rocksdb::{Options, DBCompressionType};
let mut opts = Options::default();
opts.set_wal_compression_type(DBCompressionType::Zstd);
// Or None to disable it
opts.set_wal_compression_type(DBCompressionType::None);Sourcepub fn get_wal_compression_type(&self) -> Option<DBCompressionType>
pub fn get_wal_compression_type(&self) -> Option<DBCompressionType>
The compression algorithm used for the WAL, DBCompressionType::None when disabled.
None covers a compression type this crate does not name. Only ZSTD can reach here
through Self::set_wal_compression_type, but an options string can set anything.
Sourcepub fn set_bottommost_compression_type(&mut self, t: DBCompressionType)
pub fn set_bottommost_compression_type(&mut self, t: DBCompressionType)
Sets the bottom-most compression algorithm that will be used for compressing blocks at the bottom-most level.
Note that to actually enable bottom-most compression configuration after
setting the compression type, it needs to be enabled by calling
set_bottommost_compression_options or
set_bottommost_zstd_max_train_bytes method with enabled argument
set to true.
§Examples
use rust_rocksdb::{Options, DBCompressionType};
let mut opts = Options::default();
opts.set_bottommost_compression_type(DBCompressionType::Zstd);
opts.set_bottommost_zstd_max_train_bytes(0, true);Sourcepub fn get_bottommost_compression_type(&self) -> Option<DBCompressionType>
pub fn get_bottommost_compression_type(&self) -> Option<DBCompressionType>
The compression algorithm set for the bottom-most level.
The default is the kDisableCompressionOption sentinel, which this crate does not
name, so an untouched Options reads back as None. That sentinel means the
bottom-most level follows Self::set_compression_type like every other level.
Sourcepub fn set_compression_per_level(&mut self, level_types: &[DBCompressionType])
pub fn set_compression_per_level(&mut self, level_types: &[DBCompressionType])
Different levels can have different compression policies. There are cases where most lower levels would like to use quick compression algorithms while the higher levels (which have more data) use compression algorithms that have better compression but could be slower. This array, if non-empty, should have an entry for each level of the database; these override the value specified in the previous field ‘compression’.
§Examples
use rust_rocksdb::{Options, DBCompressionType};
let mut opts = Options::default();
opts.set_compression_per_level(&[
DBCompressionType::None,
DBCompressionType::None,
DBCompressionType::Snappy,
DBCompressionType::Snappy,
DBCompressionType::Snappy
]);Sourcepub fn set_compression_options(
&mut self,
w_bits: c_int,
level: c_int,
strategy: c_int,
max_dict_bytes: c_int,
)
pub fn set_compression_options( &mut self, w_bits: c_int, level: c_int, strategy: c_int, max_dict_bytes: c_int, )
Maximum size of dictionaries used to prime the compression library. Enabling dictionary can improve compression ratios when there are repetitions across data blocks.
The dictionary is created by sampling the SST file data. If
zstd_max_train_bytes is nonzero, the samples are passed through zstd’s
dictionary generator. Otherwise, the random samples are used directly as
the dictionary.
When compression dictionary is disabled, we compress and write each block before buffering data for the next one. When compression dictionary is enabled, we buffer all SST file data in-memory so we can sample it, as data can only be compressed and written after the dictionary has been finalized. So users of this feature may see increased memory usage.
Default: 0
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.set_compression_options(4, 5, 6, 7);Sourcepub fn set_bottommost_compression_options(
&mut self,
w_bits: c_int,
level: c_int,
strategy: c_int,
max_dict_bytes: c_int,
enabled: bool,
)
pub fn set_bottommost_compression_options( &mut self, w_bits: c_int, level: c_int, strategy: c_int, max_dict_bytes: c_int, enabled: bool, )
Sets compression options for blocks at the bottom-most level. Meaning
of all settings is the same as in set_compression_options method but
affect only the bottom-most compression which is set using
set_bottommost_compression_type method.
§Examples
use rust_rocksdb::{Options, DBCompressionType};
let mut opts = Options::default();
opts.set_bottommost_compression_type(DBCompressionType::Zstd);
opts.set_bottommost_compression_options(4, 5, 6, 7, true);Sourcepub fn set_zstd_max_train_bytes(&mut self, value: c_int)
pub fn set_zstd_max_train_bytes(&mut self, value: c_int)
Sets maximum size of training data passed to zstd’s dictionary trainer. Using zstd’s
dictionary trainer can achieve even better compression ratio improvements than using
max_dict_bytes alone.
The training data will be used to generate a dictionary of max_dict_bytes.
Default: 0.
Sourcepub fn set_bottommost_zstd_max_train_bytes(
&mut self,
value: c_int,
enabled: bool,
)
pub fn set_bottommost_zstd_max_train_bytes( &mut self, value: c_int, enabled: bool, )
Sets maximum size of training data passed to zstd’s dictionary trainer
when compressing the bottom-most level. Using zstd’s dictionary trainer
can achieve even better compression ratio improvements than using
max_dict_bytes alone.
The training data will be used to generate a dictionary of
max_dict_bytes.
Default: 0.
Sourcepub fn set_compaction_readahead_size(
&mut self,
compaction_readahead_size: usize,
)
pub fn set_compaction_readahead_size( &mut self, compaction_readahead_size: usize, )
If non-zero, we perform bigger reads when doing compaction. If you’re running RocksDB on spinning disks, you should set this to at least 2MB. That way RocksDB’s compaction is doing sequential instead of random reads.
Default: 2 * 1024 * 1024 (2 MB)
Sourcepub fn set_level_compaction_dynamic_level_bytes(&mut self, v: bool)
pub fn set_level_compaction_dynamic_level_bytes(&mut self, v: bool)
Allow RocksDB to pick dynamic base of bytes for levels. With this feature turned on, RocksDB will automatically adjust max bytes for each level. The goal of this feature is to have lower bound on size amplification.
Default: true.
Sourcepub fn set_periodic_compaction_seconds(&mut self, secs: u64)
pub fn set_periodic_compaction_seconds(&mut self, secs: u64)
This option has different meanings for different compaction styles:
Leveled: files older than periodic_compaction_seconds will be picked up
for compaction and will be re-written to the same level as they were
before if level_compaction_dynamic_level_bytes is disabled. Otherwise,
it will rewrite files to the next level except for the last level files
to the same level.
FIFO: not supported. Setting this option has no effect for FIFO compaction.
Universal: when there are files older than periodic_compaction_seconds,
rocksdb will try to do as large a compaction as possible including the
last level. Such compaction is only skipped if only last level is to
be compacted and no file in last level is older than
periodic_compaction_seconds. See more in
UniversalCompactionBuilder::PickPeriodicCompaction().
For backward compatibility, the effective value of this option takes
into account the value of option ttl. The logic is as follows:
- both options are set to 30 days if they have the default value.
- if both options are zero, zero is picked. Otherwise, we take the min value among non-zero options values (i.e. takes the stricter limit).
One main use of the feature is to make sure a file goes through compaction filters periodically. Users can also use the feature to clear up SST files using old format.
A file’s age is computed by looking at file_creation_time or creation_time table properties in order, if they have valid non-zero values; if not, the age is based on the file’s last modified time (given by the underlying Env).
This option only supports block based table format for any compaction style.
unit: seconds. Ex: 7 days = 7 * 24 * 60 * 60
Values: 0: Turn off Periodic compactions. UINT64_MAX - 1 (0xfffffffffffffffe) is special flag to allow RocksDB to pick default.
Default: 30 days if using block based table format + compaction filter + leveled compaction or block based table format + universal compaction. 0 (disabled) otherwise.
Sourcepub fn set_memtable_op_scan_flush_trigger(&mut self, num: u32)
pub fn set_memtable_op_scan_flush_trigger(&mut self, num: u32)
When an iterator scans this number of invisible entries (tombstones or hidden puts) from the active memtable during a single iterator operation, we will attempt to flush the memtable. Currently only forward scans are supported (SeekToFirst(), Seek() and Next()). This option helps to reduce the overhead of scanning through a large number of entries in memtable. Users should consider enable deletion-triggered-compaction (see CompactOnDeletionCollectorFactory) together with this option to compact away tombstones after the memtable is flushed.
Default: 0 (disabled) Dynamically changeable through the SetOptions() API.
Sourcepub fn set_memtable_avg_op_scan_flush_trigger(&mut self, num: u32)
pub fn set_memtable_avg_op_scan_flush_trigger(&mut self, num: u32)
Similar to memtable_op_scan_flush_trigger, but this option applies to
Next() calls between Seeks or until iterator destruction. If the average
of the number of invisible entries scanned from the active memtable, the
memtable will be marked for flush.
Note that to avoid the case where the window between Seeks is too small,
the option only takes effect if the total number of hidden entries scanned
within a window is at least memtable_op_scan_flush_trigger. So this
option is only effective when memtable_op_scan_flush_trigger is set.
This option should be set to a lower value than
memtable_op_scan_flush_trigger. It covers the case where an iterator
scans through an expensive key range with many invisible entries from the
active memtable, but the number of invisible entries per operation does not
exceed memtable_op_scan_flush_trigger.
Default: 0 (disabled) Dynamically changeable through the SetOptions() API.
Sourcepub fn set_ttl(&mut self, secs: u64)
pub fn set_ttl(&mut self, secs: u64)
This option has different meanings for different compaction styles:
Leveled: Non-bottom-level files with all keys older than TTL will go through the compaction process. This usually happens in a cascading way so that those entries will be compacted to bottommost level/file. The feature is used to remove stale entries that have been deleted or updated from the file system.
FIFO: Files with all keys older than TTL will be deleted. TTL is only supported if option max_open_files is set to -1.
Universal: users should only set the option periodic_compaction_seconds
instead. For backward compatibility, this option has the same
meaning as periodic_compaction_seconds. See more in comments for
periodic_compaction_seconds on the interaction between these two
options.
This option only supports block based table format for any compaction style.
unit: seconds. Ex: 1 day = 1 * 24 * 60 * 60 0 means disabling. UINT64_MAX - 1 (0xfffffffffffffffe) is special flag to allow RocksDB to pick default.
Default: 30 days if using block based table. 0 (disable) otherwise.
Dynamically changeable
Note that dynamically changing this option only works for leveled and FIFO
compaction. For universal compaction, dynamically changing this option has
no effect, users should dynamically change periodic_compaction_seconds
instead.
pub fn set_merge_operator_associative<F: MergeFn + Clone>( &mut self, name: impl CStrLike, full_merge_fn: F, )
pub fn set_merge_operator<F: MergeFn, PF: MergeFn>( &mut self, name: impl CStrLike, full_merge_fn: F, partial_merge_fn: PF, )
pub fn add_merge_operator<F: MergeFn + Clone>( &mut self, name: &str, merge_fn: F, )
add_merge_operator has been renamed to set_merge_operator
Sourcepub fn set_compaction_filter<F>(&mut self, name: impl CStrLike, filter_fn: F)where
F: CompactionFilterFn + Send + 'static,
pub fn set_compaction_filter<F>(&mut self, name: impl CStrLike, filter_fn: F)where
F: CompactionFilterFn + Send + 'static,
Sets a compaction filter used to determine if entries should be kept, changed, or removed during compaction.
An example use case is to remove entries with an expired TTL.
If you take a snapshot of the database, only values written since the last snapshot will be passed through the compaction filter.
If multi-threaded compaction is used, filter_fn may be called multiple times
simultaneously.
pub fn add_event_listener<L: EventListener>(&mut self, l: L)
Sourcepub fn set_compaction_filter_factory<F>(&mut self, factory: F)where
F: CompactionFilterFactory + 'static,
pub fn set_compaction_filter_factory<F>(&mut self, factory: F)where
F: CompactionFilterFactory + 'static,
This is a factory that provides compaction filter objects which allow an application to modify/delete a key-value during background compaction.
A new filter will be created on each compaction run. If multithreaded compaction is being used, each created CompactionFilter will only be used from a single thread and so does not need to be thread-safe.
Default: nullptr
Sourcepub fn set_sst_partitioner_factory(&mut self, factory: &SstPartitionerFactory)
pub fn set_sst_partitioner_factory(&mut self, factory: &SstPartitionerFactory)
Makes compaction cut its output files on the boundaries this factory reports, so a key prefix stays inside a single SST.
See the sst_partitioner module for what that
buys and what it does not. Only files written by later compactions are
partitioned, so setting this on an existing DB takes effect gradually.
Marked experimental upstream. Default: no partitioner.
§Examples
use rust_rocksdb::{Options, SstPartitionerFactory};
let mut opts = Options::default();
opts.set_sst_partitioner_factory(&SstPartitionerFactory::fixed_prefix(8));Sourcepub fn set_file_checksum_gen_factory(
&mut self,
factory: &FileChecksumGenFactory,
)
pub fn set_file_checksum_gen_factory( &mut self, factory: &FileChecksumGenFactory, )
Makes RocksDB compute a checksum over each SST file it writes and record it in the manifest.
Nothing verifies file checksums until this is set, and files already on
disk stay without one until a compaction rewrites them. See the
file_checksum module for how this differs from
the per-block checksum on BlockBasedOptions::set_checksum_type.
Default: none, so no file checksums are produced or checked.
§Examples
use rust_rocksdb::{FileChecksumGenFactory, Options};
let mut opts = Options::default();
opts.set_file_checksum_gen_factory(&FileChecksumGenFactory::crc32c());Sourcepub fn set_compaction_service<S>(&mut self, service: S)where
S: CompactionService + 'static,
pub fn set_compaction_service<S>(&mut self, service: S)where
S: CompactionService + 'static,
Sends this DB’s compactions to service instead of running them
locally.
RocksDB serializes each compaction, hands it to
schedule, and blocks in
wait until the worker returns a result. See
the compaction_service module for the
worker half and for the panic and threading rules the service methods
run under.
Upstream marks this experimental and reserves the right to change it without compatibility guarantees.
Replaces any service set earlier. Default: none.
Sourcepub fn set_wal_filter<F>(&mut self, filter: F)where
F: WalFilter + 'static,
pub fn set_wal_filter<F>(&mut self, filter: F)where
F: WalFilter + 'static,
Installs a filter that sees every WAL record replayed during recovery and decides what to do with it.
The filter runs inside DB::open and is never
consulted again once the DB is up. See the
wal_filter module for the decisions it can make
and for the panic and threading rules its methods run under.
This is a DB-wide option. Setting it on a column family’s Options has
no effect.
Replaces any filter set earlier. Default: none.
Sourcepub fn clear_wal_filter(&mut self)
pub fn clear_wal_filter(&mut self)
Removes the filter set by Self::set_wal_filter, so recovery replays
every WAL record as written.
This only clears these Options. A DB already opened from them keeps
the filter it was opened with, and so does any Options cloned before
this call.
Sourcepub fn set_comparator(
&mut self,
name: impl CStrLike,
compare_fn: Box<dyn Fn(&[u8], &[u8]) -> Ordering + Send + Sync>,
)
pub fn set_comparator( &mut self, name: impl CStrLike, compare_fn: Box<dyn Fn(&[u8], &[u8]) -> Ordering + Send + Sync>, )
Sets the comparator used to define the order of keys in the table. Default: a comparator that uses lexicographic byte-wise ordering
The client must ensure that the comparator supplied here has the same name and orders keys exactly the same as the comparator provided to previous open calls on the same DB.
Sourcepub fn set_comparator_with_ts(
&mut self,
name: impl CStrLike,
timestamp_size: usize,
compare_fn: Box<dyn Fn(&[u8], &[u8]) -> Ordering + Send + Sync>,
compare_ts_fn: Box<dyn Fn(&[u8], &[u8]) -> Ordering + Send + Sync>,
compare_without_ts_fn: Box<dyn Fn(&[u8], bool, &[u8], bool) -> Ordering + Send + Sync>,
)
pub fn set_comparator_with_ts( &mut self, name: impl CStrLike, timestamp_size: usize, compare_fn: Box<dyn Fn(&[u8], &[u8]) -> Ordering + Send + Sync>, compare_ts_fn: Box<dyn Fn(&[u8], &[u8]) -> Ordering + Send + Sync>, compare_without_ts_fn: Box<dyn Fn(&[u8], bool, &[u8], bool) -> Ordering + Send + Sync>, )
Sets the comparator that are timestamp-aware, used to define the order of keys in the table, taking timestamp into consideration. Find more information on timestamp-aware comparator on here
The client must ensure that the comparator supplied here has the same name and orders keys exactly the same as the comparator provided to previous open calls on the same DB.
pub fn set_prefix_extractor(&mut self, prefix_extractor: SliceTransform)
pub fn optimize_for_point_lookup(&mut self, block_cache_size_mb: u64)
Sourcepub fn set_optimize_filters_for_hits(&mut self, optimize_for_hits: bool)
pub fn set_optimize_filters_for_hits(&mut self, optimize_for_hits: bool)
Sets the optimize_filters_for_hits flag
Default: false
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.set_optimize_filters_for_hits(true);Sourcepub fn set_delete_obsolete_files_period_micros(&mut self, micros: u64)
pub fn set_delete_obsolete_files_period_micros(&mut self, micros: u64)
Sets the periodicity when obsolete files get deleted.
The files that get out of scope by compaction process will still get automatically delete on every compaction, regardless of this setting.
Default: 6 hours
Sourcepub fn prepare_for_bulk_load(&mut self)
pub fn prepare_for_bulk_load(&mut self)
Prepare the DB for bulk loading.
All data will be in level 0 without any automatic compaction. It’s recommended to manually call CompactRange(NULL, NULL) before reading from the database, because otherwise the read can be very slow.
Sourcepub fn set_max_open_files(&mut self, nfiles: c_int)
pub fn set_max_open_files(&mut self, nfiles: c_int)
Sets the number of open files that can be used by the DB. You may need to
increase this if your database has a large working set. Value -1 means
files opened are always kept open. You can estimate number of files based
on target_file_size_base and target_file_size_multiplier for level-based
compaction. For universal-style compaction, you can usually set it to -1.
Default: -1
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.set_max_open_files(10);Sourcepub fn set_max_file_opening_threads(&mut self, nthreads: c_int)
pub fn set_max_file_opening_threads(&mut self, nthreads: c_int)
If max_open_files is -1, DB will open all files on DB::Open(). You can use this option to increase the number of threads used to open the files. Default: 16
Sourcepub fn set_use_fsync(&mut self, useit: bool)
pub fn set_use_fsync(&mut self, useit: bool)
By default, writes to stable storage use fdatasync (on platforms where this function is available). If this option is true, fsync is used instead.
fsync and fdatasync are equally safe for our purposes and fdatasync is faster, so it is rarely necessary to set this option. It is provided as a workaround for kernel/filesystem bugs, such as one that affected fdatasync with ext4 in kernel versions prior to 3.7.
Default: false
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.set_use_fsync(true);Sourcepub fn get_use_fsync(&self) -> bool
pub fn get_use_fsync(&self) -> bool
Returns the value of the use_fsync option.
Sourcepub fn set_db_log_dir<P: AsRef<Path>>(&mut self, path: P)
pub fn set_db_log_dir<P: AsRef<Path>>(&mut self, path: P)
Specifies the absolute info LOG dir.
If it is empty, the log files will be in the same dir as data. If it is non empty, the log files will be in the specified dir, and the db data dir’s absolute path will be used as the log file name’s prefix.
Default: empty
Sourcepub fn get_db_log_dir(&self) -> String
pub fn get_db_log_dir(&self) -> String
The info LOG dir set by Self::set_db_log_dir, empty when logs go next to the data.
Sourcepub fn set_log_level(&mut self, level: LogLevel)
pub fn set_log_level(&mut self, level: LogLevel)
Specifies the log level.
Consider the LogLevel enum for a list of possible levels.
Default: Info
§Examples
use rust_rocksdb::{Options, LogLevel};
let mut opts = Options::default();
opts.set_log_level(LogLevel::Warn);Sourcepub fn get_log_level(&self) -> Option<LogLevel>
pub fn get_log_level(&self) -> Option<LogLevel>
The verbosity set by Self::set_log_level.
None covers a level this crate does not name, which today only means RocksDB’s
NUM_INFO_LOG_LEVELS sentinel.
Sourcepub fn set_bytes_per_sync(&mut self, nbytes: u64)
pub fn set_bytes_per_sync(&mut self, nbytes: u64)
Allows OS to incrementally sync files to disk while they are being
written, asynchronously, in the background. This operation can be used
to smooth out write I/Os over time. Users shouldn’t rely on it for
persistency guarantee.
Issue one request for every bytes_per_sync written. 0 turns it off.
Default: 0
You may consider using rate_limiter to regulate write rate to device. When rate limiter is enabled, it automatically enables bytes_per_sync to 1MB.
This option applies to table files
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.set_bytes_per_sync(1024 * 1024);Sourcepub fn set_wal_bytes_per_sync(&mut self, nbytes: u64)
pub fn set_wal_bytes_per_sync(&mut self, nbytes: u64)
Same as bytes_per_sync, but applies to WAL files.
Default: 0, turned off
Dynamically changeable through SetDBOptions() API.
Sourcepub fn set_writable_file_max_buffer_size(&mut self, nbytes: u64)
pub fn set_writable_file_max_buffer_size(&mut self, nbytes: u64)
Sets the maximum buffer size that is used by WritableFileWriter.
On Windows, we need to maintain an aligned buffer for writes. We allow the buffer to grow until it’s size hits the limit in buffered IO and fix the buffer size when using direct IO to ensure alignment of write requests if the logical sector size is unusual
Default: 1024 * 1024 (1 MB)
Dynamically changeable through SetDBOptions() API.
Sourcepub fn set_allow_concurrent_memtable_write(&mut self, allow: bool)
pub fn set_allow_concurrent_memtable_write(&mut self, allow: bool)
If true, allow multi-writers to update mem tables in parallel. Only some memtable_factory-s support concurrent writes; currently it is implemented only for SkipListFactory. Concurrent memtable writes are not compatible with inplace_update_support or filter_deletes. It is strongly recommended to set enable_write_thread_adaptive_yield if you are going to use this feature.
Default: true
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.set_allow_concurrent_memtable_write(false);Sourcepub fn set_enable_write_thread_adaptive_yield(&mut self, enabled: bool)
pub fn set_enable_write_thread_adaptive_yield(&mut self, enabled: bool)
If true, threads synchronizing with the write batch group leader will wait for up to write_thread_max_yield_usec before blocking on a mutex. This can substantially improve throughput for concurrent workloads, regardless of whether allow_concurrent_memtable_write is enabled.
Default: true
Sourcepub fn set_max_sequential_skip_in_iterations(&mut self, num: u64)
pub fn set_max_sequential_skip_in_iterations(&mut self, num: u64)
Specifies whether an iteration->Next() sequentially skips over keys with the same user-key or not.
This number specifies the number of keys (with the same userkey) that will be sequentially skipped before a reseek is issued.
Default: 8
Sourcepub fn set_use_direct_reads(&mut self, enabled: bool)
pub fn set_use_direct_reads(&mut self, enabled: bool)
Enable direct I/O mode for reading they may or may not improve performance depending on the use case
Files will be opened in “direct I/O” mode which means that data read from the disk will not be cached or buffered. The hardware buffer of the devices may however still be used. Memory mapped files are not impacted by these parameters.
Default: false
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.set_use_direct_reads(true);Sourcepub fn set_use_direct_io_for_flush_and_compaction(&mut self, enabled: bool)
pub fn set_use_direct_io_for_flush_and_compaction(&mut self, enabled: bool)
Enable direct I/O mode for flush and compaction
Files will be opened in “direct I/O” mode which means that data written to the disk will not be cached or buffered. The hardware buffer of the devices may however still be used. Memory mapped files are not impacted by these parameters. they may or may not improve performance depending on the use case
Default: false
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.set_use_direct_io_for_flush_and_compaction(true);Sourcepub fn set_is_fd_close_on_exec(&mut self, enabled: bool)
pub fn set_is_fd_close_on_exec(&mut self, enabled: bool)
Enable/disable child process inherit open files.
Default: true
Sourcepub fn set_allow_os_buffer(&mut self, is_allow: bool)
👎Deprecated since 0.7.0: replaced with set_use_direct_reads/set_use_direct_io_for_flush_and_compaction methods
pub fn set_allow_os_buffer(&mut self, is_allow: bool)
replaced with set_use_direct_reads/set_use_direct_io_for_flush_and_compaction methods
Hints to the OS that it should not buffer disk I/O. Enabling this parameter may improve performance but increases pressure on the system cache.
The exact behavior of this parameter is platform dependent.
On POSIX systems, after RocksDB reads data from disk it will mark the pages as “unneeded”. The operating system may or may not evict these pages from memory, reducing pressure on the system cache. If the disk block is requested again this can result in additional disk I/O.
On WINDOWS systems, files will be opened in “unbuffered I/O” mode which means that data read from the disk will not be cached or bufferized. The hardware buffer of the devices may however still be used. Memory mapped files are not impacted by this parameter.
Default: true
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
#[allow(deprecated)]
opts.set_allow_os_buffer(false);Sourcepub fn set_table_cache_num_shard_bits(&mut self, nbits: c_int)
pub fn set_table_cache_num_shard_bits(&mut self, nbits: c_int)
Sets the number of shards used for table cache.
Default: 6
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.set_table_cache_num_shard_bits(4);Sourcepub fn set_target_file_size_multiplier(&mut self, multiplier: i32)
pub fn set_target_file_size_multiplier(&mut self, multiplier: i32)
By default target_file_size_multiplier is 1, which means by default files in different levels will have similar size.
Dynamically changeable through SetOptions() API
Sourcepub fn set_min_write_buffer_number(&mut self, nbuf: c_int)
pub fn set_min_write_buffer_number(&mut self, nbuf: c_int)
Sets the minimum number of write buffers that will be merged
before writing to storage. If set to 1, then
all write buffers are flushed to L0 as individual files and this increases
read amplification because a get request has to check in all of these
files. Also, an in-memory merge may result in writing lesser
data to storage if there are duplicate records in each of these
individual write buffers.
Default: 1
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.set_min_write_buffer_number(2);Sourcepub fn set_max_write_buffer_number(&mut self, nbuf: c_int)
pub fn set_max_write_buffer_number(&mut self, nbuf: c_int)
Sets the maximum number of write buffers that are built up in memory. The default and the minimum number is 2, so that when 1 write buffer is being flushed to storage, new writes can continue to the other write buffer. If max_write_buffer_number > 3, writing will be slowed down to options.delayed_write_rate if we are writing to the last write buffer allowed.
Default: 2
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.set_max_write_buffer_number(4);Sourcepub fn set_write_buffer_size(&mut self, size: usize)
pub fn set_write_buffer_size(&mut self, size: usize)
Sets the amount of data to build up in memory (backed by an unsorted log on disk) before converting to a sorted on-disk file.
Larger values increase performance, especially during bulk loads. Up to max_write_buffer_number write buffers may be held in memory at the same time, so you may wish to adjust this parameter to control memory usage. Also, a larger write buffer will result in a longer recovery time the next time the database is opened.
Note that write_buffer_size is enforced per column family. See db_write_buffer_size for sharing memory across column families.
Default: 0x4000000 (64MiB)
Dynamically changeable through SetOptions() API
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.set_write_buffer_size(128 * 1024 * 1024);Sourcepub fn set_db_write_buffer_size(&mut self, size: usize)
pub fn set_db_write_buffer_size(&mut self, size: usize)
Amount of data to build up in memtables across all column families before writing to disk.
This is distinct from write_buffer_size, which enforces a limit for a single memtable.
This feature is disabled by default. Specify a non-zero value to enable it.
Default: 0 (disabled)
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.set_db_write_buffer_size(128 * 1024 * 1024);Sourcepub fn set_max_bytes_for_level_base(&mut self, size: u64)
pub fn set_max_bytes_for_level_base(&mut self, size: u64)
Control maximum total data size for a level. max_bytes_for_level_base is the max total for level-1. Maximum number of bytes for level L can be calculated as (max_bytes_for_level_base) * (max_bytes_for_level_multiplier ^ (L-1)) For example, if max_bytes_for_level_base is 200MB, and if max_bytes_for_level_multiplier is 10, total data size for level-1 will be 200MB, total file size for level-2 will be 2GB, and total file size for level-3 will be 20GB.
Default: 0x10000000 (256MiB).
Dynamically changeable through SetOptions() API
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.set_max_bytes_for_level_base(512 * 1024 * 1024);Sourcepub fn set_max_bytes_for_level_multiplier(&mut self, mul: f64)
pub fn set_max_bytes_for_level_multiplier(&mut self, mul: f64)
Default: 10
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.set_max_bytes_for_level_multiplier(4.0);Sourcepub fn set_max_manifest_file_size(&mut self, size: usize)
pub fn set_max_manifest_file_size(&mut self, size: usize)
Sets a lower bound on the auto-tuned MANIFEST size limit. The MANIFEST is rolled over on reaching the limit and the older one is deleted.
This used to be a hard limit. RocksDB now auto-tunes the real limit and treats this as a minimum, so setting it small does not keep the MANIFEST small. Batches written in the foreground get a 25% higher limit.
Default: 1 GiB.
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.set_max_manifest_file_size(20 * 1024 * 1024);Sourcepub fn set_target_file_size_base(&mut self, size: u64)
pub fn set_target_file_size_base(&mut self, size: u64)
Sets the target file size for compaction. target_file_size_base is per-file size for level-1. Target file size for level L can be calculated by target_file_size_base * (target_file_size_multiplier ^ (L-1)) For example, if target_file_size_base is 2MB and target_file_size_multiplier is 10, then each file on level-1 will be 2MB, and each file on level 2 will be 20MB, and each file on level-3 will be 200MB.
Default: 0x4000000 (64MiB)
Dynamically changeable through SetOptions() API
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.set_target_file_size_base(128 * 1024 * 1024);Sourcepub fn set_min_write_buffer_number_to_merge(&mut self, to_merge: c_int)
pub fn set_min_write_buffer_number_to_merge(&mut self, to_merge: c_int)
Sets the minimum number of write buffers that will be merged together
before writing to storage. If set to 1, then
all write buffers are flushed to L0 as individual files and this increases
read amplification because a get request has to check in all of these
files. Also, an in-memory merge may result in writing lesser
data to storage if there are duplicate records in each of these
individual write buffers.
Default: 1
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.set_min_write_buffer_number_to_merge(2);Sourcepub fn set_level_zero_file_num_compaction_trigger(&mut self, n: c_int)
pub fn set_level_zero_file_num_compaction_trigger(&mut self, n: c_int)
Sets the number of files to trigger level-0 compaction. A value < 0 means that
level-0 compaction will not be triggered by number of files at all.
Default: 4
Dynamically changeable through SetOptions() API
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.set_level_zero_file_num_compaction_trigger(8);Sourcepub fn set_level_zero_slowdown_writes_trigger(&mut self, n: c_int)
pub fn set_level_zero_slowdown_writes_trigger(&mut self, n: c_int)
Sets the soft limit on number of level-0 files. We start slowing down writes at this
point. A value < 0 means that no writing slowdown will be triggered by
number of files in level-0.
Default: 20
Dynamically changeable through SetOptions() API
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.set_level_zero_slowdown_writes_trigger(10);Sourcepub fn set_level_zero_stop_writes_trigger(&mut self, n: c_int)
pub fn set_level_zero_stop_writes_trigger(&mut self, n: c_int)
Sets the maximum number of level-0 files. We stop writes at this point.
Default: 36
Dynamically changeable through SetOptions() API
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.set_level_zero_stop_writes_trigger(48);Sourcepub fn set_compaction_style(&mut self, style: DBCompactionStyle)
pub fn set_compaction_style(&mut self, style: DBCompactionStyle)
Sets the compaction style.
Default: DBCompactionStyle::Level
§Examples
use rust_rocksdb::{Options, DBCompactionStyle};
let mut opts = Options::default();
opts.set_compaction_style(DBCompactionStyle::Universal);Sourcepub fn get_compaction_style(&self) -> Option<DBCompactionStyle>
pub fn get_compaction_style(&self) -> Option<DBCompactionStyle>
The compaction style set by Self::set_compaction_style.
None means kCompactionStyleNone, which this crate does not name. That style turns
background compaction off entirely and only runs work submitted through
CompactFiles.
Sourcepub fn set_universal_compaction_options(
&mut self,
uco: &UniversalCompactOptions,
)
pub fn set_universal_compaction_options( &mut self, uco: &UniversalCompactOptions, )
Sets the options needed to support Universal Style compactions.
Sourcepub fn set_fifo_compaction_options(&mut self, fco: &FifoCompactOptions)
pub fn set_fifo_compaction_options(&mut self, fco: &FifoCompactOptions)
Sets the options for FIFO compaction style.
Sourcepub fn set_unordered_write(&mut self, unordered: bool)
pub fn set_unordered_write(&mut self, unordered: bool)
Sets unordered_write to true trades higher write throughput with relaxing the immutability guarantee of snapshots. This violates the repeatability one expects from ::Get from a snapshot, as well as ::MultiGet and Iterator’s consistent-point-in-time view property. If the application cannot tolerate the relaxed guarantees, it can implement its own mechanisms to work around that and yet benefit from the higher throughput. Using TransactionDB with WRITE_PREPARED write policy and two_write_queues=true is one way to achieve immutable snapshots despite unordered_write.
By default, i.e., when it is false, rocksdb does not advance the sequence number for new snapshots unless all the writes with lower sequence numbers are already finished. This provides the immutability that we expect from snapshots. Moreover, since Iterator and MultiGet internally depend on snapshots, the snapshot immutability results into Iterator and MultiGet offering consistent-point-in-time view. If set to true, although Read-Your-Own-Write property is still provided, the snapshot immutability property is relaxed: the writes issued after the snapshot is obtained (with larger sequence numbers) will be still not visible to the reads from that snapshot, however, there still might be pending writes (with lower sequence number) that will change the state visible to the snapshot after they are landed to the memtable.
Default: false
Sourcepub fn set_max_subcompactions(&mut self, num: u32)
pub fn set_max_subcompactions(&mut self, num: u32)
Sets maximum number of threads that will concurrently perform a compaction job by breaking it into multiple, smaller ones that are run simultaneously.
Default: 1 (i.e. no subcompactions)
Sourcepub fn set_max_background_jobs(&mut self, jobs: c_int)
pub fn set_max_background_jobs(&mut self, jobs: c_int)
Sets maximum number of concurrent background jobs (compactions and flushes).
Default: 2
Dynamically changeable through SetDBOptions() API.
Sourcepub fn set_max_background_compactions(&mut self, n: c_int)
👎Deprecated since 0.15.0: RocksDB automatically decides this based on the value of max_background_jobs
pub fn set_max_background_compactions(&mut self, n: c_int)
RocksDB automatically decides this based on the value of max_background_jobs
Sets the maximum number of concurrent background compaction jobs, submitted to
the default LOW priority thread pool.
We first try to schedule compactions based on
base_background_compactions. If the compaction cannot catch up , we
will increase number of compaction threads up to
max_background_compactions.
If you’re increasing this, also consider increasing number of threads in LOW priority thread pool. For more information, see Env::SetBackgroundThreads
Default: -1, meaning RocksDB derives it from max_background_jobs.
Setting either this or max_background_flushes opts into the old
behaviour, where the unset one of the pair counts as 1.
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
#[allow(deprecated)]
opts.set_max_background_compactions(2);Sourcepub fn get_max_background_compactions(&self) -> c_int
pub fn get_max_background_compactions(&self) -> c_int
The raw max_background_compactions field, -1 while it is unset.
Deprecated upstream in favour of max_background_jobs, so this is the value someone
passed to Self::set_max_background_compactions, not the concurrency RocksDB will
actually run. While it is -1 the real limit comes from
Self::get_max_background_jobs, unless max_background_flushes is set, in which
case this half of the pair counts as 1. RocksDB resolves that on a copy when the DB
opens and never writes it back here.
Sourcepub fn set_max_background_flushes(&mut self, n: c_int)
👎Deprecated since 0.15.0: RocksDB automatically decides this based on the value of max_background_jobs
pub fn set_max_background_flushes(&mut self, n: c_int)
RocksDB automatically decides this based on the value of max_background_jobs
Sets the maximum number of concurrent background memtable flush jobs, submitted to the HIGH priority thread pool.
By default, all background jobs (major compaction and memtable flush) go to the LOW priority pool. If this option is set to a positive number, memtable flush jobs will be submitted to the HIGH priority pool. It is important when the same Env is shared by multiple db instances. Without a separate pool, long running major compaction jobs could potentially block memtable flush jobs of other db instances, leading to unnecessary Put stalls.
If you’re increasing this, also consider increasing number of threads in HIGH priority thread pool. For more information, see Env::SetBackgroundThreads
Default: -1, meaning RocksDB derives it from max_background_jobs.
Setting either this or max_background_compactions opts into the old
behaviour, where the unset one of the pair counts as 1.
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
#[allow(deprecated)]
opts.set_max_background_flushes(2);Sourcepub fn get_max_background_flushes(&self) -> c_int
pub fn get_max_background_flushes(&self) -> c_int
The raw max_background_flushes field, -1 while it is unset.
Deprecated upstream in favour of max_background_jobs, so this is the value someone
passed to Self::set_max_background_flushes, not the concurrency RocksDB will
actually run. While it is -1 the real limit comes from
Self::get_max_background_jobs, unless max_background_compactions is set, in
which case this half of the pair counts as 1. RocksDB resolves that on a copy when
the DB opens and never writes it back here.
Sourcepub fn set_disable_auto_compactions(&mut self, disable: bool)
pub fn set_disable_auto_compactions(&mut self, disable: bool)
Disables automatic compactions. Manual compactions can still be issued on this column family
Default: false
Dynamically changeable through SetOptions() API
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.set_disable_auto_compactions(true);Sourcepub fn set_memtable_huge_page_size(&mut self, size: size_t)
pub fn set_memtable_huge_page_size(&mut self, size: size_t)
SetMemtableHugePageSize sets the page size for huge page for arena used by the memtable. If <=0, it won’t allocate from huge page but from malloc. Users are responsible to reserve huge pages for it to be allocated. For example: sysctl -w vm.nr_hugepages=20 See linux doc Documentation/vm/hugetlbpage.txt If there isn’t enough free huge page available, it will fall back to malloc.
Dynamically changeable through SetOptions() API
Sourcepub fn set_memtable_batch_lookup_optimization(&mut self, enable: bool)
pub fn set_memtable_batch_lookup_optimization(&mut self, enable: bool)
Enables the skip-list memtable’s batch-lookup optimization for
MultiGet.
When enabled, the search path is cached between consecutive keys in a
MultiGet, reducing per-key cost from O(log N) to O(log d) where
d is the distance between consecutive keys. The optimization
exploits the fact that MultiGet keys are sorted.
Applies only to the default skip-list memtable (the one used when no
memtable factory is set via Self::set_memtable_factory). The
MemtableFactory::Vector, HashSkipList, and HashLinkList variants
all fall back to per-key lookups regardless of this flag.
This option is immutable on the C++ side: it must be set before the
column family is opened and cannot be changed via SetOptions.
Default: false
Sourcepub fn get_memtable_batch_lookup_optimization(&self) -> bool
pub fn get_memtable_batch_lookup_optimization(&self) -> bool
Returns the current value of
Self::set_memtable_batch_lookup_optimization.
Provided primarily for tests that want to confirm the setter is wired
through to the underlying C++ AdvancedColumnFamilyOptions.
Sourcepub fn set_max_successive_merges(&mut self, num: usize)
pub fn set_max_successive_merges(&mut self, num: usize)
Sets the maximum number of successive merge operations on a key in the memtable.
When a merge operation is added to the memtable and the maximum number of successive merges is reached, the value of the key will be calculated and inserted into the memtable instead of the merge operation. This will ensure that there are never more than max_successive_merges merge operations in the memtable.
Default: 0 (disabled)
Sourcepub fn set_bloom_locality(&mut self, v: u32)
pub fn set_bloom_locality(&mut self, v: u32)
Control locality of bloom filter probes to improve cache miss rate. This option only applies to memtable prefix bloom and plaintable prefix bloom. It essentially limits the max number of cache lines each bloom filter check can touch.
This optimization is turned off when set to 0. The number should never be greater than number of probes. This option can boost performance for in-memory workload but should use with care since it can cause higher false positive rate.
Default: 0
Sourcepub fn set_inplace_update_support(&mut self, enabled: bool)
pub fn set_inplace_update_support(&mut self, enabled: bool)
Enable/disable thread-safe inplace updates.
Requires updates if
- key exists in current memtable
- new sizeof(new_value) <= sizeof(old_value)
- old_value for that key is a put i.e. kTypeValue
Default: false.
Sourcepub fn set_inplace_update_locks(&mut self, num: usize)
pub fn set_inplace_update_locks(&mut self, num: usize)
Sets the number of locks used for inplace update.
Default: 10000 when inplace_update_support = true, otherwise 0.
Sourcepub fn set_max_bytes_for_level_multiplier_additional(
&mut self,
level_values: &[i32],
)
pub fn set_max_bytes_for_level_multiplier_additional( &mut self, level_values: &[i32], )
Different max-size multipliers for different levels. These are multiplied by max_bytes_for_level_multiplier to arrive at the max-size of each level.
Default: 1
Dynamically changeable through SetOptions() API
Sourcepub fn set_max_write_buffer_size_to_maintain(&mut self, size: i64)
pub fn set_max_write_buffer_size_to_maintain(&mut self, size: i64)
The total maximum size(bytes) of write buffers to maintain in memory including copies of buffers that have already been flushed. This parameter only affects trimming of flushed buffers and does not affect flushing. This controls the maximum amount of write history that will be available in memory for conflict checking when Transactions are used. The actual size of write history (flushed Memtables) might be higher than this limit if further trimming will reduce write history total size below this limit. For example, if max_write_buffer_size_to_maintain is set to 64MB, and there are three flushed Memtables, with sizes of 32MB, 20MB, 20MB. Because trimming the next Memtable of size 20MB will reduce total memory usage to 52MB which is below the limit, RocksDB will stop trimming.
When using an OptimisticTransactionDB: If this value is too low, some transactions may fail at commit time due to not being able to determine whether there were any write conflicts.
When using a TransactionDB: If Transaction::SetSnapshot is used, TransactionDB will read either in-memory write buffers or SST files to do write-conflict checking. Increasing this value can reduce the number of reads to SST files done for conflict detection.
Setting this value to 0 will cause write buffers to be freed immediately after they are flushed. If this value is set to -1, ‘max_write_buffer_number * write_buffer_size’ will be used.
Default: If using a TransactionDB/OptimisticTransactionDB, the default value will be set to the value of ‘max_write_buffer_number * write_buffer_size’ if it is not explicitly set by the user. Otherwise, the default is 0.
Sourcepub fn set_enable_pipelined_write(&mut self, value: bool)
pub fn set_enable_pipelined_write(&mut self, value: bool)
By default, a single write thread queue is maintained. The thread gets to the head of the queue becomes write batch group leader and responsible for writing to WAL and memtable for the batch group.
If enable_pipelined_write is true, separate write thread queue is maintained for WAL write and memtable write. A write thread first enter WAL writer queue and then memtable writer queue. Pending thread on the WAL writer queue thus only have to wait for previous writers to finish their WAL writing but not the memtable writing. Enabling the feature may improve write throughput and reduce latency of the prepare phase of two-phase commit.
Default: false
Sourcepub fn set_memtable_factory(&mut self, factory: MemtableFactory)
pub fn set_memtable_factory(&mut self, factory: MemtableFactory)
Defines the underlying memtable implementation. See official wiki for more information. Defaults to using a skiplist.
§Examples
use rust_rocksdb::{Options, MemtableFactory};
let mut opts = Options::default();
let factory = MemtableFactory::HashSkipList {
bucket_count: 1_000_000,
height: 4,
branching_factor: 4,
};
opts.set_allow_concurrent_memtable_write(false);
opts.set_memtable_factory(factory);pub fn set_block_based_table_factory(&mut self, factory: &BlockBasedOptions)
Sourcepub fn set_cuckoo_table_factory(&mut self, factory: &CuckooTableOptions)
pub fn set_cuckoo_table_factory(&mut self, factory: &CuckooTableOptions)
Sets the table factory to a CuckooTableFactory (the default table factory is a block-based table factory that provides a default implementation of TableBuilder and TableReader with default BlockBasedTableOptions). See official wiki for more information on this table format.
§Examples
use rust_rocksdb::{Options, CuckooTableOptions};
let mut opts = Options::default();
let mut factory_opts = CuckooTableOptions::default();
factory_opts.set_hash_ratio(0.8);
factory_opts.set_max_search_depth(20);
factory_opts.set_cuckoo_block_size(10);
factory_opts.set_identity_as_first_hash(true);
factory_opts.set_use_module_hash(false);
opts.set_cuckoo_table_factory(&factory_opts);Sourcepub fn set_plain_table_factory(&mut self, options: &PlainTableFactoryOptions)
pub fn set_plain_table_factory(&mut self, options: &PlainTableFactoryOptions)
Sets the factory as plain table. See official wiki for more information.
§Examples
use rust_rocksdb::{KeyEncodingType, Options, PlainTableFactoryOptions};
let mut opts = Options::default();
let factory_opts = PlainTableFactoryOptions {
user_key_length: 0,
bloom_bits_per_key: 20,
hash_table_ratio: 0.75,
index_sparseness: 16,
huge_page_tlb_size: 0,
encoding_type: KeyEncodingType::Plain,
full_scan_mode: false,
store_index_in_file: false,
};
opts.set_plain_table_factory(&factory_opts);Sourcepub fn set_min_level_to_compress(&mut self, lvl: c_int)
pub fn set_min_level_to_compress(&mut self, lvl: c_int)
Sets the start level to use compression.
Sourcepub fn set_report_bg_io_stats(&mut self, enable: bool)
pub fn set_report_bg_io_stats(&mut self, enable: bool)
Measure IO stats in compactions and flushes, if true.
Default: false
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.set_report_bg_io_stats(true);Sourcepub fn set_max_total_wal_size(&mut self, size: u64)
pub fn set_max_total_wal_size(&mut self, size: u64)
Once write-ahead logs exceed this size, we will start forcing the flush of column families whose memtables are backed by the oldest live WAL file (i.e. the ones that are causing all the space amplification).
Default: 0
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
// Set max total wal size to 1G.
opts.set_max_total_wal_size(1 << 30);Sourcepub fn set_wal_recovery_mode(&mut self, mode: DBRecoveryMode)
pub fn set_wal_recovery_mode(&mut self, mode: DBRecoveryMode)
Recovery mode to control the consistency while replaying WAL.
Default: DBRecoveryMode::PointInTime
§Examples
use rust_rocksdb::{Options, DBRecoveryMode};
let mut opts = Options::default();
opts.set_wal_recovery_mode(DBRecoveryMode::AbsoluteConsistency);Sourcepub fn get_wal_recovery_mode(&self) -> Option<DBRecoveryMode>
pub fn get_wal_recovery_mode(&self) -> Option<DBRecoveryMode>
The recovery mode set by Self::set_wal_recovery_mode.
DBRecoveryMode covers every mode RocksDB defines today, so None only shows up if
a future release adds one.
Sourcepub fn enable_statistics(&mut self)
pub fn enable_statistics(&mut self)
Enables recording RocksDB statistics.
The statistics in this Options object are shared between all DB instances.
See get_statistics, get_ticker_count,
and get_histogram_data.
Sourcepub fn get_statistics(&self) -> Option<String>
pub fn get_statistics(&self) -> Option<String>
Returns a string containing RocksDB statistics if enabled using
enable_statistics.
Sourcepub fn set_statistics_level(&self, level: StatsLevel)
pub fn set_statistics_level(&self, level: StatsLevel)
StatsLevel can be used to reduce statistics overhead by skipping certain types of stats in the stats collection process.
Only takes effect if stats are enabled first using
enable_statistics.
Sourcepub fn get_statistics_level(&self) -> Option<StatsLevel>
pub fn get_statistics_level(&self) -> Option<StatsLevel>
The level set by Self::set_statistics_level.
Reports StatsLevel::DisableAll when statistics were never enabled,
because that is what the C API returns with no statistics object attached.
Returns None for a value this crate has no variant for, which should not
happen: RocksDB clamps the level into range on the way in.
Sourcepub fn get_ticker_count(&self, ticker: Ticker) -> u64
pub fn get_ticker_count(&self, ticker: Ticker) -> u64
Returns a counter if statistics are enabled using
enable_statistics.
Sourcepub fn get_histogram_data(&self, histogram: Histogram) -> HistogramData
pub fn get_histogram_data(&self, histogram: Histogram) -> HistogramData
Returns a histogram if statistics are enabled using
enable_statistics.
Sourcepub fn set_stats_dump_period_sec(&mut self, period: c_uint)
pub fn set_stats_dump_period_sec(&mut self, period: c_uint)
If not zero, dump rocksdb.stats to LOG every stats_dump_period_sec.
Default: 600 (10 mins)
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.set_stats_dump_period_sec(300);Sourcepub fn set_stats_persist_period_sec(&mut self, period: c_uint)
pub fn set_stats_persist_period_sec(&mut self, period: c_uint)
If not zero, dump rocksdb.stats to RocksDB to LOG every stats_persist_period_sec.
Default: 600 (10 mins)
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.set_stats_persist_period_sec(5);Sourcepub fn set_advise_random_on_open(&mut self, advise: bool)
pub fn set_advise_random_on_open(&mut self, advise: bool)
When set to true, reading SST files will opt out of the filesystem’s readahead. Setting this to false may improve sequential iteration performance.
Default: true
Sourcepub fn set_use_adaptive_mutex(&mut self, enabled: bool)
pub fn set_use_adaptive_mutex(&mut self, enabled: bool)
Enable/disable adaptive mutex, which spins in the user space before resorting to kernel.
This could reduce context switch when the mutex is not heavily contended. However, if the mutex is hot, we could end up wasting spin time.
Default: false
Sourcepub fn set_num_levels(&mut self, n: c_int)
pub fn set_num_levels(&mut self, n: c_int)
Sets the number of levels for this database.
Sourcepub fn set_memtable_prefix_bloom_ratio(&mut self, ratio: f64)
pub fn set_memtable_prefix_bloom_ratio(&mut self, ratio: f64)
When a prefix_extractor is defined through opts.set_prefix_extractor this
creates a prefix bloom filter for each memtable with the size of
write_buffer_size * memtable_prefix_bloom_ratio (capped at 0.25).
Default: 0
§Examples
use rust_rocksdb::{Options, SliceTransform};
let mut opts = Options::default();
let transform = SliceTransform::create_fixed_prefix(10);
opts.set_prefix_extractor(transform);
opts.set_memtable_prefix_bloom_ratio(0.2);Sourcepub fn set_max_compaction_bytes(&mut self, nbytes: u64)
pub fn set_max_compaction_bytes(&mut self, nbytes: u64)
Sets the maximum number of bytes in all compacted files. We try to limit number of bytes in one compaction to be lower than this threshold. But it’s not guaranteed.
Value 0 will be sanitized.
Default: target_file_size_base * 25
Sourcepub fn set_wal_dir<P: AsRef<Path>>(&mut self, path: P)
pub fn set_wal_dir<P: AsRef<Path>>(&mut self, path: P)
Specifies the absolute path of the directory the write-ahead log (WAL) should be written to.
Default: same directory as the database
§Examples
use rust_rocksdb::Options;
let mut opts = Options::default();
opts.set_wal_dir("/path/to/dir");Sourcepub fn get_wal_dir(&self) -> String
pub fn get_wal_dir(&self) -> String
The WAL directory set by Self::set_wal_dir, empty when the WAL lives with the data.
Sourcepub fn set_wal_ttl_seconds(&mut self, secs: u64)
pub fn set_wal_ttl_seconds(&mut self, secs: u64)
Sets the WAL ttl in seconds.
The following two options affect how archived logs will be deleted.
- If both set to 0, logs will be deleted asap and will not get into the archive.
- If wal_ttl_seconds is 0 and wal_size_limit_mb is not 0, WAL files will be checked every 10 min and if total size is greater then wal_size_limit_mb, they will be deleted starting with the earliest until size_limit is met. All empty files will be deleted.
- If wal_ttl_seconds is not 0 and wall_size_limit_mb is 0, then WAL files will be checked every wal_ttl_seconds / 2 and those that are older than wal_ttl_seconds will be deleted.
- If both are not 0, WAL files will be checked every 10 min and both checks will be performed with ttl being first.
Default: 0
Sourcepub fn set_wal_size_limit_mb(&mut self, size: u64)
pub fn set_wal_size_limit_mb(&mut self, size: u64)
Sets the WAL size limit in MB.
If total size of WAL files is greater then wal_size_limit_mb, they will be deleted starting with the earliest until size_limit is met.
Default: 0
Sourcepub fn set_manifest_preallocation_size(&mut self, size: usize)
pub fn set_manifest_preallocation_size(&mut self, size: usize)
Sets the number of bytes to preallocate (via fallocate) the manifest files.
Default is 4MB, which is reasonable to reduce random IO as well as prevent overallocation for mounts that preallocate large amounts of data (such as xfs’s allocsize option).
Sourcepub fn set_skip_stats_update_on_db_open(&mut self, skip: bool)
pub fn set_skip_stats_update_on_db_open(&mut self, skip: bool)
If true, then DB::Open() will not update the statistics used to optimize compaction decision by loading table properties from many files. Turning off this feature will improve DBOpen time especially in disk environment.
Default: false
Sourcepub fn set_open_files_async(&mut self, enabled: bool) -> Result<(), Error>
pub fn set_open_files_async(&mut self, enabled: bool) -> Result<(), Error>
Controls whether RocksDB opens and validates SST files in the background after open.
Enabling this can reduce open latency for databases with many SST files
or high latency storage. It is mostly useful with
Options::set_max_open_files set to -1.
This option is not compatible with FIFO compaction and requires
Options::set_skip_stats_update_on_db_open to be true. SST open
errors are no longer returned by DB::open; they can instead surface as
background errors or from operations that access the affected file.
Default: false
Sourcepub fn get_open_files_async(&self) -> bool
pub fn get_open_files_async(&self) -> bool
Returns whether SST files are opened and validated in the background after open.
Sourcepub fn supports_open_files_async() -> bool
pub fn supports_open_files_async() -> bool
Returns whether the linked RocksDB supports open_files_async.
Sourcepub fn set_keep_log_file_num(&mut self, nfiles: usize)
pub fn set_keep_log_file_num(&mut self, nfiles: usize)
Specify the maximal number of info log files to be kept.
Default: 1000
§Examples
use rust_rocksdb::Options;
let mut options = Options::default();
options.set_keep_log_file_num(100);Sourcepub fn set_allow_mmap_writes(&mut self, is_enabled: bool)
pub fn set_allow_mmap_writes(&mut self, is_enabled: bool)
Allow the OS to mmap file for writing.
Default: false
§Examples
use rust_rocksdb::Options;
let mut options = Options::default();
options.set_allow_mmap_writes(true);Sourcepub fn set_allow_mmap_reads(&mut self, is_enabled: bool)
pub fn set_allow_mmap_reads(&mut self, is_enabled: bool)
Allow the OS to mmap file for reading sst tables.
Default: false
§Examples
use rust_rocksdb::Options;
let mut options = Options::default();
options.set_allow_mmap_reads(true);Sourcepub fn set_manual_wal_flush(&mut self, is_enabled: bool)
pub fn set_manual_wal_flush(&mut self, is_enabled: bool)
If enabled, WAL is not flushed automatically after each write. Instead it
relies on manual invocation of DB::flush_wal() to write the WAL buffer
to its file.
Default: false
§Examples
use rust_rocksdb::Options;
let mut options = Options::default();
options.set_manual_wal_flush(true);Sourcepub fn set_atomic_flush(&mut self, atomic_flush: bool)
pub fn set_atomic_flush(&mut self, atomic_flush: bool)
Guarantee that all column families are flushed together atomically.
This option applies to both manual flushes (db.flush()) and automatic
background flushes caused when memtables are filled.
Note that this is only useful when the WAL is disabled. When using the WAL, writes are always consistent across column families.
Default: false
§Examples
use rust_rocksdb::Options;
let mut options = Options::default();
options.set_atomic_flush(true);Sourcepub fn set_row_cache(&mut self, cache: &Cache)
pub fn set_row_cache(&mut self, cache: &Cache)
Sets global cache for table-level rows.
Default: null (disabled) Not supported in ROCKSDB_LITE mode!
Sourcepub fn set_ratelimiter(
&mut self,
rate_bytes_per_sec: i64,
refill_period_us: i64,
fairness: i32,
)
pub fn set_ratelimiter( &mut self, rate_bytes_per_sec: i64, refill_period_us: i64, fairness: i32, )
Use to control write rate of flush and compaction. Flush has higher priority than compaction. If rate limiter is enabled, bytes_per_sync is set to 1MB by default.
Default: disable
§Examples
use rust_rocksdb::Options;
let mut options = Options::default();
options.set_ratelimiter(1024 * 1024, 100 * 1000, 10);Sourcepub fn set_auto_tuned_ratelimiter(
&mut self,
rate_bytes_per_sec: i64,
refill_period_us: i64,
fairness: i32,
)
pub fn set_auto_tuned_ratelimiter( &mut self, rate_bytes_per_sec: i64, refill_period_us: i64, fairness: i32, )
Use to control write rate of flush and compaction. Flush has higher priority than compaction. If rate limiter is enabled, bytes_per_sync is set to 1MB by default.
Default: disable
Sourcepub fn set_ratelimiter_with_mode(
&mut self,
rate_bytes_per_sec: i64,
refill_period_us: i64,
fairness: i32,
mode: RateLimiterMode,
auto_tuned: bool,
)
pub fn set_ratelimiter_with_mode( &mut self, rate_bytes_per_sec: i64, refill_period_us: i64, fairness: i32, mode: RateLimiterMode, auto_tuned: bool, )
Create a RateLimiter object, which can be shared among RocksDB instances to control write rate of flush and compaction.
rate_bytes_per_sec: this is the only parameter you want to set most of the time. It controls the total write rate of compaction and flush in bytes per second. Currently, RocksDB does not enforce rate limit for anything other than flush and compaction, e.g. write to WAL.
refill_period_us: this controls how often tokens are refilled. For example, when rate_bytes_per_sec is set to 10MB/s and refill_period_us is set to 100ms, then 1MB is refilled every 100ms internally. Larger value can lead to burstier writes while smaller value introduces more CPU overhead. The default should work for most cases.
fairness: RateLimiter accepts high-pri requests and low-pri requests. A low-pri request is usually blocked in favor of hi-pri request. Currently, RocksDB assigns low-pri to request from compaction and high-pri to request from flush. Low-pri requests can get blocked if flush requests come in continuously. This fairness parameter grants low-pri requests permission by 1/fairness chance even though high-pri requests exist to avoid starvation. You should be good by leaving it at default 10.
mode: Mode indicates which types of operations count against the limit.
auto_tuned: Enables dynamic adjustment of rate limit within the range
[rate_bytes_per_sec / 20, rate_bytes_per_sec], according to
the recent demand for background I/O.
Sourcepub fn set_max_log_file_size(&mut self, size: usize)
pub fn set_max_log_file_size(&mut self, size: usize)
Sets the maximal size of the info log file.
If the log file is larger than max_log_file_size, a new info log file
will be created. If max_log_file_size is equal to zero, all logs will
be written to one log file.
Default: 0
§Examples
use rust_rocksdb::Options;
let mut options = Options::default();
options.set_max_log_file_size(0);Sourcepub fn set_log_file_time_to_roll(&mut self, secs: usize)
pub fn set_log_file_time_to_roll(&mut self, secs: usize)
Sets the time for the info log file to roll (in seconds).
If specified with non-zero value, log file will be rolled
if it has been active longer than log_file_time_to_roll.
Default: 0 (disabled)
Sourcepub fn set_recycle_log_file_num(&mut self, num: usize)
pub fn set_recycle_log_file_num(&mut self, num: usize)
Controls the recycling of log files.
If non-zero, previously written log files will be reused for new logs, overwriting the old data. The value indicates how many such files we will keep around at any point in time for later use. This is more efficient because the blocks are already allocated and fdatasync does not need to update the inode after each write.
Default: 0
§Examples
use rust_rocksdb::Options;
let mut options = Options::default();
options.set_recycle_log_file_num(5);Sourcepub fn set_stderr_logger(&mut self, log_level: LogLevel, prefix: impl CStrLike)
pub fn set_stderr_logger(&mut self, log_level: LogLevel, prefix: impl CStrLike)
Prints logs to stderr for faster debugging See official wiki for more information.
Sourcepub fn set_callback_logger(
&mut self,
log_level: LogLevel,
callback: impl Fn(LogLevel, &str) + 'static + Send + Sync,
)
pub fn set_callback_logger( &mut self, log_level: LogLevel, callback: impl Fn(LogLevel, &str) + 'static + Send + Sync, )
Invokes callback with RocksDB log messages with level >= log_level.
The callback can be called concurrently by multiple RocksDB threads.
§Examples
use rust_rocksdb::{LogLevel, Options};
let mut options = Options::default();
options.set_callback_logger(LogLevel::Debug, move |level, msg| println!("{level:?} {msg}"));Sourcepub fn set_soft_pending_compaction_bytes_limit(&mut self, limit: usize)
pub fn set_soft_pending_compaction_bytes_limit(&mut self, limit: usize)
Sets the threshold at which all writes will be slowed down to at least delayed_write_rate if estimated bytes needed to be compaction exceed this threshold.
Default: 64GB
Sourcepub fn set_hard_pending_compaction_bytes_limit(&mut self, limit: usize)
pub fn set_hard_pending_compaction_bytes_limit(&mut self, limit: usize)
Sets the bytes threshold at which all writes are stopped if estimated bytes needed to be compaction exceed this threshold.
Default: 256GB
Sourcepub fn set_arena_block_size(&mut self, size: usize)
pub fn set_arena_block_size(&mut self, size: usize)
Sets the size of one block in arena memory allocation.
If <= 0, a proper value is automatically calculated (usually 1/10 of writer_buffer_size).
Default: 0
Sourcepub fn set_dump_malloc_stats(&mut self, enabled: bool)
pub fn set_dump_malloc_stats(&mut self, enabled: bool)
If true, then print malloc stats together with rocksdb.stats when printing to LOG.
Default: false
Sourcepub fn set_memtable_whole_key_filtering(&mut self, whole_key_filter: bool)
pub fn set_memtable_whole_key_filtering(&mut self, whole_key_filter: bool)
Enable whole key bloom filter in memtable. Note this will only take effect if memtable_prefix_bloom_size_ratio is not 0. Enabling whole key filtering can potentially reduce CPU usage for point-look-ups.
Default: false (disable)
Dynamically changeable through SetOptions() API
Sourcepub fn set_enable_blob_files(&mut self, val: bool)
pub fn set_enable_blob_files(&mut self, val: bool)
Enable the use of key-value separation.
More details can be found here: Integrated BlobDB.
Default: false (disable)
Dynamically changeable through SetOptions() API
Sourcepub fn set_min_blob_size(&mut self, val: u64)
pub fn set_min_blob_size(&mut self, val: u64)
Sets the minimum threshold value at or above which will be written to blob files during flush or compaction.
Dynamically changeable through SetOptions() API
Sourcepub fn set_blob_file_size(&mut self, val: u64)
pub fn set_blob_file_size(&mut self, val: u64)
Sets the size limit for blob files.
Dynamically changeable through SetOptions() API
Sourcepub fn set_blob_compression_type(&mut self, val: DBCompressionType)
pub fn set_blob_compression_type(&mut self, val: DBCompressionType)
Sets the blob compression type. All blob files use the same compression type.
Dynamically changeable through SetOptions() API
Sourcepub fn get_blob_compression_type(&self) -> Option<DBCompressionType>
pub fn get_blob_compression_type(&self) -> Option<DBCompressionType>
The compression algorithm used for blob files.
None covers a compression type this crate does not name.
Sourcepub fn set_enable_blob_gc(&mut self, val: bool)
pub fn set_enable_blob_gc(&mut self, val: bool)
If this is set to true RocksDB will actively relocate valid blobs from the oldest blob files as they are encountered during compaction.
Dynamically changeable through SetOptions() API
Sourcepub fn set_blob_gc_age_cutoff(&mut self, val: c_double)
pub fn set_blob_gc_age_cutoff(&mut self, val: c_double)
Sets the threshold that the GC logic uses to determine which blob files should be considered “old.”
For example, the default value of 0.25 signals to RocksDB that blobs residing in the oldest 25% of blob files should be relocated by GC. This parameter can be tuned to adjust the trade-off between write amplification and space amplification.
Dynamically changeable through SetOptions() API
Sourcepub fn set_blob_gc_force_threshold(&mut self, val: c_double)
pub fn set_blob_gc_force_threshold(&mut self, val: c_double)
Sets the blob GC force threshold.
Dynamically changeable through SetOptions() API
Sourcepub fn set_blob_compaction_readahead_size(&mut self, val: u64)
pub fn set_blob_compaction_readahead_size(&mut self, val: u64)
Sets the blob compaction read ahead size.
Dynamically changeable through SetOptions() API
Sourcepub fn set_blob_cache(&mut self, cache: &Cache)
pub fn set_blob_cache(&mut self, cache: &Cache)
Sets the blob cache.
Using a dedicated object for blobs and using the same object for the block and blob caches are both supported. In the latter case, note that blobs are less valuable from a caching perspective than SST blocks, and some cache implementations have configuration options that can be used to prioritize items accordingly (see Cache::Priority and LRUCacheOptions::{high,low}_pri_pool_ratio).
Default: disabled
Sourcepub fn set_prepopulate_blob_cache(&mut self, val: PrepopulateBlobCache)
pub fn set_prepopulate_blob_cache(&mut self, val: PrepopulateBlobCache)
Whether newly written blobs go straight into the blob cache.
PrepopulateBlobCache::FlushOnly pays off when reading a blob back is expensive,
with direct I/O or remote storage, or when the workload has strong temporal locality.
It needs Self::set_blob_cache to have been called to have any effect.
Default: PrepopulateBlobCache::Disable
Dynamically changeable through SetOptions() API
Sourcepub fn get_prepopulate_blob_cache(&self) -> Option<PrepopulateBlobCache>
pub fn get_prepopulate_blob_cache(&self) -> Option<PrepopulateBlobCache>
The setting from Self::set_prepopulate_blob_cache.
None covers a value this crate does not name, which RocksDB has none of today.
Sourcepub fn set_allow_ingest_behind(&mut self, val: bool)
pub fn set_allow_ingest_behind(&mut self, val: bool)
Set this option to true during creation of database if you want to be able to ingest behind (call IngestExternalFile() skipping keys that already exist, rather than overwriting matching keys). Setting this option to true has the following effects:
- Disable some internal optimizations around SST file compression.
- Reserve the last level for ingested files only.
- Compaction will not include any file from the last level.
Note that only Universal Compaction supports allow_ingest_behind.
num_levels should be >= 3 if this option is turned on.
DEFAULT: false Immutable.
pub fn add_compact_on_deletion_collector_factory( &mut self, window_size: size_t, num_dels_trigger: size_t, deletion_ratio: f64, )
Sourcepub fn add_compact_on_deletion_collector_factory_count_only(
&mut self,
window_size: size_t,
num_dels_trigger: size_t,
)
pub fn add_compact_on_deletion_collector_factory_count_only( &mut self, window_size: size_t, num_dels_trigger: size_t, )
Like Self::add_compact_on_deletion_collector_factory, but with the ratio trigger
off, so a file is only marked once num_dels_trigger deletions land inside a window
of window_size consecutive entries.
window_size is rounded up to a multiple of 128. num_dels_trigger is used as given
and is not rescaled when window_size changes.
This appends another collector factory to the column family’s list, it does not replace the ones already there. Calling it twice registers the collector twice.
Sourcepub fn add_compact_on_deletion_collector_factory_min_file_size(
&mut self,
window_size: size_t,
num_dels_trigger: size_t,
deletion_ratio: f64,
min_file_size: u64,
)
pub fn add_compact_on_deletion_collector_factory_min_file_size( &mut self, window_size: size_t, num_dels_trigger: size_t, deletion_ratio: f64, min_file_size: u64, )
Like Self::add_compact_on_deletion_collector_factory, but only triggers
compaction if the SST file size is at least min_file_size bytes.
Sourcepub fn set_write_buffer_manager(
&mut self,
write_buffer_manager: &WriteBufferManager,
)
pub fn set_write_buffer_manager( &mut self, write_buffer_manager: &WriteBufferManager, )
https://github.com/facebook/rocksdb/wiki/Write-Buffer-Manager Write buffer manager helps users control the total memory used by memtables across multiple column families and/or DB instances. Users can enable this control by 2 ways:
1- Limit the total memtable usage across multiple column families and DBs under a threshold. 2- Cost the memtable memory usage to block cache so that memory of RocksDB can be capped by the single limit. The usage of a write buffer manager is similar to rate_limiter and sst_file_manager. Users can create one write buffer manager object and pass it to all the options of column families or DBs whose memtable size they want to be controlled by this object.
Sourcepub fn set_sst_file_manager(&mut self, sst_file_manager: &SstFileManager)
pub fn set_sst_file_manager(&mut self, sst_file_manager: &SstFileManager)
Sets an SstFileManager for this Options.
SstFileManager tracks and controls total SST file space usage, enabling applications to cap disk utilization and throttle deletions.
Sourcepub fn set_avoid_unnecessary_blocking_io(&mut self, val: bool)
pub fn set_avoid_unnecessary_blocking_io(&mut self, val: bool)
If true, working thread may avoid doing unnecessary and long-latency operation (such as deleting obsolete files directly or deleting memtable) and will instead schedule a background job to do it.
Use it if you’re latency-sensitive.
Default: false (disabled)
Sourcepub fn set_experimental_mempurge_threshold(&mut self, threshold: f64)
pub fn set_experimental_mempurge_threshold(&mut self, threshold: f64)
Activates the experimental Mempurge memtable garbage collection feature.
See the upstream RocksDB option documentation: https://github.com/facebook/rocksdb/blob/v10.7.5/include/rocksdb/advanced_options.h#L259-L274
At every flush, RocksDB estimates the useful payload ratio of the memtable and compares it with this threshold. If the ratio is below the threshold, RocksDB replaces the regular flush with a mempurge operation.
Threshold values:
0.0: mempurge deactivated.1.0: recommended threshold value.> 1.0: aggressive mempurge.0.0 < threshold < 1.0: mempurge only for very low useful payload ratios.
Default: 0.0
Sourcepub fn set_compaction_pri(&mut self, pri: DBCompactionPri)
pub fn set_compaction_pri(&mut self, pri: DBCompactionPri)
Sets the compaction priority.
If level compaction_style = kCompactionStyleLevel, for each level, which files are prioritized to be picked to compact.
Default: DBCompactionPri::MinOverlappingRatio
§Examples
use rust_rocksdb::{Options, DBCompactionPri};
let mut opts = Options::default();
opts.set_compaction_pri(DBCompactionPri::RoundRobin);Sourcepub fn get_compaction_pri(&self) -> Option<DBCompactionPri>
pub fn get_compaction_pri(&self) -> Option<DBCompactionPri>
The file pick order set by Self::set_compaction_pri.
DBCompactionPri covers every value RocksDB defines today, so None only shows up
if a future release adds one.
Sourcepub fn set_track_and_verify_wals_in_manifest(&mut self, val: bool)
pub fn set_track_and_verify_wals_in_manifest(&mut self, val: bool)
If true, the log numbers and sizes of the synced WALs are tracked in MANIFEST. During DB recovery, if a synced WAL is missing from disk, or the WAL’s size does not match the recorded size in MANIFEST, an error will be reported and the recovery will be aborted.
This is one additional protection against WAL corruption besides the per-WAL-entry checksum.
Note that this option does not work with secondary instance.
Currently, only syncing closed WALs are tracked. Calling DB::SyncWAL(),
etc. or writing with WriteOptions::sync=true to sync the live WAL is not
tracked for performance/efficiency reasons.
See: https://github.com/facebook/rocksdb/wiki/Track-WAL-in-MANIFEST
Default: false (disabled)
Sourcepub fn get_track_and_verify_wals_in_manifest(&self) -> bool
pub fn get_track_and_verify_wals_in_manifest(&self) -> bool
Returns the value of the track_and_verify_wals_in_manifest option.
Sourcepub fn set_write_dbid_to_manifest(&mut self, val: bool)
pub fn set_write_dbid_to_manifest(&mut self, val: bool)
The DB unique ID can be saved in the DB manifest (preferred, this option)
or an IDENTITY file (historical, deprecated), or both. If this option is
set to false (old behavior), then write_identity_file must be set to true.
The manifest is preferred because
- The IDENTITY file is not checksummed, so it is not as safe against corruption.
- The IDENTITY file may or may not be copied with the DB (e.g. not copied by BackupEngine), so is not reliable for the provenance of a DB.
This option might eventually be obsolete and removed as Identity files are phased out.
Default: true (enabled)
Sourcepub fn get_write_dbid_to_manifest(&self) -> bool
pub fn get_write_dbid_to_manifest(&self) -> bool
Returns the value of the write_dbid_to_manifest option.
Sourcepub fn set_info_logger(&mut self, logger: InfoLogger)
pub fn set_info_logger(&mut self, logger: InfoLogger)
Sets the logger to use.
By default rocksdb writes its internal logs to a file in the database
directory; this can be changed to a custom callback with the
InfoLogger::new_callback_logger constructor.
Sourcepub fn get_info_logger(&self) -> InfoLogger
pub fn get_info_logger(&self) -> InfoLogger
Returns a reference to the currently configured logger.
Sourcepub fn clear_calculate_sst_write_lifetime_hint_set(&mut self)
pub fn clear_calculate_sst_write_lifetime_hint_set(&mut self)
Empties the set of compaction styles that get SST write lifetime hints.
The hints tell the filesystem how long a file is expected to live, which cuts write amplification from OS level garbage collection and SSD wear levelling. RocksDB derives them from the output level alone, so a workload whose data lifetime varies a lot inside one level can end up worse off. Clearing the set is the documented way to turn the feature off. The default set holds level compaction only.
Entries go in through Self::set_add and come back out through
Self::set_remove, both of which take the raw rocksdb::CompactionStyle value.
Sourcepub fn calculate_sst_write_lifetime_hint_set_contains(
&self,
style: DBCompactionStyle,
) -> bool
pub fn calculate_sst_write_lifetime_hint_set_contains( &self, style: DBCompactionStyle, ) -> bool
Whether style is in the set of compaction styles that get SST write lifetime hints.
Only level and universal compaction do anything with the hints, even when another
style is in the set. See Self::clear_calculate_sst_write_lifetime_hint_set.
Sourcepub fn calculate_sst_write_lifetime_hint_set_count(&self) -> usize
pub fn calculate_sst_write_lifetime_hint_set_count(&self) -> usize
How many compaction styles are in the SST write lifetime hint set.
Sourcepub fn set_allow_2pc(&mut self, val: bool)
pub fn set_allow_2pc(&mut self, val: bool)
if set to false then recovery will fail when a prepared transaction is encountered in the WAL
Sourcepub fn get_allow_2pc(&self) -> bool
pub fn get_allow_2pc(&self) -> bool
Returns the value of the allow_2pc option.
Sourcepub fn set_allow_data_in_errors(&mut self, val: bool)
pub fn set_allow_data_in_errors(&mut self, val: bool)
It allows user to opt-in to get error messages containing corrupted keys/values. Corrupt keys, values will be logged in the messages/logs/status that will help users with the useful information regarding affected data. By default value is set false to prevent users data to be exposed in the logs/messages etc.
Default: false
Sourcepub fn get_allow_data_in_errors(&self) -> bool
pub fn get_allow_data_in_errors(&self) -> bool
Returns the value of the allow_data_in_errors option.
Sourcepub fn set_allow_fallocate(&mut self, val: bool)
pub fn set_allow_fallocate(&mut self, val: bool)
If false, fallocate() calls are bypassed, which disables file preallocation. The file
space preallocation is used to increase the file write/append performance. By default,
RocksDB preallocates space for WAL, SST, Manifest files, the extra space is truncated
when the file is written. Warning: if you’re using btrfs, we would recommend setting
allow_fallocate=false to disable preallocation. As on btrfs, the extra allocated
space cannot be freed, which could be significant if you have lots of files. More
details about this limitation:
https://github.com/btrfs/btrfs-dev-docs/blob/471c5699336e043114d4bca02adcd57d9dab9c44/data-extent-reference-counts.md
Sourcepub fn get_allow_fallocate(&self) -> bool
pub fn get_allow_fallocate(&self) -> bool
Returns the value of the allow_fallocate option.
Sourcepub fn set_async_wal_precreate(&mut self, val: bool)
pub fn set_async_wal_precreate(&mut self, val: bool)
EXPERIMENTAL: If true, RocksDB asynchronously precreates the next WAL file so foreground memtable switching can usually avoid the filesystem latency of creating a new WAL. The precreated file is only reserved empty storage; it does not become a logical WAL and is not added to WAL tracking until it is consumed by a foreground WAL rotation.
The option is sanitized to false when recycle_log_file_num is non-zero.
Default: false
Sourcepub fn get_async_wal_precreate(&self) -> bool
pub fn get_async_wal_precreate(&self) -> bool
Returns the value of the async_wal_precreate option.
Sourcepub fn set_avoid_flush_during_recovery(&mut self, val: bool)
pub fn set_avoid_flush_during_recovery(&mut self, val: bool)
By default RocksDB replay WAL logs and flush them on DB open, which may create very small SST files. If this option is enabled, RocksDB will try to avoid (but not guarantee not to) flush during recovery. Also, existing WAL logs will be kept, so that if crash happened before flush, we still have logs to recover from.
Note: when enforce_write_buffer_manager_during_recovery is also enabled, flushes may
still occur during recovery to respect the WriteBufferManager’s global memory limit,
even if this option is true. Once any such WBM-triggered flush happens, all remaining
memtables will also be flushed at the end of recovery (similar to the behavior when
this option is false).
DEFAULT: false
Sourcepub fn get_avoid_flush_during_recovery(&self) -> bool
pub fn get_avoid_flush_during_recovery(&self) -> bool
Returns the value of the avoid_flush_during_recovery option.
Sourcepub fn set_avoid_flush_during_shutdown(&mut self, val: bool)
pub fn set_avoid_flush_during_shutdown(&mut self, val: bool)
By default RocksDB will flush all memtables on DB close if there are unpersisted data (i.e. with WAL disabled) The flush can be skip to speedup DB close. Unpersisted data WILL BE LOST.
DEFAULT: false
Dynamically changeable through SetDBOptions() API.
Sourcepub fn get_avoid_flush_during_shutdown(&self) -> bool
pub fn get_avoid_flush_during_shutdown(&self) -> bool
Returns the value of the avoid_flush_during_shutdown option.
Sourcepub fn set_background_close_inactive_wals(&mut self, val: bool)
pub fn set_background_close_inactive_wals(&mut self, val: bool)
Set to true to re-instate an old behavior of keeping complete, synced WAL files open for write until they are collected for deletion by a background thread. This should not be needed unless there is a performance issue with file Close(), but setting it to true means that Checkpoint might call LinkFile on a WAL still open for write, which might be unsupported on some FileSystem implementations. As this is intended as a temporary kill switch, it is already DEPRECATED.
Sourcepub fn get_background_close_inactive_wals(&self) -> bool
pub fn get_background_close_inactive_wals(&self) -> bool
Returns the value of the background_close_inactive_wals option.
Sourcepub fn set_best_efforts_recovery(&mut self, val: bool)
pub fn set_best_efforts_recovery(&mut self, val: bool)
By default, RocksDB will attempt to detect any data losses or corruptions in DB files and return an error to the user, either at DB::Open time or later during DB operation. The exception to this policy is the WAL file, whose recovery is controlled by the wal_recovery_mode option.
Best-efforts recovery (this option set to true) signals a preference for opening the DB to any point-in-time valid state for each column family, including the empty/new state, versus the default of returning non-WAL data losses to the user as errors. In terms of RocksDB user data, this is like applying WALRecoveryMode::kPointInTimeRecovery to each column family rather than just the WAL.
The behavior changes in the presence of “AtomicGroup“s in the MANIFEST, which is
currently only the case when atomic_flush == true. In that case, all pre-existing
CFs must recover the atomic group in order for that group to be applied in an
all-or-nothing manner. This means that unused/inactive CF(s) with invalid filesystem
state can block recovery of all other CFs at an atomic group.
Best-efforts recovery (BER) is specifically designed to recover a DB with files that are missing or truncated to some smaller size, such as the result of an incomplete DB “physical” (FileSystem) copy. BER can also detect when an SST file has been replaced with a different one of the same size (assuming SST unique IDs are tracked in DB manifest). BER is not yet designed to produce a usable DB from other corruptions to DB files (which should generally be detectable by DB::VerifyChecksum()), and BER does not yet attempt to recover any WAL files.
For example, if an SST or blob file referenced by the MANIFEST is missing, BER might
be able to find a set of files corresponding to an old “point in time” version of the
column family, possibly from an older MANIFEST file. Besides complete “point in time”
version, an incomplete version with only a suffix of L0 files missing can also be
recovered to if the versioning history doesn’t include an atomic flush. From the
users’ perspective, missing a suffix of L0 files means missing the user’s most
recently written data. So the remaining available files still presents a valid point
in time view, although for some previous time. It’s not done for atomic flush because
that guarantees a consistent view across column families. We cannot guarantee that if
recovering an incomplete version. Some other kinds of DB files (e.g. CURRENT, LOCK,
IDENTITY) are either ignored or replaced with BER, or quietly fixed regardless of BER
setting. BER does require at least one valid MANIFEST to recover to a non-trivial DB
state, unlike ldb repair.
Default: false
Sourcepub fn get_best_efforts_recovery(&self) -> bool
pub fn get_best_efforts_recovery(&self) -> bool
Returns the value of the best_efforts_recovery option.
Sourcepub fn set_bgerror_resume_retry_interval(&mut self, val: u64)
pub fn set_bgerror_resume_retry_interval(&mut self, val: u64)
If max_bgerror_resume_count is >= 2, db resume is called multiple times. This option decides how long to wait to retry the next resume if the previous resume fails and satisfy redo resume conditions.
Default: 1000000 (microseconds).
Sourcepub fn get_bgerror_resume_retry_interval(&self) -> u64
pub fn get_bgerror_resume_retry_interval(&self) -> u64
Returns the value of the bgerror_resume_retry_interval option.
Sourcepub fn set_blob_direct_write_partitions(&mut self, val: u32)
pub fn set_blob_direct_write_partitions(&mut self, val: u32)
Number of direct-write blob partitions for this column family. Requires enable_blob_direct_write = true.
If blob_direct_write_partition_strategy is null, partition selection uses the default round-robin strategy.
Default: 1
Not dynamically changeable through the SetOptions() API.
Sourcepub fn get_blob_direct_write_partitions(&self) -> u32
pub fn get_blob_direct_write_partitions(&self) -> u32
Returns the value of the blob_direct_write_partitions option.
Sourcepub fn set_block_protection_bytes_per_key(&mut self, val: u8)
pub fn set_block_protection_bytes_per_key(&mut self, val: u8)
Enable/disable per key-value checksum protection for in memory blocks.
Checksum is constructed when a block is loaded into memory and verification is done for each key read from the block. This is useful for detecting in-memory data corruption. Note that this feature has a non-trivial negative impact on read performance. Different values of the option have similar performance impact, but different memory cost and corruption detection probability (e.g. 1 byte gives 255/256 chance for detecting a corruption).
Default: 0 (no protection) Supported values: 0, 1, 2, 4, 8. Dynamically changeable through the SetOptions() API.
Sourcepub fn get_block_protection_bytes_per_key(&self) -> u8
pub fn get_block_protection_bytes_per_key(&self) -> u8
Returns the value of the block_protection_bytes_per_key option.
Sourcepub fn set_bottommost_file_compaction_delay(&mut self, val: u32)
pub fn set_bottommost_file_compaction_delay(&mut self, val: u32)
For leveled compaction, RocksDB may compact a file at the bottommost level if it can compact away data that were protected by some snapshot. The compaction reason in LOG for this kind of compactions is “BottommostFiles”. Usually such compaction can happen as soon as a relevant snapshot is released. This option allows user to delay such compactions. A file is qualified for “BottommostFiles” compaction if it is at least “bottommost_file_compaction_delay” seconds old.
Default: 0 (no delay) Dynamically changeable through the SetOptions() API.
Sourcepub fn get_bottommost_file_compaction_delay(&self) -> u32
pub fn get_bottommost_file_compaction_delay(&self) -> u32
Returns the value of the bottommost_file_compaction_delay option.
Sourcepub fn set_cf_allow_ingest_behind(&mut self, val: bool)
pub fn set_cf_allow_ingest_behind(&mut self, val: bool)
If either DBOptions::allow_ingest_behind or this option is set to true, this column family will prepare for ingesting files to the last level (IngestExternalFiles() with ingest_behind=true). Users should set only this option since DBOptions::allow_ingest_behind is deprecated.
Specifically, preparing a column family for ingesting files to the last level has the following effects:
- Disables some internal optimizations around SST file compression.
- Reserves the last level for ingested files only.
- Compaction will not include any file from the last level.
- Compaction will preserve necessary tombstones that can apply on top of ingested files.
Note that only Universal Compaction supports cf_allow_ingest_behind. num_levels
should be >= 3 if this option is turned on.
Note that this option needs to be set to true before any write to the CF. It’s recommended to set the option to true since CF creation. Otherwise, ingestion with ingest_behind = true might fail. Once file ingestions are done, the option should be flipped to false. Flipping this option to false allows the CF to disable the behavior changes detailed above and resume more efficient operation.
Default: false Immutable.
Sourcepub fn get_cf_allow_ingest_behind(&self) -> bool
pub fn get_cf_allow_ingest_behind(&self) -> bool
Returns the value of the cf_allow_ingest_behind option.
Sourcepub fn add_checksum_handoff_file_type(&mut self, file_type: FileType)
pub fn add_checksum_handoff_file_type(&mut self, file_type: FileType)
Turns on checksum handoff for file_type, so RocksDB passes the crc32c it already
computed down to the FileSystem instead of relying on the storage layer to protect
the write on its own.
Only enable this for a FileSystem that verifies crc32c. RocksDB generates nothing
else, so a filesystem expecting a different checksum will reject the writes.
RocksDB honours the set for FileType::WalFile, FileType::TableFile, and
FileType::DescriptorFile. Other types can be added but are never consulted.
FileType::CompactionProgressFile and FileType::Unknown fall outside the range
RocksDB’s file type set can hold and are ignored.
Default: empty.
Sourcepub fn remove_checksum_handoff_file_type(&mut self, file_type: FileType)
pub fn remove_checksum_handoff_file_type(&mut self, file_type: FileType)
Turns checksum handoff back off for file_type.
Removing a type that is not in the set does nothing. See
Self::add_checksum_handoff_file_type.
Sourcepub fn clear_checksum_handoff_file_types(&mut self)
pub fn clear_checksum_handoff_file_types(&mut self)
Turns checksum handoff off for every file type.
Sourcepub fn contains_checksum_handoff_file_type(&self, file_type: FileType) -> bool
pub fn contains_checksum_handoff_file_type(&self, file_type: FileType) -> bool
Whether checksum handoff is on for file_type.
Always false for the two types the set cannot hold, see
Self::add_checksum_handoff_file_type.
Sourcepub fn checksum_handoff_file_type_count(&self) -> usize
pub fn checksum_handoff_file_type_count(&self) -> usize
How many file types have checksum handoff turned on.
Sourcepub fn set_compaction_verify_record_count(&mut self, val: bool)
pub fn set_compaction_verify_record_count(&mut self, val: bool)
DEPRECATED: This option might be removed in a future release.
If true, during compaction, RocksDB will count the number of entries read and compare it against the number of entries in the compaction input files. This is intended to add protection against corruption during compaction. Note that
- this verification is not done for compactions during which a compaction filter returns kRemoveAndSkipUntil, and
- the number of range deletions is not verified.
The option is here to turn the feature off in case this new validation feature has a bug. The option may be removed in the future once the feature is stable.
Default: true
Sourcepub fn get_compaction_verify_record_count(&self) -> bool
pub fn get_compaction_verify_record_count(&self) -> bool
Returns the value of the compaction_verify_record_count option.
Sourcepub fn set_daily_offpeak_time_utc(
&mut self,
v: impl CStrLike,
) -> Result<(), Error>
pub fn set_daily_offpeak_time_utc( &mut self, v: impl CStrLike, ) -> Result<(), Error>
Declares a daily window of low read and write activity, in UTC, so RocksDB can pull low priority work such as TTL compaction into it instead of letting it land in the middle of a busy period.
The format is HH:mm-HH:mm, inclusive on both ends, with hours in 00 to 23 and
minutes in 00 to 59. A start later than the end wraps past midnight, so
23:30-04:00 is a valid overnight window. 0:00-23:59 marks the whole day off-peak,
and an empty string, the default, means there is no off-peak period.
A string that does not parse is not reported here. RocksDB rejects it when the DB is
opened, and SetDBOptions rejects it at runtime.
§Errors
Returns an error if v contains an interior NUL byte.
Sourcepub fn get_daily_offpeak_time_utc(&self) -> String
pub fn get_daily_offpeak_time_utc(&self) -> String
The off-peak window set by Self::set_daily_offpeak_time_utc, empty when there is
none.
Sourcepub fn set_db_host_id(&mut self, v: impl CStrLike) -> Result<(), Error>
pub fn set_db_host_id(&mut self, v: impl CStrLike) -> Result<(), Error>
Names the machine hosting the DB. RocksDB writes it as a property into every SST file
it produces, including files from SstFileWriter and RepairDB.
It exists to trace memory corruption back to the host that wrote the file. Corruption that happens before RocksDB checksums the data is invisible to the checksum, so the host id is the only thing left pointing at the culprit.
RocksDB substitutes the real hostname when this is left at its default. Setting it to an empty string leaves the property out of the SST file entirely.
§Errors
Returns an error if v contains an interior NUL byte.
Sourcepub fn get_db_host_id(&self) -> String
pub fn get_db_host_id(&self) -> String
The host id set by Self::set_db_host_id.
An untouched Options returns the __hostname__ placeholder rather than the real
hostname, because RocksDB only resolves it while writing a file.
Sourcepub fn set_default_temperature(&mut self, val: c_int)
pub fn set_default_temperature(&mut self, val: c_int)
EXPERIMENTAL When this field is set, all SST files without an explicitly set temperature will be treated as if they have this temperature for file reading accounting purpose, such as io statistics, io perf context.
Not dynamically changeable; change requires DB restart.
Sourcepub fn get_default_temperature(&self) -> c_int
pub fn get_default_temperature(&self) -> c_int
Returns the value of the default_temperature option.
Sourcepub fn set_default_write_temperature(&mut self, val: c_int)
pub fn set_default_write_temperature(&mut self, val: c_int)
EXPERIMENTAL When no other option such as last_level_temperature determines the temperature of a new SST file, it will be written with this temperature, which can be set differently for each column family.
Dynamically changeable through the SetOptions() API
Sourcepub fn get_default_write_temperature(&self) -> c_int
pub fn get_default_write_temperature(&self) -> c_int
Returns the value of the default_write_temperature option.
Sourcepub fn set_delayed_write_rate(&mut self, val: u64)
pub fn set_delayed_write_rate(&mut self, val: u64)
The limited write rate to DB if soft_pending_compaction_bytes_limit or
level0_slowdown_writes_trigger is triggered, or we are writing to the last mem table
allowed and we allow more than 3 mem tables. It is calculated using size of user write
requests before compression. RocksDB may decide to slow down more if the compaction
still gets behind further. If the value is 0, we will infer a value from
rater_limiter value if it is not empty, or 16MB if rater_limiter is empty. Note
that if users change the rate in rate_limiter after DB is opened,
delayed_write_rate won’t be adjusted.
Unit: byte per second.
Default: 0
Dynamically changeable through SetDBOptions() API.
Sourcepub fn get_delayed_write_rate(&self) -> u64
pub fn get_delayed_write_rate(&self) -> u64
Returns the value of the delayed_write_rate option.
Sourcepub fn set_disallow_memtable_writes(&mut self, val: bool)
pub fn set_disallow_memtable_writes(&mut self, val: bool)
Setting this option to true disallows ordinary writes to the column family and it can only be populated through import and ingestion. It is intended to protect “ingestion only” column families. This option is not currently supported on the default column family because of error handling challenges analogous to https://github.com/facebook/rocksdb/issues/13429
This option is not mutable with SetOptions(). It can be changed between DB::Open() calls, but open will fail if recovering WAL writes to a CF with this option set.
Sourcepub fn get_disallow_memtable_writes(&self) -> bool
pub fn get_disallow_memtable_writes(&self) -> bool
Returns the value of the disallow_memtable_writes option.
Sourcepub fn get_dump_malloc_stats(&self) -> bool
pub fn get_dump_malloc_stats(&self) -> bool
If true, then print malloc stats together with rocksdb.stats when printing to LOG. DEFAULT: false
Sourcepub fn set_enable_blob_direct_write(&mut self, val: bool)
pub fn set_enable_blob_direct_write(&mut self, val: bool)
When enabled, values >= min_blob_size are written directly to blob files during the write path and replaced in WAL and memtable with BlobIndex references.
Requires enable_blob_files = true. Experimental reduced-scope v1 restrictions. These limitations keep the v1 implementation intentionally small; follow-up PRs are expected to improve feature compatibility over time:
- only supports the ordered single-memtable-writer path; unordered, pipelined, two_write_queues, and allow_concurrent_memtable_write are not supported.
- crash recovery only supports blob files that were already made manifest-visible by flush/SST creation; WAL replay of active direct-write blob files is not currently supported.
- checkpoint/backup/live-files enumeration must flush pending direct-write state first; APIs that intentionally skip the flush, or run while WAL is locked, can return NotSupported.
- not compatible with MemPurge or user-defined timestamps.
- DB::IngestWriteBatchWithIndex() is not supported while any live column family enables this option.
- read-only and secondary opens can read flushed/manifest-visible blob files, but do not resolve still-active direct-write blob files.
Default: false
Not dynamically changeable through the SetOptions() API.
Sourcepub fn get_enable_blob_direct_write(&self) -> bool
pub fn get_enable_blob_direct_write(&self) -> bool
Returns the value of the enable_blob_direct_write option.
Sourcepub fn set_enable_thread_tracking(&mut self, val: bool)
pub fn set_enable_thread_tracking(&mut self, val: bool)
If true, then the status of the threads involved in this DB will be tracked and available via GetThreadList() API.
Default: false
Sourcepub fn get_enable_thread_tracking(&self) -> bool
pub fn get_enable_thread_tracking(&self) -> bool
Returns the value of the enable_thread_tracking option.
Sourcepub fn set_enforce_single_del_contracts(&mut self, val: bool)
pub fn set_enforce_single_del_contracts(&mut self, val: bool)
DEPRECATED: This option might be removed in a future release.
If set to false, when compaction or flush sees a SingleDelete followed by a Delete for the same user key, compaction job will not fail. Otherwise, compaction job will fail. This is a temporary option to help existing use cases migrate, and will be removed in a future release. Warning: do not set to false unless you are trying to migrate existing data in which the contract of single delete (https://github.com/facebook/rocksdb/wiki/Single-Delete) is not enforced, thus has Delete mixed with SingleDelete for the same user key. Violation of the contract leads to undefined behaviors with high possibility of data inconsistency, e.g. deleted old data become visible again, etc.
Sourcepub fn get_enforce_single_del_contracts(&self) -> bool
pub fn get_enforce_single_del_contracts(&self) -> bool
Returns the value of the enforce_single_del_contracts option.
Sourcepub fn set_enforce_write_buffer_manager_during_recovery(&mut self, val: bool)
pub fn set_enforce_write_buffer_manager_during_recovery(&mut self, val: bool)
If true and a WriteBufferManager is configured, RocksDB will check WriteBufferManager::ShouldFlush() during WAL recovery and schedule flushes when needed. This prevents OOM when multiple RocksDB instances share a WriteBufferManager and one instance is recovering from WAL.
When triggered, all column families with non-empty memtables are scheduled for flush,
which may produce smaller L0 files in some column families. This also overrides
avoid_flush_during_recovery: once a WBM-triggered flush occurs mid-recovery, all
remaining non-empty memtables will be flushed at the end of recovery as well.
DEFAULT: true
Sourcepub fn get_enforce_write_buffer_manager_during_recovery(&self) -> bool
pub fn get_enforce_write_buffer_manager_during_recovery(&self) -> bool
Returns the value of the enforce_write_buffer_manager_during_recovery option.
Sourcepub fn set_fast_sst_open(&mut self, val: bool)
pub fn set_fast_sst_open(&mut self, val: bool)
EXPERIMENTAL When this is true, save file system metadata (if supported by the FS) for SST files added to the DB in the MANIFEST, and use it to accelerate re-opening of those files on DB open. This will help cut down DB open latency on remote storage systems.
Sourcepub fn get_fast_sst_open(&self) -> bool
pub fn get_fast_sst_open(&self) -> bool
Returns the value of the fast_sst_open option.
Sourcepub fn set_flush_verify_memtable_count(&mut self, val: bool)
pub fn set_flush_verify_memtable_count(&mut self, val: bool)
DEPRECATED: This option might be removed in a future release.
If true, during memtable flush, RocksDB will validate total entries read in flush, total entries written in the SST and compare them with counter of keys added.
The option is here to turn the feature off in case this new validation feature has a bug. The option may be removed in the future once the feature is stable.
Default: true
Sourcepub fn get_flush_verify_memtable_count(&self) -> bool
pub fn get_flush_verify_memtable_count(&self) -> bool
Returns the value of the flush_verify_memtable_count option.
Sourcepub fn set_follower_catchup_retry_count(&mut self, val: u64)
pub fn set_follower_catchup_retry_count(&mut self, val: u64)
For a given catch up attempt, this option specifies the number of times to tail the MANIFEST and try to install a new, consistent version before giving up. Though it should be extremely rare, the catch up may fail if the leader is mutating the LSM at a very high rate and the follower is unable to get a consistent view. Default to 10 attempts
Sourcepub fn get_follower_catchup_retry_count(&self) -> u64
pub fn get_follower_catchup_retry_count(&self) -> u64
Returns the value of the follower_catchup_retry_count option.
Sourcepub fn set_follower_catchup_retry_wait_ms(&mut self, val: u64)
pub fn set_follower_catchup_retry_wait_ms(&mut self, val: u64)
Time to wait between consecutive catch up attempts Default 100ms
Sourcepub fn get_follower_catchup_retry_wait_ms(&self) -> u64
pub fn get_follower_catchup_retry_wait_ms(&self) -> u64
Returns the value of the follower_catchup_retry_wait_ms option.
Sourcepub fn set_follower_refresh_catchup_period_ms(&mut self, val: u64)
pub fn set_follower_refresh_catchup_period_ms(&mut self, val: u64)
When a RocksDB database is opened in follower mode, this option is set by the user to request the frequency of the follower attempting to refresh its view of the leader. RocksDB may choose to trigger catch ups more frequently if it detects any changes in the database state. Default every 10s.
Sourcepub fn get_follower_refresh_catchup_period_ms(&self) -> u64
pub fn get_follower_refresh_catchup_period_ms(&self) -> u64
Returns the value of the follower_refresh_catchup_period_ms option.
Sourcepub fn set_force_consistency_checks(&mut self, val: bool)
pub fn set_force_consistency_checks(&mut self, val: bool)
In debug mode, RocksDB runs consistency checks on the LSM every time the LSM changes (Flush, Compaction, AddFile). When this option is true, these checks are also enabled in release mode. These checks were historically disabled in release mode, but are now enabled by default for proactive corruption detection. The CPU overhead is negligible for normal mixed operations but can slow down saturated writing. See Options::DisableExtraChecks(). Default: true
Sourcepub fn get_force_consistency_checks(&self) -> bool
pub fn get_force_consistency_checks(&self) -> bool
Returns the value of the force_consistency_checks option.
Sourcepub fn set_last_level_temperature(&mut self, val: c_int)
pub fn set_last_level_temperature(&mut self, val: c_int)
EXPERIMENTAL If this option is set, when creating the last level files, pass this temperature to FileSystem used. Should be no-op for default FileSystem and users need to plug in their own FileSystem to take advantage of it. Currently only compatible with universal compaction.
Dynamically changeable through the SetOptions() API
Sourcepub fn get_last_level_temperature(&self) -> c_int
pub fn get_last_level_temperature(&self) -> c_int
Returns the value of the last_level_temperature option.
Sourcepub fn set_log_readahead_size(&mut self, val: usize)
pub fn set_log_readahead_size(&mut self, val: usize)
The number of bytes to prefetch when reading the DB manifest and WAL files during DB::Open (and variants). This is mostly useful for reading a remotely located log, as it can save the number of round-trips. If 0, then the prefetching is disabled.
Default: 0
Sourcepub fn get_log_readahead_size(&self) -> usize
pub fn get_log_readahead_size(&self) -> usize
Returns the value of the log_readahead_size option.
Sourcepub fn set_lowest_used_cache_tier(&mut self, val: c_int)
pub fn set_lowest_used_cache_tier(&mut self, val: c_int)
It indicates, which lowest cache tier we want to use for a certain DB. Currently we support volatile_tier and non_volatile_tier. They are layered. By setting it to kVolatileTier, only the block cache (current implemented volatile_tier) is used. So cache entries will not spill to secondary cache (current implemented non_volatile_tier), and block cache lookup misses will not lookup in the secondary cache. When kNonVolatileBlockTier is used, we use both block cache and secondary cache.
Default: kNonVolatileBlockTier
Sourcepub fn get_lowest_used_cache_tier(&self) -> c_int
pub fn get_lowest_used_cache_tier(&self) -> c_int
Returns the value of the lowest_used_cache_tier option.
Sourcepub fn set_max_bgerror_resume_count(&mut self, val: c_int)
pub fn set_max_bgerror_resume_count(&mut self, val: c_int)
It defines how many times DB::Resume() is called by a separate thread when background retryable IO Error happens. When background retryable IO Error happens, SetBGError is called to deal with the error. If the error can be auto-recovered (e.g., retryable IO Error during Flush or WAL write), then db resume is called in background to recover from the error. If this value is 0 or negative, DB::Resume() will not be called automatically.
Default: INT_MAX
Sourcepub fn get_max_bgerror_resume_count(&self) -> c_int
pub fn get_max_bgerror_resume_count(&self) -> c_int
Returns the value of the max_bgerror_resume_count option.
Sourcepub fn set_max_compaction_trigger_wakeup_seconds(&mut self, val: u64)
pub fn set_max_compaction_trigger_wakeup_seconds(&mut self, val: u64)
Maximum interval in seconds between periodic compaction trigger checks. The periodic trigger re-evaluates compaction scores for all column families, which is necessary for features like read-triggered compaction and time-based compaction to work on a “quiet” DB with no writes.
This is an upper bound: the actual check interval may be reduced to align with stats_dump_period_sec, stats_persist_period_sec, or per-CF time-based compaction intervals (periodic_compaction_seconds, ttl, etc.).
Note: this option controls how often RocksDB checks whether compaction is needed. It
is different from the CF option periodic_compaction_seconds which controls the age
threshold at which SST files become eligible for periodic compaction.
The minimum effective period is 1 second (values below 1 are clamped to 1). Setting this to 0 results in the most aggressive 1-second polling.
Default: 43200 (12 hours)
Dynamically changeable through SetDBOptions() API.
Sourcepub fn get_max_compaction_trigger_wakeup_seconds(&self) -> u64
pub fn get_max_compaction_trigger_wakeup_seconds(&self) -> u64
Returns the value of the max_compaction_trigger_wakeup_seconds option.
Sourcepub fn set_max_manifest_space_amp_pct(&mut self, val: c_int)
pub fn set_max_manifest_space_amp_pct(&mut self, val: c_int)
This option mostly replaces max_manifest_file_size to control an auto-tuned balance of manifest write amplification and space amplification. A new manifest file is created with the “compacted” contents of the old one when current_manifest_size > max(max_manifest_file_size, est_compacted_manifest_size * (1 + max_manifest_space_amp_pct/100))
where est_compacted_manifest_size is an estimate of how big a new compacted version of the current manifest would be. Currently, the estimate used is the last newly-written manifest, in its “compacted” form.
Space amplification in the manifest file might be less of a concern for primary storage space and more of a concern for DB recover time and size of backup files that aren’t incremental between backups. To minimize manifest churn on initial DB population, setting max_manifest_file_size to something not too small, like 1MB, should suffice. Similarly, write amp on the manifest file is likely not a direct concern but completed compactions and flushes cannot (currently) be committed while the (relatively small) manifest file is being compacted. Manifest compactions should not interfere with user write latency or throughput unless the DB is chronically stalling or close to stalling writes already.
For this option to have a meaningful effect, it is recommended to set max_manifest_file_size to something modest like 1MB. Then we can interpret values for this option as follows, starting with minimum space amp and maximum write amp:
- 0 - Every manifest write (flush, compaction, etc.) generates a whole new manifest. Only useful for testing.
- very small - Doesn’t take many manifest writes to generate a whole new manifest.
- 100 - In a DB with pretty consistent number of SST files, etc., achieves about 1.0 write amp (writing about 2x the theoretical minimum) and a max of about 1.0 space amp (manifest up to 2x the compacted size).
- 500 - Recommended and default: 0.2 write amp and up to roughly 5.0 space amp.
- 10000 - 0.01 write amp and up to 100 space amp on the manifest.
This option is mutable with SetDBOptions(), taking effect on the next manifest write (e.g. completed DB compaction or flush).
Sourcepub fn get_max_manifest_space_amp_pct(&self) -> c_int
pub fn get_max_manifest_space_amp_pct(&self) -> c_int
Returns the value of the max_manifest_space_amp_pct option.
Sourcepub fn set_max_write_batch_group_size_bytes(&mut self, val: u64)
pub fn set_max_write_batch_group_size_bytes(&mut self, val: u64)
The maximum limit of number of bytes that are written in a single batch of WAL or memtable write. It is followed when the leader write size is larger than 1/8 of this limit.
Default: 1 MB
Sourcepub fn get_max_write_batch_group_size_bytes(&self) -> u64
pub fn get_max_write_batch_group_size_bytes(&self) -> u64
Returns the value of the max_write_batch_group_size_bytes option.
Sourcepub fn set_memtable_max_range_deletions(&mut self, val: u32)
pub fn set_memtable_max_range_deletions(&mut self, val: u32)
RocksDB will try to flush the current memtable after the number of range deletions is >= this limit. For workloads with many range deletions, limiting the number of range deletions in memtable can help prevent performance degradation and/or OOM caused by too many range tombstones in a single memtable.
Default: 0 (disabled)
Dynamically changeable through SetOptions() API
Sourcepub fn get_memtable_max_range_deletions(&self) -> u32
pub fn get_memtable_max_range_deletions(&self) -> u32
Returns the value of the memtable_max_range_deletions option.
Sourcepub fn set_memtable_protection_bytes_per_key(&mut self, val: u32)
pub fn set_memtable_protection_bytes_per_key(&mut self, val: u32)
Enable memtable per key-value checksum protection.
Each entry in memtable will be suffixed by a per key-value checksum. This options determines the size of such checksums.
It is suggested to turn on write batch per key-value checksum protection together with this option, so that the checksum computation is done outside of writer threads (memtable kv checksum can be computed from write batch checksum) See WriteOptions::protection_bytes_per_key for more detail.
Default: 0 (no protection) Supported values: 0, 1, 2, 4, 8. Dynamically changeable through the SetOptions() API.
Sourcepub fn get_memtable_protection_bytes_per_key(&self) -> u32
pub fn get_memtable_protection_bytes_per_key(&self) -> u32
Returns the value of the memtable_protection_bytes_per_key option.
Sourcepub fn set_memtable_verify_per_key_checksum_on_seek(&mut self, val: bool)
pub fn set_memtable_verify_per_key_checksum_on_seek(&mut self, val: bool)
Enables additional integrity checks during seek. Specifically, for skiplist-based memtables, key checksum validation could be enabled during seek optionally. This is helpful to detect corrupted memtable keys during reads. Enabling this feature incurs a performance overhead due to additional key checksum validation during memtable seek operation. This option depends on memtable_protection_bytes_per_key to be non zero. If memtable_protection_bytes_per_key is zero, no validation is performed.
Sourcepub fn get_memtable_verify_per_key_checksum_on_seek(&self) -> bool
pub fn get_memtable_verify_per_key_checksum_on_seek(&self) -> bool
Returns the value of the memtable_verify_per_key_checksum_on_seek option.
Sourcepub fn get_memtable_whole_key_filtering(&self) -> bool
pub fn get_memtable_whole_key_filtering(&self) -> bool
Enable whole key bloom filter in memtable. Note this will only take effect if memtable_prefix_bloom_size_ratio is not 0. Enabling whole key filtering can potentially reduce CPU usage for point-look-ups.
Default: false (disabled)
Dynamically changeable through SetOptions() API
Sourcepub fn set_metadata_write_temperature(&mut self, val: c_int)
pub fn set_metadata_write_temperature(&mut self, val: c_int)
When DB files other than SST, blob and WAL files are created, use this filesystem
temperature. (See also wal_write_temperature and various *_temperature CF
options.) When not kUnknown, this overrides any temperature set by
OptimizeForManifestWrite functions.
Sourcepub fn get_metadata_write_temperature(&self) -> c_int
pub fn get_metadata_write_temperature(&self) -> c_int
Returns the value of the metadata_write_temperature option.
Sourcepub fn set_min_tombstones_for_range_conversion(&mut self, val: u32)
pub fn set_min_tombstones_for_range_conversion(&mut self, val: u32)
EXPERIMENTAL
During forward or reverse iteration, when this many or more strictly contiguous point tombstones (kTypeDeletion, kTypeDeletionWithTimestamp, kTypeSingleDeletion) are encountered with no live keys between them, a range tombstone [first_tombstone_key, next_live_key) is inserted into the current mutable memtable (only if memtable is not empty). This is a logically redundant entry that does not change any data, but optimizes future iterators by potentially skipping a large number of tombstone scans.
This optimization is best-effort and is currently disabled for iterator configurations that may not expose all interior live keys, including:
- user-defined timestamp reads without full visibility (for example, ReadOptions::iter_start_ts or a non-max ReadOptions::timestamp)
- prefix extractor reads that are neither total-order (ReadOptions::total_order_seek / ReadOptions::auto_prefix_mode) nor bounded by ReadOptions::prefix_same_as_start
Even if the above restrictions are met, there are still scenarios where a converted range tombstone may be discarded:
- The snapshot’s active mutable memtable has already become immutable.
- The iterator’s snapshot seq is below the active memtable’s earliest sequence number.
- A range tombstone covering [first_tombstone_key, next_live_key) is already present in the memtable.
- A WritePrepared/WriteUnprepared transaction read callback is in use and the snapshot seq is at or above its min uncommitted seq.
- An IngestExternalFile call is currently in flight on this column family OR the inserted range tombstone seqno would be lower than the ingested file seqno.
Read-write iterators using ReadOptions::table_filter are rejected while this option is enabled, see more details in ReadOptions::table_filter comments.
Set to 0 to disable.
Dynamically changeable through SetOptions() API
Sourcepub fn get_min_tombstones_for_range_conversion(&self) -> u32
pub fn get_min_tombstones_for_range_conversion(&self) -> u32
Returns the value of the min_tombstones_for_range_conversion option.
Sourcepub fn set_optimize_manifest_for_recovery(&mut self, val: bool)
pub fn set_optimize_manifest_for_recovery(&mut self, val: bool)
EXPERIMENTAL: If true, RocksDB can reduce recovery work after a clean shutdown, which may reduce DB::Open latency on warm reopens, especially on storage where metadata appends are expensive.
Best-effort optimization: if it is disabled or unavailable, RocksDB falls back to the standard recovery path.
Temporary rollout / kill switch for an optimization that is intended to be correct and eventually always enabled. Mutable via SetDBOptions().
Sourcepub fn get_optimize_manifest_for_recovery(&self) -> bool
pub fn get_optimize_manifest_for_recovery(&self) -> bool
Returns the value of the optimize_manifest_for_recovery option.
Sourcepub fn set_paranoid_file_checks(&mut self, val: bool)
pub fn set_paranoid_file_checks(&mut self, val: bool)
After writing every SST file, reopen it and read all the keys. Checks the hash of all of the keys and values written versus the keys in the file and signals a corruption if they do not match
Default: false
Dynamically changeable through SetOptions() API
Sourcepub fn get_paranoid_file_checks(&self) -> bool
pub fn get_paranoid_file_checks(&self) -> bool
Returns the value of the paranoid_file_checks option.
Sourcepub fn set_paranoid_memory_checks(&mut self, val: bool)
pub fn set_paranoid_memory_checks(&mut self, val: bool)
Enables additional integrity checks during reads/scans. Specifically, for skiplist-based memtables, key ordering validation could be enabled optionally. This is helpful to detect corrupted memtable keys during reads. Enabling this feature incurs a performance overhead due to additional comparison during memtable lookup.
Sourcepub fn get_paranoid_memory_checks(&self) -> bool
pub fn get_paranoid_memory_checks(&self) -> bool
Returns the value of the paranoid_memory_checks option.
Sourcepub fn set_persist_stats_to_disk(&mut self, val: bool)
pub fn set_persist_stats_to_disk(&mut self, val: bool)
If true, automatically persist stats to a hidden column family (column family name:
rocksdb_stats_history) every stats_persist_period_sec seconds; otherwise, write
to an in-memory struct. User can query through GetStatsHistory API. If user attempts
to create a column family with the same name on a DB which have previously set
persist_stats_to_disk to true, the column family creation will fail, but the hidden
column family will survive, as well as the previously persisted statistics. When
peristing stats to disk, the stat name will be limited at 100 bytes. Default: false
Sourcepub fn get_persist_stats_to_disk(&self) -> bool
pub fn get_persist_stats_to_disk(&self) -> bool
Returns the value of the persist_stats_to_disk option.
Sourcepub fn set_persist_user_defined_timestamps(&mut self, val: bool)
pub fn set_persist_user_defined_timestamps(&mut self, val: bool)
UNDER CONSTRUCTION – DO NOT USE When the user-defined timestamp feature is enabled, this flag controls whether the user-defined timestamps will be persisted.
When it’s false, the user-defined timestamps will be removed from the user keys when data is flushed from memtables to SST files. Other places that user keys can be persisted like file boundaries in file metadata and blob files go through a similar process. There are two major motivations for this flag:
- backward compatibility: if the user later decides to disable the user-defined timestamp feature for the column family, these SST files can be handled by a user comparator that is not aware of user-defined timestamps.
- enable user-defined timestamp feature for an existing column family while set this
flag to be
false: user keys in the newly generated SST files are of the same format as the existing SST files.
Currently only user comparator that formats user-defined timesamps as uint64_t via
using one of the RocksDB provided comparator ComparatorWithU64TsImpl are supported.
When setting this flag to false, users should also call
DB::IncreaseFullHistoryTsLow to set a cutoff timestamp for flush. RocksDB refrains
from flushing a memtable with data still above the cutoff timestamp with best effort.
One limitation of this best effort is that when max_write_buffer_number is equal to
or smaller than 2, RocksDB will not attempt to retain user-defined timestamps, all
flush jobs continue normally.
Users can do user-defined multi-versioned read above the cutoff timestamp. When users try to read below the cutoff timestamp, an error will be returned.
Note that if WAL is enabled, unlike SST files, user-defined timestamps are persisted
to WAL even if this flag is set to false. The benefit of this is that user-defined
timestamps can be recovered with the caveat that users should flush all memtables so
there is no active WAL files before doing a downgrade. In order to use WAL to recover
user-defined timestamps, users of this feature would want to set both
avoid_flush_during_shutdown and avoid_flush_during_recovery to be true.
Note that setting this flag to false is not supported in combination with atomic
flush, or concurrent memtable write enabled by allow_concurrent_memtable_write.
Default: true (user-defined timestamps are persisted) Not dynamically changeable, change it requires db restart and only compatible changes are allowed.
Sourcepub fn get_persist_user_defined_timestamps(&self) -> bool
pub fn get_persist_user_defined_timestamps(&self) -> bool
Returns the value of the persist_user_defined_timestamps option.
Sourcepub fn set_preclude_last_level_data_seconds(&mut self, val: u64)
pub fn set_preclude_last_level_data_seconds(&mut self, val: u64)
EXPERIMENTAL The feature is still in development and is incomplete. If this option is set, when data insert time is within this time range, it will be precluded from the last level. 0 means no key will be precluded from the last level.
Note: when enabled, universal size amplification (controlled by option
compaction_options_universal.max_size_amplification_percent) calculation will
exclude the last level. As the feature is designed for tiered storage and a typical
setting is the last level is cold tier which is likely not size constrained, the size
amp is going to be only for non-last levels.
Default: 0 (disable the feature)
Dynamically changeable through the SetOptions() API
Sourcepub fn get_preclude_last_level_data_seconds(&self) -> u64
pub fn get_preclude_last_level_data_seconds(&self) -> u64
Returns the value of the preclude_last_level_data_seconds option.
Sourcepub fn set_prefix_seek_opt_in_only(&mut self, val: bool)
pub fn set_prefix_seek_opt_in_only(&mut self, val: bool)
Historically, when prefix_extractor != nullptr, iterators have an unfortunate default semantics of possibly only returning data within the same prefix. To avoid “spooky action at a distance,” iterator bounds should come from the instantiation or seeking of the iterator, not from a mutable column family option.
When set to true, it is as if every iterator is created with total_order_seek=true and only auto_prefix_mode=true and prefix_same_as_start=true can take advantage of prefix seek optimizations.
Sourcepub fn get_prefix_seek_opt_in_only(&self) -> bool
pub fn get_prefix_seek_opt_in_only(&self) -> bool
Returns the value of the prefix_seek_opt_in_only option.
Sourcepub fn set_preserve_internal_time_seconds(&mut self, val: u64)
pub fn set_preserve_internal_time_seconds(&mut self, val: u64)
EXPERIMENTAL If this option is set, it will preserve the internal time information
about the data until it’s older than the specified time here. Internally the time
information is a map between sequence number and time, which is the same as
preclude_last_level_data_seconds. But it won’t preclude the data from the last level
and the data in the last level won’t have the sequence number zeroed out. Internally,
rocksdb would sample the sequence number to time pair and store that in SST property
“rocksdb.seqno.time.map”. The information is currently only used for tiered storage
compaction (option preclude_last_level_data_seconds).
Note: if both preclude_last_level_data_seconds and this option is set, it will
preserve the max time of the 2 options and compaction still preclude the data based on
preclude_last_level_data_seconds. The higher the preserve_time is, the less the
sampling frequency will be ( which means less accuracy of the time estimation).
Default: 0 (disable the feature)
Dynamically changeable through the SetOptions() API
Sourcepub fn get_preserve_internal_time_seconds(&self) -> u64
pub fn get_preserve_internal_time_seconds(&self) -> u64
Returns the value of the preserve_internal_time_seconds option.
Sourcepub fn set_read_io_executor_threads(&mut self, val: c_int)
pub fn set_read_io_executor_threads(&mut self, val: c_int)
Requested maximum number of threads in the shared read I/O executor. A DB open can increase the executor to this size but cannot reduce it. Used exclusively for asynchronous read requests (e.g. GetAsync, MultiGetAsync).
Sourcepub fn get_read_io_executor_threads(&self) -> c_int
pub fn get_read_io_executor_threads(&self) -> c_int
Returns the value of the read_io_executor_threads option.
Sourcepub fn set_read_triggered_compaction_threshold(&mut self, val: f64)
pub fn set_read_triggered_compaction_threshold(&mut self, val: f64)
When set to a positive value, enables read-triggered compaction. An SST file is marked for compaction when its estimated read frequency (estimated_reads / file_size) exceeds this threshold. This helps reduce read amplification for hot keys by compacting frequently-read files.
Only “collapsible” reads are counted – lookups that return NotFound (bloom filter false positive), Delete/SingleDeletion (tombstone), or Merge (partial result). These are reads where the file contributed no final value and compaction would eliminate the wasted work.
Choosing a value: the threshold balances read IO saved against the write amplification (WA) of an extra compaction. This assumes the block-based table format is being used,
Break-even derivation (no block cache): Let r = estimated_reads / file_size (the threshold) S = file_size B = block_size (typically 4 KB) F = level fanout (typically ~10)
Each collapsible read wastes one data-block read = B bytes of IO. Total wasted read IO for a file = r * S * B.
Compaction cost: one level-L file overlaps ~F files in level L+1, so we read (1 + F) files and write (1 + F) files. Total compaction IO = 2 * (1 + F) * S.
Break-even when wasted read IO equals compaction IO: r * S * B = 2 * (1 + F) * S r = 2
- (1 + F) / B
With F = 10, B = 4096: r = 22 / 4096 ~= 0.005.
With a block-cache hit rate h (0 <= h < 1), each collapsible read only costs (1 - h) * B bytes of actual disk IO, so: r = 2 * (1 + F) / ((1 - h) * B)
h = 0 -> r ~= 0.005 h = 0.5 -> r ~= 0.01 h = 0.9 -> r ~= 0.05
A recommended starting point is 0.01, which avoids triggering compactions that cost more IO than they save for most cache-friendly workloads, while still being responsive enough to compact files with significant wasted reads.
For this feature to take effect on a “quiet” DB (no writes), the DB-level option
max_compaction_trigger_wakeup_seconds must also be set to a non-zero value so the
periodic background job can re-evaluate files.
Valid range: >= 0.0 (must be finite). Use 0.0 to disable.
Dynamically changeable through SetOptions() API
Sourcepub fn get_read_triggered_compaction_threshold(&self) -> f64
pub fn get_read_triggered_compaction_threshold(&self) -> f64
Returns the value of the read_triggered_compaction_threshold option.
Sourcepub fn set_remove(&mut self, val: c_int)
pub fn set_remove(&mut self, val: c_int)
Sets the remove option.
Sourcepub fn set_reuse_manifest_on_open(&mut self, val: bool)
pub fn set_reuse_manifest_on_open(&mut self, val: bool)
EXPERIMENTAL: If true, DB::Open can try to reuse the existing MANIFEST for the first post-open metadata update instead of creating a fresh one. This can reduce warm-open latency for DBs whose MANIFEST is expensive to rebuild.
Best-effort optimization: even when enabled, RocksDB may still create a fresh MANIFEST if the FileSystem does not support reopening the existing MANIFEST for append, or if RocksDB decides reuse is unsafe. That fallback is normal behavior.
With very small max_manifest_file_size settings, the reused MANIFEST can still
rotate earlier than expected after open, because RocksDB may keep a conservative
auto-tuned rotation threshold until it later refreshes its compacted-size estimate.
Temporary rollout / kill switch while this optimization is being validated.
Sourcepub fn get_reuse_manifest_on_open(&self) -> bool
pub fn get_reuse_manifest_on_open(&self) -> bool
Returns the value of the reuse_manifest_on_open option.
Sourcepub fn set_sample_for_compression(&mut self, val: u64)
pub fn set_sample_for_compression(&mut self, val: u64)
If this option is set then 1 in N blocks are compressed using a fast (lz4) and slow (zstd) compression algorithm. The compressibility is reported as stats and the stored data is left uncompressed (unless compression is also requested).
Sourcepub fn get_sample_for_compression(&self) -> u64
pub fn get_sample_for_compression(&self) -> u64
Returns the value of the sample_for_compression option.
Sourcepub fn set_stats_history_buffer_size(&mut self, val: usize)
pub fn set_stats_history_buffer_size(&mut self, val: usize)
if not zero, periodically take stats snapshots and store in memory, the memory size for stats snapshots is capped at stats_history_buffer_size Default: 1MB
Sourcepub fn get_stats_history_buffer_size(&self) -> usize
pub fn get_stats_history_buffer_size(&self) -> usize
Returns the value of the stats_history_buffer_size option.
Sourcepub fn set_strict_bytes_per_sync(&mut self, val: bool)
pub fn set_strict_bytes_per_sync(&mut self, val: bool)
When true, guarantees WAL files have at most wal_bytes_per_sync bytes submitted for
writeback at any given time, and SST files have at most bytes_per_sync bytes pending
writeback at any given time. This can be used to handle cases where processing speed
exceeds I/O speed during file generation, which can lead to a huge sync when the file
is finished, even with bytes_per_sync / wal_bytes_per_sync properly configured.
- If
sync_file_rangeis supported it achieves this by waiting for any priorsync_file_ranges to finish before proceeding. In this way, processing (compression, etc.) can proceed uninhibited in the gap betweensync_file_ranges, and we block only when I/O falls behind. - Otherwise the
WritableFile::Syncmethod is used. Note this mechanism always blocks, thus preventing the interleaving of I/O and processing.
Note: Enabling this option does not provide any additional persistence guarantees, as
it may use sync_file_range, which does not write out metadata.
Default: false
Sourcepub fn get_strict_bytes_per_sync(&self) -> bool
pub fn get_strict_bytes_per_sync(&self) -> bool
Returns the value of the strict_bytes_per_sync option.
Sourcepub fn set_strict_max_successive_merges(&mut self, val: bool)
pub fn set_strict_max_successive_merges(&mut self, val: bool)
Whether to allow filesystem reads to stay under the max_successive_merges limit.
When true, this can lead to merge writes blocking the write path waiting on filesystem
reads.
This option is temporary in case the recent change to disallow filesystem reads during merge writes has a problem and users need to undo it quickly.
Default: false
Sourcepub fn get_strict_max_successive_merges(&self) -> bool
pub fn get_strict_max_successive_merges(&self) -> bool
Returns the value of the strict_max_successive_merges option.
Sourcepub fn set_target_file_size_is_upper_bound(&mut self, val: bool)
pub fn set_target_file_size_is_upper_bound(&mut self, val: bool)
If true, RocksDB will consider the estimated tail size (filter + index + meta blocks) when deciding whether to cut a compaction output file. This helps prevent output files from exceeding the target_file_size_base due to large tail blocks. When disabled, only the data block size is considered, which may result in SST files exceeding the target_file_size_base.
Default: false
Dynamically changeable through SetOptions() API
Sourcepub fn get_target_file_size_is_upper_bound(&self) -> bool
pub fn get_target_file_size_is_upper_bound(&self) -> bool
Returns the value of the target_file_size_is_upper_bound option.
Sourcepub fn set_track_and_verify_wals(&mut self, val: bool)
pub fn set_track_and_verify_wals(&mut self, val: bool)
EXPERIMENTAL
If true, each new WAL will record various information about its predecessor WAL for verification on the predecessor WAL during WAL recovery.
It verifies the following:
- There exists at least some WAL in the DB
- It’s not compatible with
RepairDB()since this option imposes a stricter requirement on WAL than the DB went throughRepariDB()can normally meet - There exists no WAL hole where new WAL data presents while some old WAL data not yet obsolete is missing. The DB manifest indicates which WALs are obsolete.
This is intended to be a better replacement to track_and_verify_wals_in_manifest.
Default: false
Sourcepub fn get_track_and_verify_wals(&self) -> bool
pub fn get_track_and_verify_wals(&self) -> bool
Returns the value of the track_and_verify_wals option.
Sourcepub fn set_two_write_queues(&mut self, val: bool)
pub fn set_two_write_queues(&mut self, val: bool)
If enabled it uses two queues for writes, one for the ones with disable_memtable and one for the ones that also write to memtable. This allows the memtable writes not to lag behind other writes. It can be used to optimize MySQL 2PC in which only the commits, which are serial, write to memtable.
Sourcepub fn get_two_write_queues(&self) -> bool
pub fn get_two_write_queues(&self) -> bool
Returns the value of the two_write_queues option.
Sourcepub fn set_uncache_aggressiveness(&mut self, val: u32)
pub fn set_uncache_aggressiveness(&mut self, val: u32)
EXPERIMENTAL When > 0, RocksDB attempts to erase some block cache entries for files that have become obsolete, which means they are about to be deleted. To avoid excessive tracking, this “uncaching” process is iterative and speculative, meaning it could incur extra background CPU effort if the file’s blocks are generally not cached. A larger number indicates more willingness to spend CPU time to maximize block cache hit rates by erasing known-obsolete entries.
When uncache_aggressiveness=1, block cache entries for an obsolete file are only erased until any attempted erase operation fails because the block is not cached. Then no further attempts are made to erase cached blocks for that file.
For larger values, erasure is attempted until evidence incidates that the chance of success is < 0.99^(a-1), where a = uncache_aggressiveness. For example: 2 -> Attempt only while expecting >= 99% successful/useful erasure 11 -> 90% 69 -> 50% 110 -> 33% 230 -> 10% 460 -> 1% 690 -> 0.1% 1000 -> 1 in 23000 10000 -> Always (for all practical purposes) NOTE: UINT32_MAX and nearby values could take additional special meanings in the future.
Pinned cache entries (guaranteed present) are always erased if uncache_aggressiveness > 0, but are not used in predicting the chances of successful erasure of non-pinned entries.
NOTE: In the case of copied DBs (such as Checkpoints) sharing a block cache, it is possible that a file becoming obsolete doesn’t mean its block cache entries (shared among copies) are obsolete. Such a scenerio is the best case for uncache_aggressiveness = 0.
When using allow_mmap_reads=true, this option is ignored (no un-caching).
Once validated in production, the default will likely change to something around 300.
Sourcepub fn get_uncache_aggressiveness(&self) -> u32
pub fn get_uncache_aggressiveness(&self) -> u32
Returns the value of the uncache_aggressiveness option.
Sourcepub fn set_use_direct_io_for_compaction_reads(&mut self, val: bool)
pub fn set_use_direct_io_for_compaction_reads(&mut self, val: bool)
Use O_DIRECT for compaction-input SST reads only, leaving user reads buffered. Useful when sequential compaction reads would otherwise evict the hot user-read working set from the OS page cache. When this is true and use_direct_reads is false, compaction opens short-lived O_DIRECT readers for its input files instead of reusing the buffered readers cached for user reads. This is the read-side analogue of use_direct_io_for_flush_and_compaction, and the two are often paired on write-heavy workloads.
Scope and limits:
- DBOption scope (applies to all column families); no per-CF setting.
- Covers compaction inputs only. Blob-file reads and compaction-output verification (paranoid_file_checks) still use the buffered path.
- The ephemeral readers bypass the TableCache and are not counted against max_open_files. Non-L0 levels keep one reader open at a time; L0 opens all of a subcompaction’s overlapping inputs at once, so with large L0 fan-in and many subcompactions, watch RLIMIT_NOFILE.
- Every input file is reopened per compaction, so NO_FILE_OPENS and TABLE_OPEN_IO_MICROS rise while this is enabled.
The same SST can be open through both a buffered handle (user reads) and an O_DIRECT handle (the compaction scan) at once; modern Linux handles this fine. The flag is neutral or slightly negative for in-memory DBs or uniform random reads, so measure before enabling.
Has no effect when use_direct_reads is true (all reads are already O_DIRECT). Rejected at DB::Open when allow_mmap_reads is set.
On a filesystem without O_DIRECT support (e.g. tmpfs), DB::Open fails: it probes by opening the MANIFEST with O_DIRECT. The probe only checks the filesystem holding the DB directory, so if SST files live elsewhere (via db_paths/cf_paths) without O_DIRECT, Open succeeds and the first compaction fails instead.
Default: false
Sourcepub fn get_use_direct_io_for_compaction_reads(&self) -> bool
pub fn get_use_direct_io_for_compaction_reads(&self) -> bool
Returns the value of the use_direct_io_for_compaction_reads option.
Sourcepub fn set_verify_manifest_content_on_close(&mut self, val: bool)
pub fn set_verify_manifest_content_on_close(&mut self, val: bool)
If true, on DB close, read back the entire MANIFEST file and validate CRC checksums and logical record content. If corruption is detected, a fresh MANIFEST is written from in-memory state before closing.
This option is mutable with SetDBOptions().
Sourcepub fn get_verify_manifest_content_on_close(&self) -> bool
pub fn get_verify_manifest_content_on_close(&self) -> bool
Returns the value of the verify_manifest_content_on_close option.
Sourcepub fn set_verify_output_flags(&mut self, val: c_int)
pub fn set_verify_output_flags(&mut self, val: c_int)
Bitmask enum for output verification option.
Default: 0 (kVerifyNone)
Dynamically changeable (as a uint32_t) through SetOptions() API.
Sourcepub fn get_verify_output_flags(&self) -> c_int
pub fn get_verify_output_flags(&self) -> c_int
Returns the value of the verify_output_flags option.
Sourcepub fn set_verify_sst_unique_id_in_manifest(&mut self, val: bool)
pub fn set_verify_sst_unique_id_in_manifest(&mut self, val: bool)
If true, verifies the SST unique id between MANIFEST and actual file each time an SST file is opened. This check ensures an SST file is not overwritten or misplaced. A corruption error will be reported if mismatch detected, but only when MANIFEST tracks the unique id, which starts from RocksDB version 7.3. Although the tracked internal unique id is related to the one returned by GetUniqueIdFromTableProperties, that is subject to change. NOTE: verification is currently only done on SST files using block-based table format.
Setting to false should only be needed in case of unexpected problems.
Although an early version of this option opened all SST files for verification on DB::Open, that is no longer guaranteed. However, as documented in an above option, if max_open_files is -1, DB will open all files on DB::Open().
Default: true
Sourcepub fn get_verify_sst_unique_id_in_manifest(&self) -> bool
pub fn get_verify_sst_unique_id_in_manifest(&self) -> bool
Returns the value of the verify_sst_unique_id_in_manifest option.
Sourcepub fn set_wal_write_temperature(&mut self, val: c_int)
pub fn set_wal_write_temperature(&mut self, val: c_int)
Use this filesystem temperature when creating WAL files. When not kUnknown, this
overrides any temperature set by OptimizeForLogWrite functions.
Sourcepub fn get_wal_write_temperature(&self) -> c_int
pub fn get_wal_write_temperature(&self) -> c_int
Returns the value of the wal_write_temperature option.
Sourcepub fn set_write_thread_max_yield_usec(&mut self, val: u64)
pub fn set_write_thread_max_yield_usec(&mut self, val: u64)
The maximum number of microseconds that a write operation will use a yielding spin loop to coordinate with other write threads before blocking on a mutex. (Assuming write_thread_slow_yield_usec is set properly) increasing this value is likely to increase RocksDB throughput at the expense of increased CPU usage.
Default: 100
Sourcepub fn get_write_thread_max_yield_usec(&self) -> u64
pub fn get_write_thread_max_yield_usec(&self) -> u64
Returns the value of the write_thread_max_yield_usec option.
Sourcepub fn set_write_thread_slow_yield_usec(&mut self, val: u64)
pub fn set_write_thread_slow_yield_usec(&mut self, val: u64)
The latency in microseconds after which a std::this_thread::yield call (sched_yield on Linux) is considered to be a signal that other processes or threads would like to use the current core. Increasing this makes writer threads more likely to take CPU by spinning, which will show up as an increase in the number of involuntary context switches.
Default: 3
Sourcepub fn get_write_thread_slow_yield_usec(&self) -> u64
pub fn get_write_thread_slow_yield_usec(&self) -> u64
Returns the value of the write_thread_slow_yield_usec option.
Sourcepub fn get_advise_random_on_open(&self) -> bool
pub fn get_advise_random_on_open(&self) -> bool
Returns the current advise_random_on_open setting.
See Self::set_advise_random_on_open for what this controls.
Sourcepub fn get_allow_concurrent_memtable_write(&self) -> bool
pub fn get_allow_concurrent_memtable_write(&self) -> bool
Returns the current allow_concurrent_memtable_write setting.
See Self::set_allow_concurrent_memtable_write for what this controls.
Sourcepub fn get_allow_ingest_behind(&self) -> bool
pub fn get_allow_ingest_behind(&self) -> bool
Returns the current allow_ingest_behind setting.
See Self::set_allow_ingest_behind for what this controls.
Sourcepub fn get_allow_mmap_reads(&self) -> bool
pub fn get_allow_mmap_reads(&self) -> bool
Returns the current allow_mmap_reads setting.
See Self::set_allow_mmap_reads for what this controls.
Sourcepub fn get_allow_mmap_writes(&self) -> bool
pub fn get_allow_mmap_writes(&self) -> bool
Returns the current allow_mmap_writes setting.
See Self::set_allow_mmap_writes for what this controls.
Sourcepub fn get_arena_block_size(&self) -> usize
pub fn get_arena_block_size(&self) -> usize
Returns the current arena_block_size setting.
See Self::set_arena_block_size for what this controls.
Sourcepub fn get_atomic_flush(&self) -> bool
pub fn get_atomic_flush(&self) -> bool
Returns the current atomic_flush setting.
See Self::set_atomic_flush for what this controls.
Sourcepub fn get_avoid_unnecessary_blocking_io(&self) -> bool
pub fn get_avoid_unnecessary_blocking_io(&self) -> bool
Returns the current avoid_unnecessary_blocking_io setting.
See Self::set_avoid_unnecessary_blocking_io for what this controls.
Sourcepub fn get_blob_compaction_readahead_size(&self) -> u64
pub fn get_blob_compaction_readahead_size(&self) -> u64
Returns the current blob_compaction_readahead_size setting.
See Self::set_blob_compaction_readahead_size for what this controls.
Sourcepub fn get_blob_file_size(&self) -> u64
pub fn get_blob_file_size(&self) -> u64
Returns the current blob_file_size setting.
See Self::set_blob_file_size for what this controls.
Sourcepub fn get_blob_file_starting_level(&self) -> c_int
pub fn get_blob_file_starting_level(&self) -> c_int
Returns the current blob_file_starting_level setting.
See Self::set_blob_file_starting_level for what this controls.
Sourcepub fn get_blob_gc_age_cutoff(&self) -> f64
pub fn get_blob_gc_age_cutoff(&self) -> f64
Returns the current blob_gc_age_cutoff setting.
See Self::set_blob_gc_age_cutoff for what this controls.
Sourcepub fn get_blob_gc_force_threshold(&self) -> f64
pub fn get_blob_gc_force_threshold(&self) -> f64
Returns the current blob_gc_force_threshold setting.
See Self::set_blob_gc_force_threshold for what this controls.
Sourcepub fn get_bloom_locality(&self) -> u32
pub fn get_bloom_locality(&self) -> u32
Returns the current bloom_locality setting.
See Self::set_bloom_locality for what this controls.
Sourcepub fn get_bottommost_compression_options_use_zstd_dict_trainer(&self) -> bool
pub fn get_bottommost_compression_options_use_zstd_dict_trainer(&self) -> bool
Returns the current bottommost_compression_options_use_zstd_dict_trainer setting.
See Self::set_bottommost_compression_options_use_zstd_dict_trainer for what this controls.
Sourcepub fn get_bytes_per_sync(&self) -> u64
pub fn get_bytes_per_sync(&self) -> u64
Returns the current bytes_per_sync setting.
See Self::set_bytes_per_sync for what this controls.
Sourcepub fn get_compaction_readahead_size(&self) -> usize
pub fn get_compaction_readahead_size(&self) -> usize
Returns the current compaction_readahead_size setting.
See Self::set_compaction_readahead_size for what this controls.
Sourcepub fn get_compression_options_max_dict_buffer_bytes(&self) -> u64
pub fn get_compression_options_max_dict_buffer_bytes(&self) -> u64
Returns the current compression_options_max_dict_buffer_bytes setting.
See Self::set_compression_options_max_dict_buffer_bytes for what this controls.
Sourcepub fn get_compression_options_parallel_threads(&self) -> c_int
pub fn get_compression_options_parallel_threads(&self) -> c_int
Returns the current compression_options_parallel_threads setting.
See Self::set_compression_options_parallel_threads for what this controls.
Sourcepub fn get_compression_options_use_zstd_dict_trainer(&self) -> bool
pub fn get_compression_options_use_zstd_dict_trainer(&self) -> bool
Returns the current compression_options_use_zstd_dict_trainer setting.
See Self::set_compression_options_use_zstd_dict_trainer for what this controls.
Sourcepub fn get_compression_options_zstd_max_train_bytes(&self) -> c_int
pub fn get_compression_options_zstd_max_train_bytes(&self) -> c_int
Returns the maximum size of training data passed to zstd’s dictionary trainer.
Sourcepub fn get_create_if_missing(&self) -> bool
pub fn get_create_if_missing(&self) -> bool
Returns the current create_if_missing setting.
See Self::create_if_missing for what this controls.
Sourcepub fn get_create_missing_column_families(&self) -> bool
pub fn get_create_missing_column_families(&self) -> bool
Returns the current create_missing_column_families setting.
See Self::create_missing_column_families for what this controls.
Sourcepub fn get_db_write_buffer_size(&self) -> usize
pub fn get_db_write_buffer_size(&self) -> usize
Returns the current db_write_buffer_size setting.
See Self::set_db_write_buffer_size for what this controls.
Sourcepub fn get_delete_obsolete_files_period_micros(&self) -> u64
pub fn get_delete_obsolete_files_period_micros(&self) -> u64
Returns the current delete_obsolete_files_period_micros setting.
See Self::set_delete_obsolete_files_period_micros for what this controls.
Sourcepub fn get_disable_auto_compactions(&self) -> bool
pub fn get_disable_auto_compactions(&self) -> bool
Returns the current disable_auto_compactions setting.
See Self::set_disable_auto_compactions for what this controls.
Sourcepub fn get_enable_blob_files(&self) -> bool
pub fn get_enable_blob_files(&self) -> bool
Returns the current enable_blob_files setting.
See Self::set_enable_blob_files for what this controls.
Sourcepub fn get_enable_blob_gc(&self) -> bool
pub fn get_enable_blob_gc(&self) -> bool
Returns the current enable_blob_gc setting.
See Self::set_enable_blob_gc for what this controls.
Sourcepub fn get_enable_pipelined_write(&self) -> bool
pub fn get_enable_pipelined_write(&self) -> bool
Returns the current enable_pipelined_write setting.
See Self::set_enable_pipelined_write for what this controls.
Sourcepub fn get_enable_write_thread_adaptive_yield(&self) -> bool
pub fn get_enable_write_thread_adaptive_yield(&self) -> bool
Returns the current enable_write_thread_adaptive_yield setting.
See Self::set_enable_write_thread_adaptive_yield for what this controls.
Sourcepub fn get_error_if_exists(&self) -> bool
pub fn get_error_if_exists(&self) -> bool
Returns the current error_if_exists setting.
See Self::set_error_if_exists for what this controls.
Sourcepub fn get_experimental_mempurge_threshold(&self) -> f64
pub fn get_experimental_mempurge_threshold(&self) -> f64
Returns the current experimental_mempurge_threshold setting.
See Self::set_experimental_mempurge_threshold for what this controls.
Sourcepub fn get_hard_pending_compaction_bytes_limit(&self) -> usize
pub fn get_hard_pending_compaction_bytes_limit(&self) -> usize
Returns the current hard_pending_compaction_bytes_limit setting.
See Self::set_hard_pending_compaction_bytes_limit for what this controls.
Sourcepub fn get_inplace_update_num_locks(&self) -> usize
pub fn get_inplace_update_num_locks(&self) -> usize
Number of locks used for inplace update Default: 10000, if inplace_update_support = true, else 0.
Dynamically changeable through SetOptions() API.
Sourcepub fn get_inplace_update_support(&self) -> bool
pub fn get_inplace_update_support(&self) -> bool
Returns the current inplace_update_support setting.
See Self::set_inplace_update_support for what this controls.
Sourcepub fn get_is_fd_close_on_exec(&self) -> bool
pub fn get_is_fd_close_on_exec(&self) -> bool
Returns the current is_fd_close_on_exec setting.
See Self::set_is_fd_close_on_exec for what this controls.
Sourcepub fn get_keep_log_file_num(&self) -> usize
pub fn get_keep_log_file_num(&self) -> usize
Returns the current keep_log_file_num setting.
See Self::set_keep_log_file_num for what this controls.
Sourcepub fn get_level0_file_num_compaction_trigger(&self) -> c_int
pub fn get_level0_file_num_compaction_trigger(&self) -> c_int
Number of files to trigger level-0 compaction. A value <0 means that level-0 compaction will not be triggered by number of files at all.
Universal compaction: RocksDB will try to keep the number of sorted runs no more than this number. If CompactionOptionsUniversal::max_read_amp is set, then this option will be used only as a trigger to look for compaction. CompactionOptionsUniversal::max_read_amp will be the limit on the number of sorted runs.
Default: 4
Dynamically changeable through SetOptions() API.
Sourcepub fn get_level0_slowdown_writes_trigger(&self) -> c_int
pub fn get_level0_slowdown_writes_trigger(&self) -> c_int
Soft limit on number of level-0 files. We start slowing down writes at this point. A value <0 means that no writing slow down will be triggered by number of files in level-0.
Default: 20
Dynamically changeable through SetOptions() API.
Sourcepub fn get_level0_stop_writes_trigger(&self) -> c_int
pub fn get_level0_stop_writes_trigger(&self) -> c_int
Maximum number of level-0 files. We stop writes at this point.
Default: 36
Dynamically changeable through SetOptions() API.
Sourcepub fn get_level_compaction_dynamic_level_bytes(&self) -> bool
pub fn get_level_compaction_dynamic_level_bytes(&self) -> bool
Returns the current level_compaction_dynamic_level_bytes setting.
See Self::set_level_compaction_dynamic_level_bytes for what this controls.
Sourcepub fn get_log_file_time_to_roll(&self) -> usize
pub fn get_log_file_time_to_roll(&self) -> usize
Returns the current log_file_time_to_roll setting.
See Self::set_log_file_time_to_roll for what this controls.
Sourcepub fn get_manifest_preallocation_size(&self) -> usize
pub fn get_manifest_preallocation_size(&self) -> usize
Returns the current manifest_preallocation_size setting.
See Self::set_manifest_preallocation_size for what this controls.
Sourcepub fn get_manual_wal_flush(&self) -> bool
pub fn get_manual_wal_flush(&self) -> bool
Returns the current manual_wal_flush setting.
See Self::set_manual_wal_flush for what this controls.
Sourcepub fn get_max_background_jobs(&self) -> c_int
pub fn get_max_background_jobs(&self) -> c_int
Returns the current max_background_jobs setting.
See Self::set_max_background_jobs for what this controls.
Sourcepub fn get_max_bytes_for_level_base(&self) -> u64
pub fn get_max_bytes_for_level_base(&self) -> u64
Returns the current max_bytes_for_level_base setting.
See Self::set_max_bytes_for_level_base for what this controls.
Sourcepub fn get_max_bytes_for_level_multiplier(&self) -> f64
pub fn get_max_bytes_for_level_multiplier(&self) -> f64
Returns the current max_bytes_for_level_multiplier setting.
See Self::set_max_bytes_for_level_multiplier for what this controls.
Sourcepub fn get_max_compaction_bytes(&self) -> u64
pub fn get_max_compaction_bytes(&self) -> u64
Returns the current max_compaction_bytes setting.
See Self::set_max_compaction_bytes for what this controls.
Sourcepub fn get_max_file_opening_threads(&self) -> c_int
pub fn get_max_file_opening_threads(&self) -> c_int
Returns the current max_file_opening_threads setting.
See Self::set_max_file_opening_threads for what this controls.
Sourcepub fn get_max_log_file_size(&self) -> usize
pub fn get_max_log_file_size(&self) -> usize
Returns the current max_log_file_size setting.
See Self::set_max_log_file_size for what this controls.
Sourcepub fn get_max_manifest_file_size(&self) -> usize
pub fn get_max_manifest_file_size(&self) -> usize
Returns the current max_manifest_file_size setting.
See Self::set_max_manifest_file_size for what this controls.
Sourcepub fn get_max_open_files(&self) -> c_int
pub fn get_max_open_files(&self) -> c_int
Returns the current max_open_files setting.
See Self::set_max_open_files for what this controls.
Sourcepub fn get_max_sequential_skip_in_iterations(&self) -> u64
pub fn get_max_sequential_skip_in_iterations(&self) -> u64
Returns the current max_sequential_skip_in_iterations setting.
See Self::set_max_sequential_skip_in_iterations for what this controls.
Sourcepub fn get_max_subcompactions(&self) -> u32
pub fn get_max_subcompactions(&self) -> u32
Returns the current max_subcompactions setting.
See Self::set_max_subcompactions for what this controls.
Sourcepub fn get_max_successive_merges(&self) -> usize
pub fn get_max_successive_merges(&self) -> usize
Returns the current max_successive_merges setting.
See Self::set_max_successive_merges for what this controls.
Sourcepub fn get_max_total_wal_size(&self) -> u64
pub fn get_max_total_wal_size(&self) -> u64
Returns the current max_total_wal_size setting.
See Self::set_max_total_wal_size for what this controls.
Sourcepub fn get_max_write_buffer_number(&self) -> c_int
pub fn get_max_write_buffer_number(&self) -> c_int
Returns the current max_write_buffer_number setting.
See Self::set_max_write_buffer_number for what this controls.
Sourcepub fn get_max_write_buffer_size_to_maintain(&self) -> i64
pub fn get_max_write_buffer_size_to_maintain(&self) -> i64
Returns the current max_write_buffer_size_to_maintain setting.
See Self::set_max_write_buffer_size_to_maintain for what this controls.
Sourcepub fn get_memtable_avg_op_scan_flush_trigger(&self) -> u32
pub fn get_memtable_avg_op_scan_flush_trigger(&self) -> u32
Returns the current memtable_avg_op_scan_flush_trigger setting.
See Self::set_memtable_avg_op_scan_flush_trigger for what this controls.
Sourcepub fn get_memtable_huge_page_size(&self) -> usize
pub fn get_memtable_huge_page_size(&self) -> usize
Returns the current memtable_huge_page_size setting.
See Self::set_memtable_huge_page_size for what this controls.
Sourcepub fn get_memtable_op_scan_flush_trigger(&self) -> u32
pub fn get_memtable_op_scan_flush_trigger(&self) -> u32
Returns the current memtable_op_scan_flush_trigger setting.
See Self::set_memtable_op_scan_flush_trigger for what this controls.
Sourcepub fn get_memtable_prefix_bloom_size_ratio(&self) -> f64
pub fn get_memtable_prefix_bloom_size_ratio(&self) -> f64
Should really be called memtable_bloom_size_ratio. Enables a dynamic Bloom filter in
memtable to optimize many queries that must go beyond the memtable. The size in bytes
of the filter is write_buffer_size * memtable_prefix_bloom_size_ratio.
- If prefix_extractor is set, the filter includes prefixes.
- If memtable_whole_key_filtering, the filter includes whole keys.
- If both, the filter includes both.
- If neither, the feature is disabled.
If this value is larger than 0.25, it is sanitized to 0.25.
Default: 0 (disabled)
Dynamically changeable through SetOptions() API.
Sourcepub fn get_min_blob_size(&self) -> u64
pub fn get_min_blob_size(&self) -> u64
Returns the current min_blob_size setting.
See Self::set_min_blob_size for what this controls.
Sourcepub fn get_min_write_buffer_number_to_merge(&self) -> c_int
pub fn get_min_write_buffer_number_to_merge(&self) -> c_int
Returns the current min_write_buffer_number_to_merge setting.
See Self::set_min_write_buffer_number_to_merge for what this controls.
Sourcepub fn get_num_levels(&self) -> c_int
pub fn get_num_levels(&self) -> c_int
Returns the current num_levels setting.
See Self::set_num_levels for what this controls.
Sourcepub fn get_optimize_filters_for_hits(&self) -> bool
pub fn get_optimize_filters_for_hits(&self) -> bool
Returns the current optimize_filters_for_hits setting.
See Self::set_optimize_filters_for_hits for what this controls.
Sourcepub fn get_paranoid_checks(&self) -> bool
pub fn get_paranoid_checks(&self) -> bool
Returns the current paranoid_checks setting.
See Self::set_paranoid_checks for what this controls.
Sourcepub fn get_periodic_compaction_seconds(&self) -> u64
pub fn get_periodic_compaction_seconds(&self) -> u64
Returns the current periodic_compaction_seconds setting.
See Self::set_periodic_compaction_seconds for what this controls.
Sourcepub fn get_recycle_log_file_num(&self) -> usize
pub fn get_recycle_log_file_num(&self) -> usize
Returns the current recycle_log_file_num setting.
See Self::set_recycle_log_file_num for what this controls.
Sourcepub fn get_report_bg_io_stats(&self) -> bool
pub fn get_report_bg_io_stats(&self) -> bool
Returns the current report_bg_io_stats setting.
See Self::set_report_bg_io_stats for what this controls.
Sourcepub fn get_skip_stats_update_on_db_open(&self) -> bool
pub fn get_skip_stats_update_on_db_open(&self) -> bool
Returns the current skip_stats_update_on_db_open setting.
See Self::set_skip_stats_update_on_db_open for what this controls.
Sourcepub fn get_soft_pending_compaction_bytes_limit(&self) -> usize
pub fn get_soft_pending_compaction_bytes_limit(&self) -> usize
Returns the current soft_pending_compaction_bytes_limit setting.
See Self::set_soft_pending_compaction_bytes_limit for what this controls.
Sourcepub fn get_stats_dump_period_sec(&self) -> u32
pub fn get_stats_dump_period_sec(&self) -> u32
Returns the current stats_dump_period_sec setting.
See Self::set_stats_dump_period_sec for what this controls.
Sourcepub fn get_stats_persist_period_sec(&self) -> u32
pub fn get_stats_persist_period_sec(&self) -> u32
Returns the current stats_persist_period_sec setting.
See Self::set_stats_persist_period_sec for what this controls.
Sourcepub fn get_table_cache_numshardbits(&self) -> c_int
pub fn get_table_cache_numshardbits(&self) -> c_int
Number of shards used for table cache.
Sourcepub fn get_target_file_size_base(&self) -> u64
pub fn get_target_file_size_base(&self) -> u64
Returns the current target_file_size_base setting.
See Self::set_target_file_size_base for what this controls.
Sourcepub fn get_target_file_size_multiplier(&self) -> c_int
pub fn get_target_file_size_multiplier(&self) -> c_int
Returns the current target_file_size_multiplier setting.
See Self::set_target_file_size_multiplier for what this controls.
Sourcepub fn get_ttl(&self) -> u64
pub fn get_ttl(&self) -> u64
Returns the current ttl setting.
See Self::set_ttl for what this controls.
Sourcepub fn get_unordered_write(&self) -> bool
pub fn get_unordered_write(&self) -> bool
Returns the current unordered_write setting.
See Self::set_unordered_write for what this controls.
Sourcepub fn get_use_adaptive_mutex(&self) -> bool
pub fn get_use_adaptive_mutex(&self) -> bool
Returns the current use_adaptive_mutex setting.
See Self::set_use_adaptive_mutex for what this controls.
Sourcepub fn get_use_direct_io_for_flush_and_compaction(&self) -> bool
pub fn get_use_direct_io_for_flush_and_compaction(&self) -> bool
Returns the current use_direct_io_for_flush_and_compaction setting.
See Self::set_use_direct_io_for_flush_and_compaction for what this controls.
Sourcepub fn get_use_direct_reads(&self) -> bool
pub fn get_use_direct_reads(&self) -> bool
Returns the current use_direct_reads setting.
See Self::set_use_direct_reads for what this controls.
Sourcepub fn get_wal_bytes_per_sync(&self) -> u64
pub fn get_wal_bytes_per_sync(&self) -> u64
Returns the current wal_bytes_per_sync setting.
See Self::set_wal_bytes_per_sync for what this controls.
Sourcepub fn get_wal_size_limit_mb(&self) -> u64
pub fn get_wal_size_limit_mb(&self) -> u64
Returns the current wal_size_limit_mb setting.
See Self::set_wal_size_limit_mb for what this controls.
Sourcepub fn get_wal_ttl_seconds(&self) -> u64
pub fn get_wal_ttl_seconds(&self) -> u64
Returns the current wal_ttl_seconds setting.
See Self::set_wal_ttl_seconds for what this controls.
Sourcepub fn get_writable_file_max_buffer_size(&self) -> u64
pub fn get_writable_file_max_buffer_size(&self) -> u64
Returns the current writable_file_max_buffer_size setting.
See Self::set_writable_file_max_buffer_size for what this controls.
Sourcepub fn get_write_buffer_size(&self) -> usize
pub fn get_write_buffer_size(&self) -> usize
Returns the current write_buffer_size setting.
See Self::set_write_buffer_size for what this controls.
Sourcepub fn get_write_identity_file(&self) -> bool
pub fn get_write_identity_file(&self) -> bool
Returns the current write_identity_file setting.
See Self::set_write_identity_file for what this controls.
Sourcepub fn set_blob_file_starting_level(&mut self, val: c_int)
pub fn set_blob_file_starting_level(&mut self, val: c_int)
Enable blob files starting from a certain LSM tree level.
For certain use cases that have a mix of short-lived and long-lived values, it might make sense to support extracting large values only during compactions whose output level is greater than or equal to a specified LSM tree level (e.g. compactions into L1/L2/… or above). This could reduce the space amplification caused by large values that are turned into garbage shortly after being written at the price of some write amplification incurred by long-lived values whose extraction to blob files is delayed.
Default: 0
Dynamically changeable through the SetOptions() API.
Sourcepub fn set_bottommost_compression_options_max_dict_buffer_bytes(
&mut self,
max_dict_buffer_bytes: u64,
enabled: bool,
)
pub fn set_bottommost_compression_options_max_dict_buffer_bytes( &mut self, max_dict_buffer_bytes: u64, enabled: bool, )
Bottommost-level counterpart of
Self::set_compression_options_max_dict_buffer_bytes.
enabled must be true for the bottommost setting to take effect; otherwise
the non-bottommost compression options apply.
Sourcepub fn set_bottommost_compression_options_use_zstd_dict_trainer(
&mut self,
use_zstd_dict_trainer: bool,
enabled: bool,
)
pub fn set_bottommost_compression_options_use_zstd_dict_trainer( &mut self, use_zstd_dict_trainer: bool, enabled: bool, )
Bottommost-level counterpart of
Self::set_compression_options_use_zstd_dict_trainer.
enabled must be true for the bottommost setting to take effect; otherwise
the non-bottommost compression options apply.
Sourcepub fn set_compression_options_max_dict_buffer_bytes(&mut self, val: u64)
pub fn set_compression_options_max_dict_buffer_bytes(&mut self, val: u64)
Limits the max buffered data used to build the compression dictionary.
Limiting too strictly may harm dictionary effectiveness, because it forces
RocksDB to pick samples from the start of the output SST, which may not
represent the whole file. Setting it below zstd_max_train_bytes restricts
how many samples reach the dictionary trainer, and setting it below
max_dict_bytes restricts the size of the final dictionary.
Default: 0
Sourcepub fn set_compression_options_use_zstd_dict_trainer(&mut self, val: bool)
pub fn set_compression_options_use_zstd_dict_trainer(&mut self, val: bool)
Selects how zstd dictionaries are generated.
When true, buffered data is passed to zstd’s dictionary trainer. When false,
zstd’s ZDICT_finalizeDictionary() is called instead, which saves CPU during
training but usually gives a worse compression ratio.
Default: true
Sourcepub fn set_uint64add_merge_operator(&mut self)
pub fn set_uint64add_merge_operator(&mut self)
Installs the built-in merge operator that adds 64-bit counters.
Values are RocksDB fixed-width 64-bit integers, and a value that is not exactly that width is treated as 0 rather than failing the merge.
Sourcepub fn set_write_identity_file(&mut self, val: bool)
pub fn set_write_identity_file(&mut self, val: bool)
It is expected that the Identity file will be obsoleted by recording DB ID in the manifest (see write_dbid_to_manifest). Setting this to true maintains the historical behavior of writing an Identity file, while setting to false is expected to be the future default. This option might eventually be obsolete and removed as Identity files are phased out.
Trait Implementations§
Source§impl AsRawPtr<rocksdb_options_t> for Options
Available on crate feature raw-ptr only.
impl AsRawPtr<rocksdb_options_t> for Options
raw-ptr only.Source§unsafe fn as_raw_ptr(&self) -> *mut rocksdb_options_t
unsafe fn as_raw_ptr(&self) -> *mut rocksdb_options_t
Returns a raw pointer to the underlying rocksdb_options_t object.
This allows direct access to the RocksDB options C API for advanced use cases.