pub(crate) mod fifo;
pub(crate) mod leveled;
pub(crate) mod drop_range;
pub mod filter;
mod flavour;
pub(crate) mod major;
pub(crate) mod movedown;
pub(crate) mod pulldown;
pub(crate) mod state;
pub(crate) mod stream;
pub(crate) mod tiered;
pub(crate) mod worker;
pub use fifo::Strategy as Fifo;
pub use filter::{CompactionFilter, Factory, ItemAccessor, Verdict};
pub use leveled::Strategy as Leveled;
pub use tiered::Strategy as SizeTiered;
pub use {
fifo::NAME as FIFO_COMPACTION_NAME, leveled::NAME as LEVELED_COMPACTION_NAME,
tiered::NAME as TIERED_COMPACTION_NAME,
};
pub type Levelled = Leveled;
#[doc(hidden)]
pub use movedown::Strategy as MoveDown;
#[doc(hidden)]
pub use pulldown::Strategy as PullDown;
use crate::{
HashSet, KvPair, TableId, compaction::state::CompactionState, config::Config, version::Version,
};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CompactionAction {
Nothing,
Merged,
Moved,
Dropped,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CompactionResult {
pub action: CompactionAction,
pub dest_level: Option<u8>,
pub tables_in: usize,
pub tables_out: usize,
}
impl CompactionResult {
#[must_use]
pub fn nothing() -> Self {
Self {
action: CompactionAction::Nothing,
dest_level: None,
tables_in: 0,
tables_out: 0,
}
}
}
#[derive(Debug, Eq, PartialEq)]
pub struct Input {
pub table_ids: HashSet<TableId>,
pub dest_level: u8,
pub canonical_level: u8,
pub target_size: u64,
}
#[derive(Debug, Eq, PartialEq)]
pub enum Choice {
DoNothing,
Move(Input),
Merge(Input),
Drop(HashSet<TableId>),
}
#[expect(clippy::module_name_repetitions)]
pub trait CompactionStrategy {
fn get_name(&self) -> &'static str;
#[doc(hidden)]
fn get_config(&self) -> Vec<KvPair> {
vec![]
}
fn choose(&self, version: &Version, config: &Config, state: &CompactionState) -> Choice;
}