Skip to main content

CompactionStrategy

Trait CompactionStrategy 

Source
pub trait CompactionStrategy: Send + Sync {
    // Required methods
    fn get_name(&self) -> &'static str;
    fn choose(
        &self,
        version: &Version,
        config: &Config,
        state: &CompactionState,
    ) -> Choice;

    // Provided method
    fn pending_compaction_bytes(&self, _version: &Version) -> u64 { ... }
}
Expand description

Trait for a compaction strategy

The strategy receives the levels of the LSM-tree as argument and emits a choice on what to do.

Required Methods§

Source

fn get_name(&self) -> &'static str

Gets the compaction strategy name.

Source

fn choose( &self, version: &Version, config: &Config, state: &CompactionState, ) -> Choice

Decides on what to do based on the current state of the LSM-tree’s levels

This is the purely structural decision (level shape, run counts, size targets); it deliberately does not see the live runtime config. The orchestrator layers the runtime-config-driven housekeeping fallback on top (the density-based columnar rewrite).

Provided Methods§

Source

fn pending_compaction_bytes(&self, _version: &Version) -> u64

Estimated bytes pending compaction: on-disk data currently sitting above its level’s target size that must eventually be rewritten downward (a RocksDB estimate-pending-compaction-bytes analog). A scheduler / tiering consumer reads it as a compaction-debt signal; 0 means the tree is at or below its target shape.

The default is 0 for strategies without a size-target notion of debt (FIFO, drop-range, major one-shot); the leveled strategy overrides it with the per-level overflow sum.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl CompactionStrategy for lsm_tree::compaction::Fifo

Source§

impl CompactionStrategy for lsm_tree::compaction::Leveled

Source§

impl CompactionStrategy for lsm_tree::compaction::EccHeal

Source§

impl CompactionStrategy for lsm_tree::compaction::SizeTiered