Skip to main content

Options

Struct Options 

Source
pub struct Options {
Show 14 fields pub create_if_missing: bool, pub error_if_exists: bool, pub paranoid_checks: bool, pub write_buffer_size: usize, pub max_open_files: usize, pub block_size: usize, pub block_restart_interval: usize, pub max_file_size: usize, pub compression: CompressionType, pub reuse_logs: bool, pub filter_policy: Option<Arc<dyn FilterPolicy>>, pub block_cache: Option<Arc<BlockCache>>, pub comparator: Arc<dyn Comparator>, pub file_system: Arc<dyn FileSystem>,
}
Expand description

Options that control the overall behaviour of a database.

See include/leveldb/options.h.

Fields§

§create_if_missing: bool

Create the database if it does not already exist.

Default: false.

§error_if_exists: bool

Return an error if the database already exists.

Default: false.

§paranoid_checks: bool

Aggressively check data integrity; stop early on any detected error.

When set, acts as a database-wide verify_checksums = true: every SSTable block read (both point lookups via [Db::get] and iterator block reads) verifies its CRC32c checksum, and WAL and MANIFEST records are checksum-verified during recovery. Any mismatch returns [Error::Corruption].

This flag is OR-ed with [ReadOptions::verify_checksums] on each individual read, so per-read verification can also be enabled independently.

Default: false.

§write_buffer_size: usize

Bytes of key-value data to accumulate in the memtable before flushing to an L0 SSTable. Larger values improve bulk-load throughput at the cost of higher memory use and longer recovery time.

Default: 4 MiB.

§max_open_files: usize

Maximum number of simultaneously open file descriptors.

Controls the capacity of the table cache: max_open_files - 10 SSTable file handles are kept open at once (LRU eviction when at capacity).

Default: 1 000.

§block_size: usize

Uncompressed byte size of each SSTable data block.

Default: 4 KiB.

§block_restart_interval: usize

Number of keys between delta-encoding restart points within a block.

Default: 16.

§max_file_size: usize

Maximum size of an individual SSTable file before a new one is started during compaction.

Default: 2 MiB.

§compression: CompressionType

Compression algorithm applied to SSTable data blocks.

Use CompressionType::Zstd(level) to enable Zstd at a specific level ([-5, 22]).

Default: Snappy.

§reuse_logs: bool

Reuse existing MANIFEST and log files on open rather than creating new ones (experimental).

Not yet implemented. Accepted but ignored.

Default: false.

§filter_policy: Option<Arc<dyn FilterPolicy>>

Filter policy applied to SSTable data blocks.

When set, each SSTable written by this database includes a filter block. Before reading any data block, Table::get consults the filter; a definite-negative answer skips all data-block I/O entirely, making point lookups on absent keys much cheaper.

BloomFilterPolicy::new(10) gives roughly 1 % false positives at ~10 bits per key — the same default used by LevelDB. Pass None to disable filtering (useful for write-heavy workloads where all reads are expected to hit).

The filter is also applied when reading SSTables on reopen, provided the policy name stored in the metaindex matches the configured policy.

Default: None (no filter).

§block_cache: Option<Arc<BlockCache>>

Shared LRU block cache for decompressed SSTable data blocks.

Hot data blocks are cached here so repeated reads of the same block avoid repeated decompression and disk I/O. The cache is shared across all SSTable files opened by this database.

Set to None to disable the block cache entirely (useful when the working set does not fit in memory and caching would just churn).

Default: 8 MiB. Call BlockCache::new to create one with a custom capacity, or share a cache across databases.

§comparator: Arc<dyn Comparator>

Comparator defining the total order over user keys.

The comparator name is stored in the MANIFEST so that reopening with an incompatible comparator is detected.

Default: BytewiseComparator (lexicographic byte order).

§file_system: Arc<dyn FileSystem>

Pluggable filesystem backend for all database I/O.

Custom implementations enable in-memory filesystems (for testing), encrypted storage, cloud backends, or async I/O — without touching core database logic.

Default: PosixFileSystem (local filesystem via std::fs).

Trait Implementations§

Source§

impl Clone for Options

Source§

fn clone(&self) -> Options

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 Options

Source§

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

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

impl Default for Options

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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.