// Copyright (c) 2022-2025 Alex Chi Z // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. 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, pub upper_level_sst_ids: Vec, pub lower_level: usize, pub lower_level_sst_ids: Vec, 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 { unimplemented!() } pub fn generate_compaction_task( &self, _snapshot: &LsmStorageState, ) -> Option { unimplemented!() } pub fn apply_compaction_result( &self, _snapshot: &LsmStorageState, _task: &LeveledCompactionTask, _output: &[usize], _in_recovery: bool, ) -> (LsmStorageState, Vec) { unimplemented!() } }