47 lines
1.2 KiB
Rust
47 lines
1.2 KiB
Rust
|
|
use serde::{Deserialize, Serialize};
|
||
|
|
|
||
|
|
use crate::lsm_storage::LsmStorageState;
|
||
|
|
|
||
|
|
#[derive(Debug, Clone)]
|
||
|
|
pub struct SimpleLeveledCompactionOptions {
|
||
|
|
pub size_ratio_percent: usize,
|
||
|
|
pub level0_file_num_compaction_trigger: usize,
|
||
|
|
pub max_levels: usize,
|
||
|
|
}
|
||
|
|
|
||
|
|
#[derive(Debug, Serialize, Deserialize)]
|
||
|
|
pub struct SimpleLeveledCompactionTask {
|
||
|
|
// if upper_level is `None`, then it is L0 compaction
|
||
|
|
pub upper_level: Option<usize>,
|
||
|
|
pub upper_level_sst_ids: Vec<usize>,
|
||
|
|
pub lower_level: usize,
|
||
|
|
pub lower_level_sst_ids: Vec<usize>,
|
||
|
|
pub is_lower_level_bottom_level: bool,
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct SimpleLeveledCompactionController {
|
||
|
|
options: SimpleLeveledCompactionOptions,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl SimpleLeveledCompactionController {
|
||
|
|
pub fn new(options: SimpleLeveledCompactionOptions) -> Self {
|
||
|
|
Self { options }
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn generate_compaction_task(
|
||
|
|
&self,
|
||
|
|
snapshot: &LsmStorageState,
|
||
|
|
) -> Option<SimpleLeveledCompactionTask> {
|
||
|
|
unimplemented!()
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn apply_compaction_result(
|
||
|
|
&self,
|
||
|
|
snapshot: &LsmStorageState,
|
||
|
|
task: &SimpleLeveledCompactionTask,
|
||
|
|
output: &[usize],
|
||
|
|
) -> (LsmStorageState, Vec<usize>) {
|
||
|
|
unimplemented!()
|
||
|
|
}
|
||
|
|
}
|