Skip to main content

UniversalCompactOptions

Struct UniversalCompactOptions 

Source
pub struct UniversalCompactOptions { /* private fields */ }

Implementations§

Source§

impl UniversalCompactOptions

Source

pub fn set_size_ratio(&mut self, ratio: c_int)

Sets the percentage flexibility while comparing file size. If the candidate file(s) size is 1% smaller than the next file’s size, then include next file into this candidate set.

Default: 1

Source

pub fn set_min_merge_width(&mut self, num: c_int)

Sets the minimum number of files in a single compaction run.

Default: 2

Source

pub fn set_max_merge_width(&mut self, num: c_int)

Sets the maximum number of files in a single compaction run.

Default: UINT_MAX

Source

pub fn set_max_size_amplification_percent(&mut self, v: c_int)

sets the size amplification.

It is defined as the amount (in percentage) of additional storage needed to store a single byte of data in the database. For example, a size amplification of 2% means that a database that contains 100 bytes of user-data may occupy upto 102 bytes of physical storage. By this definition, a fully compacted database has a size amplification of 0%. Rocksdb uses the following heuristic to calculate size amplification: it assumes that all files excluding the earliest file contribute to the size amplification.

Default: 200, which means that a 100 byte database could require upto 300 bytes of storage.

Source

pub fn set_compression_size_percent(&mut self, v: c_int)

Sets the percentage of compression size.

If this option is set to be -1, all the output files will follow compression type specified.

If this option is not negative, we will try to make sure compressed size is just above this value. In normal cases, at least this percentage of data will be compressed. When we are compacting to a new file, here is the criteria whether it needs to be compressed: assuming here are the list of files sorted by generation time: A1…An B1…Bm C1…Ct where A1 is the newest and Ct is the oldest, and we are going to compact B1…Bm, we calculate the total size of all the files as total_size, as well as the total size of C1…Ct as total_C, the compaction output file will be compressed iff total_C / total_size < this percentage

Default: -1

Source

pub fn set_stop_style(&mut self, style: UniversalCompactionStopStyle)

Sets the algorithm used to stop picking files into a single compaction run.

Default: ::Total

Source

pub fn get_stop_style(&self) -> Option<UniversalCompactionStopStyle>

The stop style set by Self::set_stop_style.

UniversalCompactionStopStyle covers both styles RocksDB defines today, so None only shows up if a future release adds one.

Source

pub fn set_allow_trivial_move(&mut self, val: bool)

Option to optimize the manual compaction by enabling trivial move for non overlapping files. Default: false

Source

pub fn get_allow_trivial_move(&self) -> bool

Returns the value of the allow_trivial_move option.

Source

pub fn set_incremental(&mut self, val: bool)

EXPERIMENTAL If true, try to limit compaction size under max_compaction_bytes. This might cause higher write amplification, but can prevent some problem caused by large compactions. Default: false

Source

pub fn get_incremental(&self) -> bool

Returns the value of the incremental option.

Source

pub fn set_max_read_amp(&mut self, val: c_int)

The limit on the number of sorted runs. RocksDB will try to keep the number of sorted runs at most this number. While compactions are running, the number of sorted runs may be temporarily higher than this number.

Since universal compaction checks if there is compaction to do when the number of sorted runs is at least level0_file_num_compaction_trigger, it is suggested to set level0_file_num_compaction_trigger to be no larger than max_read_amp.

Values: -1: special flag to let RocksDB pick default. Currently, RocksDB will fall back to the behavior before this option is introduced, which is to use level0_file_num_compaction_trigger as the limit. This may change in the future to behave as 0 below. 0: Let RocksDB auto-tune. Currently, we determine the max number of sorted runs based on the current DB size, size_ratio and write_buffer_size. Note that this is only supported for the default stop_style kCompactionStopStyleTotalSize. For kCompactionStopStyleSimilarSize, this behaves as if -1 is configured. N > 0: limit the number of sorted runs to be at most N. N should be at least the compaction trigger specified by level0_file_num_compaction_trigger. If 0 < max_read_amp < level0_file_num_compaction_trigger, Status::NotSupported() will be returned during DB open. N < -1: Status::NotSupported() will be returned during DB open.

Default: -1

Source

pub fn get_max_read_amp(&self) -> c_int

Returns the value of the max_read_amp option.

Source

pub fn set_reduce_file_locking(&mut self, val: bool)

If true, auto universal compaction picking will adjust to minimize locking of input files when bottom priority compactions are waiting to run. This can increase the likelihood of existing L0s being selected for compaction, thereby improving write stall and reducing read regression. It may increase the overrall write amplification and compaction load on low priority threads.

Default: true (enabled)

This options does not apply to manual compactions.

This option is temporary in case turning on this feature causes problems and users need to undo it quickly. This option is planned for removal in the near future with default value set to true.

Dynamically changeable through the SetOptions() API.

Source

pub fn get_reduce_file_locking(&self) -> bool

Returns the value of the reduce_file_locking option.

Source

pub fn get_compression_size_percent(&self) -> c_int

Returns the current compression_size_percent setting.

See Self::set_compression_size_percent for what this controls.

Source

pub fn get_max_merge_width(&self) -> c_int

Returns the current max_merge_width setting.

See Self::set_max_merge_width for what this controls.

Source

pub fn get_max_size_amplification_percent(&self) -> c_int

Returns the current max_size_amplification_percent setting.

See Self::set_max_size_amplification_percent for what this controls.

Source

pub fn get_min_merge_width(&self) -> c_int

Returns the current min_merge_width setting.

See Self::set_min_merge_width for what this controls.

Source

pub fn get_size_ratio(&self) -> c_int

Returns the current size_ratio setting.

See Self::set_size_ratio for what this controls.

Trait Implementations§

Source§

impl Default for UniversalCompactOptions

Source§

fn default() -> Self

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

impl Drop for UniversalCompactOptions

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.