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: boolCreate the database if it does not already exist.
Default: false.
error_if_exists: boolReturn an error if the database already exists.
Default: false.
paranoid_checks: boolAggressively 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: usizeBytes 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: usizeMaximum 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: usizeUncompressed byte size of each SSTable data block.
Default: 4 KiB.
block_restart_interval: usizeNumber of keys between delta-encoding restart points within a block.
Default: 16.
max_file_size: usizeMaximum size of an individual SSTable file before a new one is started during compaction.
Default: 2 MiB.
compression: CompressionTypeCompression algorithm applied to SSTable data blocks.
Use CompressionType::Zstd(level) to enable Zstd at a specific level ([-5, 22]).
Default: Snappy.
reuse_logs: boolReuse 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).