use tessarikv_format::Compression;
use super::compaction::CompactionStyle;
use super::keyspace::KeyspaceOptions;
use super::keyspace_bounds::validate;
use crate::Result;
#[derive(Debug, Clone)]
#[must_use]
pub struct KeyspaceOptionsBuilder {
pub(super) options: KeyspaceOptions,
}
impl KeyspaceOptionsBuilder {
pub const fn memtable_bytes(mut self, value: u64) -> Self {
self.options.memtable_bytes = value;
self
}
pub const fn max_immutable_memtables(mut self, value: u32) -> Self {
self.options.max_immutable_memtables = value;
self
}
pub const fn block_bytes(mut self, value: u64) -> Self {
self.options.block_bytes = value;
self
}
pub const fn block_restart_interval(mut self, value: u32) -> Self {
self.options.block_restart_interval = value;
self
}
pub const fn bloom_bits_per_key(mut self, value: u32) -> Self {
self.options.bloom_bits_per_key = value;
self
}
pub const fn level0_compaction_trigger(mut self, value: u32) -> Self {
self.options.level0_compaction_trigger = value;
self
}
pub const fn level0_slowdown_trigger(mut self, value: u32) -> Self {
self.options.level0_slowdown_trigger = value;
self
}
pub const fn level0_stop_trigger(mut self, value: u32) -> Self {
self.options.level0_stop_trigger = value;
self
}
pub const fn max_compactions(mut self, value: u32) -> Self {
self.options.max_compactions = value;
self
}
pub const fn disable_auto_compactions(mut self, value: bool) -> Self {
self.options.disable_auto_compactions = value;
self
}
pub const fn max_subcompactions(mut self, value: u32) -> Self {
self.options.max_subcompactions = value;
self
}
pub const fn soft_pending_compaction_bytes(mut self, value: u64) -> Self {
self.options.soft_pending_compaction_bytes = value;
self
}
pub const fn compaction(mut self, value: CompactionStyle) -> Self {
self.options.compaction = value;
self
}
pub const fn hard_pending_compaction_bytes(mut self, value: u64) -> Self {
self.options.hard_pending_compaction_bytes = value;
self
}
pub const fn level_base_bytes(mut self, value: u64) -> Self {
self.options.level_base_bytes = value;
self
}
pub const fn level_size_multiplier(mut self, value: u32) -> Self {
self.options.level_size_multiplier = value;
self
}
pub const fn target_file_bytes(mut self, value: u64) -> Self {
self.options.target_file_bytes = value;
self
}
pub const fn compression(mut self, value: Compression) -> Self {
self.options.compression = value;
self
}
pub const fn bottommost_compression(mut self, value: Option<Compression>) -> Self {
self.options.bottommost_compression = value;
self
}
pub fn build(self) -> Result<KeyspaceOptions> {
validate(&self.options)?;
Ok(self.options)
}
}