use crate::types::level::{FileFormat, Level};
use crate::types::schema::TableSchema;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EngineConfig {
pub schema: TableSchema,
pub catalog_uri: String,
pub object_store_prefix: String,
pub wal_dir: PathBuf,
pub memtable_size_bytes: usize,
pub max_immutable_count: usize,
pub row_cache_capacity: usize,
pub level_target_bytes: Vec<u64>,
pub l0_compaction_trigger: usize,
pub l0_slowdown_trigger: usize,
pub l0_stop_trigger: usize,
pub bloom_bits_per_key: u8,
pub max_compaction_bytes: u64,
pub max_compaction_input_rows: u64,
pub flush_parallelism: usize,
pub compaction_parallelism: usize,
pub read_only: bool,
pub gc_grace_period_secs: u64,
pub dual_format_max_level: Option<u8>,
}
impl EngineConfig {
#[inline]
pub fn file_format_for(&self, output_level: Level) -> FileFormat {
match self.dual_format_max_level {
Some(max) if output_level.0 <= max => FileFormat::Dual,
_ => FileFormat::Columnar,
}
}
}
impl Default for EngineConfig {
fn default() -> Self {
Self {
schema: TableSchema::builder(String::new()).build(),
catalog_uri: String::new(),
object_store_prefix: String::new(),
wal_dir: PathBuf::from("./meru-wal"),
memtable_size_bytes: 64 * 1024 * 1024,
max_immutable_count: 4,
row_cache_capacity: 10_000,
level_target_bytes: vec![
256 * 1024 * 1024,
2 * 1024 * 1024 * 1024,
16 * 1024 * 1024 * 1024,
128 * 1024 * 1024 * 1024,
],
l0_compaction_trigger: 4,
l0_slowdown_trigger: 20,
l0_stop_trigger: 36,
bloom_bits_per_key: 10,
max_compaction_bytes: 256 * 1024 * 1024,
max_compaction_input_rows: 0,
flush_parallelism: 1,
compaction_parallelism: 2,
read_only: false,
gc_grace_period_secs: 300,
dual_format_max_level: Some(0),
}
}
}