DBOptions

Struct DBOptions 

Source
pub struct DBOptions {
Show 25 fields pub memtable_capacity: usize, pub wal_sync_policy: SyncPolicy, pub recovery_mode: RecoveryMode, pub base_level_size: u64, pub size_ratio: u64, pub num_levels: usize, pub vlog_threshold: Option<usize>, pub background_compaction: bool, pub background_flush: bool, pub adaptive_compaction: bool, pub max_memory_bytes: Option<usize>, pub min_disk_space_bytes: Option<u64>, pub max_open_files: Option<usize>, pub block_cache_capacity: usize, pub buffer_pool_capacity: Option<usize>, pub group_commit_delay_us: u64, pub group_commit_max_batch_size: usize, pub l0_slowdown_writes_trigger: usize, pub l0_stop_writes_trigger: usize, pub compaction_filter: Option<Arc<dyn CompactionFilter>>, pub merge_operator: Option<Arc<dyn MergeOperator>>, pub disable_metrics: bool, pub use_direct_wal: bool, pub skip_wal: bool, pub compression: CompressionType, /* private fields */
}
Expand description

Database configuration options.

Use the builder pattern to configure options, then call open() to create the database. For simple cases, use DB::open().

§Quick Start

use seerdb::DBOptions;

// Simple: just open with defaults (recommended for most cases)
let db = seerdb::DB::open("./my_db")?;

// Custom: tune specific options
let db = DBOptions::default()
    .memtable_capacity(512 * 1024 * 1024)  // 512MB write buffer
    .open("./my_db")?;

§Configuration Profiles

For common workloads, use a preset profile:

ProfileUse CaseMemory
default()General purpose256 MB
embedded()CLI tools, mobile, IoT64 MB
high_throughput()Write-heavy servers512 MB
large_scale()1B+ keys, analytics1 GB

§Option Reference

§Essential Options

Most users only need these:

OptionDefaultDescription
memtable_capacity256 MBWrite buffer size
sync_policySyncDataDurability level (see platform notes)
compressionLZ4SSTable compression

§Tuning Options

For performance optimization:

OptionDefaultDescription
vlog_threshold4 KBValue size for key-value separation
block_cache_capacity16K blocksRead cache size
adaptive_compactionfalseAuto-tune compaction
background_compactiontrueAsync compaction

§Expert Options

Rarely needed, for specific tuning:

OptionDefaultDescription
l0_slowdown_writes_trigger20L0 count before throttling
l0_stop_writes_trigger36L0 count before blocking
group_commit_delay_us0Batching delay
skip_walfalseDisable durability

§Platform Notes

macOS Performance: The default SyncPolicy::SyncData is ~13x slower on macOS than Linux due to APFS treating fdatasync() like fsync(). If your application can tolerate data loss on power failure (but not app crashes), use Barrier:

use seerdb::{DBOptions, SyncPolicy};

// 13x faster writes on macOS, still survives app crashes
let db = DBOptions::default()
    .sync_policy(SyncPolicy::Barrier)
    .open("./my_db")?;

See SyncPolicy for durability trade-offs.

Fields§

§memtable_capacity: usize§wal_sync_policy: SyncPolicy§recovery_mode: RecoveryMode§base_level_size: u64§size_ratio: u64§num_levels: usize§vlog_threshold: Option<usize>§background_compaction: bool§background_flush: bool§adaptive_compaction: bool§max_memory_bytes: Option<usize>§min_disk_space_bytes: Option<u64>§max_open_files: Option<usize>§block_cache_capacity: usize§buffer_pool_capacity: Option<usize>§group_commit_delay_us: u64§group_commit_max_batch_size: usize§l0_slowdown_writes_trigger: usize§l0_stop_writes_trigger: usize§compaction_filter: Option<Arc<dyn CompactionFilter>>§merge_operator: Option<Arc<dyn MergeOperator>>§disable_metrics: bool§use_direct_wal: bool§skip_wal: bool§compression: CompressionType

Implementations§

Source§

impl DBOptions

Source

pub fn new() -> Self

Create a new options builder with default values.

Source

pub fn open(&self, path: impl AsRef<Path>) -> Result<DB>

Open a database with these options at the given path.

This is the primary way to open a configured database. For simple cases with default options, use DB::open() instead.

Options can be reused to open multiple databases with the same configuration:

§Examples
use seerdb::DBOptions;

let opts = DBOptions::default()
    .memtable_capacity(128 * 1024 * 1024)
    .background_compaction(true);

let db1 = opts.open("./db1")?;
let db2 = opts.open("./db2")?;  // Reuse same options
Source

pub fn embedded() -> Self

Configuration for memory-constrained embedded applications.

Use when: CLI tools, mobile apps, IoT devices, or single-process apps with limited RAM.

