59 lines
1.4 KiB
Rust
59 lines
1.4 KiB
Rust
|
|
use std::collections::HashSet;
|
||
|
|
|
||
|
|
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,
|
||
|
|
snapshot: &LsmStorageState,
|
||
|
|
sst_ids: &[usize],
|
||
|
|
in_level: usize,
|
||
|
|
) -> Vec<usize> {
|
||
|
|
unimplemented!()
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn generate_compaction_task(
|
||
|
|
&self,
|
||
|
|
snapshot: &LsmStorageState,
|
||
|
|
) -> Option<LeveledCompactionTask> {
|
||
|
|
unimplemented!()
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn apply_compaction_result(
|
||
|
|
&self,
|
||
|
|
snapshot: &LsmStorageState,
|
||
|
|
task: &LeveledCompactionTask,
|
||
|
|
output: &[usize],
|
||
|
|
) -> (LsmStorageState, Vec<usize>) {
|
||
|
|
unimplemented!()
|
||
|
|
}
|
||
|
|
}
|