2024-01-20 11:11:09 +08:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
|
|
|
|
|
use crate::lsm_storage::LsmStorageState;
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
|
|
|
pub struct LeveledCompactionTask {
|
|
|
|
|
// 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,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
|
pub struct LeveledCompactionOptions {
|
|
|
|
|
pub level_size_multiplier: usize,
|
|
|
|
|
pub level0_file_num_compaction_trigger: usize,
|
|
|
|
|
pub max_levels: usize,
|
|
|
|
|
pub base_level_size_mb: usize,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub struct LeveledCompactionController {
|
|
|
|
|
options: LeveledCompactionOptions,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl LeveledCompactionController {
|
|
|
|
|
pub fn new(options: LeveledCompactionOptions) -> Self {
|
|
|
|
|
Self { options }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn find_overlapping_ssts(
|
|
|
|
|
&self,
|
2024-01-20 11:14:19 +08:00
|
|
|
_snapshot: &LsmStorageState,
|
|
|
|
|
_sst_ids: &[usize],
|
|
|
|
|
_in_level: usize,
|
2024-01-20 11:11:09 +08:00
|
|
|
) -> Vec<usize> {
|
|
|
|
|
unimplemented!()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn generate_compaction_task(
|
|
|
|
|
&self,
|
2024-01-20 11:14:19 +08:00
|
|
|
_snapshot: &LsmStorageState,
|
2024-01-20 11:11:09 +08:00
|
|
|
) -> Option<LeveledCompactionTask> {
|
|
|
|
|
unimplemented!()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn apply_compaction_result(
|
|
|
|
|
&self,
|
2024-01-20 11:14:19 +08:00
|
|
|
_snapshot: &LsmStorageState,
|
|
|
|
|
_task: &LeveledCompactionTask,
|
|
|
|
|
_output: &[usize],
|
2024-01-20 11:11:09 +08:00
|
|
|
) -> (LsmStorageState, Vec<usize>) {
|
|
|
|
|
unimplemented!()
|
|
|
|
|
}
|
|
|
|
|
}
|