OptionDefaultEmbeddedReason
memtable_capacity256 MB64 MBReduce memory footprint
block_cache_capacity16K4KFewer cached blocks
background_compactiontruefalseSimpler threading model
background_flushtruefalsePredictable latency
metricsenableddisabledReduce overhead
direct_walfalsetrueSkip pipelined WAL
Source

pub fn high_throughput() -> Self

Configuration for write-heavy server workloads.

Use when: High-throughput services, streaming data ingestion, or write-heavy OLTP workloads.

OptionDefaultHigh-ThroughputReason
memtable_capacity256 MB512 MBLarger write buffer, fewer flushes
block_cache_capacity16K64KMore cached blocks for reads
adaptive_compactionfalsetrueAuto-tune compaction strategy
Source

pub fn large_scale() -> Self

Configuration for large datasets (1B+ keys, 100GB+ data).

Use when: Data warehousing, analytics backends, or any workload where dataset size exceeds available RAM.

OptionDefaultLarge-ScaleReason
memtable_capacity256 MB1 GBBatch more writes before flush
block_cache_capacity16K128KCache more blocks for large scans
base_level_size10 MB64 MBReduce level count for large data
vlog_threshold4 KB1 KBSeparate values earlier (less write amp)
adaptive_compactionfalsetrueAuto-tune for varying load
Source

pub const fn memtable_capacity(self, bytes: usize) -> Self

Set the memtable capacity in bytes.

Source

pub const fn block_cache_capacity(self, num_blocks: usize) -> Self

Set the block cache capacity (number of blocks).

Source

pub const fn sync_policy(self, policy: SyncPolicy) -> Self

Set the WAL sync policy.

Source

pub const fn background_compaction(self, enabled: bool) -> Self

Enable or disable background compaction.

Source

pub const fn background_flush(self, enabled: bool) -> Self

Enable or disable background flush.

Source

pub const fn metrics(self, enabled: bool) -> Self

Enable or disable metrics collection.

Source

pub const fn direct_wal(self, enabled: bool) -> Self

Enable or disable direct WAL writes.

Source

pub const fn skip_wal(self, enabled: bool) -> Self

Enable or disable WAL entirely.

Source

pub const fn vlog_threshold(self, threshold: Option<usize>) -> Self

Set the value size threshold for vLog separation.

Source

pub const fn compression(self, compression: CompressionType) -> Self

Set the compression type for SSTables.

Source

pub fn merge_operator(self, operator: Arc<dyn MergeOperator>) -> Self

Set the merge operator for read-modify-write operations.

Source

pub const fn recovery_mode(self, mode: RecoveryMode) -> Self

Set the recovery mode for WAL replay.

Source

pub const fn base_level_size(self, bytes: u64) -> Self

Set the base level size for LSM compaction (bytes).

Source

pub const fn size_ratio(self, ratio: u64) -> Self

Set the size ratio between LSM levels.

Source

pub const fn num_levels(self, levels: usize) -> Self

Set the number of LSM levels.

Source

pub const fn adaptive_compaction(self, enabled: bool) -> Self

Enable or disable adaptive compaction.

Source

pub const fn max_memory_bytes(self, bytes: Option<usize>) -> Self

Set the maximum memory budget in bytes.

Source

pub const fn min_disk_space_bytes(self, bytes: Option<u64>) -> Self

Set the minimum disk space threshold in bytes.

Source

pub const fn max_open_files(self, max: Option<usize>) -> Self

Set the maximum number of open files.

Source

pub const fn buffer_pool_capacity(self, capacity: Option<usize>) -> Self

Set the buffer pool capacity.

Source

pub const fn group_commit_delay_us(self, us: u64) -> Self

Set the group commit delay in microseconds.

Source

pub const fn group_commit_max_batch_size(self, size: usize) -> Self

Set the maximum batch size for group commits.

Source

pub const fn l0_slowdown_writes_trigger(self, count: usize) -> Self

Set the L0 file count that triggers write slowdown.

Source

pub const fn l0_stop_writes_trigger(self, count: usize) -> Self

Set the L0 file count that stops writes entirely.

Source

pub fn compaction_filter(self, filter: Arc<dyn CompactionFilter>) -> Self

Set a compaction filter for custom key filtering during compaction.

Trait Implementations§

Source§

impl Clone for DBOptions

Source§

fn clone(&self) -> DBOptions

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DBOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DBOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<K, Q> Comparable<Q> for K
where K: Borrow<Q> + ?Sized, Q: Ord + ?Sized,

Source§

fn compare(&self, key: &Q) -> Ordering

Compare self to key and return their ordering.
Source§

impl<K, Q> Equivalent<Q> for K
where K: Borrow<Q> + ?Sized, Q: Eq + ?Sized,

Source§

fn equivalent(&self, key: &Q) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more