use super::{Choice, CompactionStrategy};
use crate::{
Config,
compaction::{Input, state::CompactionState},
version::Version,
};
pub struct Strategy(pub u8, pub u8);
impl CompactionStrategy for Strategy {
fn get_name(&self) -> &'static str {
"PullDownCompaction"
}
#[expect(clippy::expect_used)]
fn choose(&self, version: &Version, _: &Config, _: &CompactionState) -> Choice {
let level = version
.level(usize::from(self.0))
.expect("source level should exist");
let next_level = version
.level(usize::from(self.1))
.expect("destination level should exist");
let mut table_ids = level.list_ids();
table_ids.extend(next_level.list_ids());
Choice::Merge(Input {
table_ids,
dest_level: self.1,
target_size: 64_000_000,
canonical_level: 6, })
}
}