Skip to main content

Config

Struct Config 

Source
pub struct Config<F: Fs = StdFs> {
Show 19 fields pub level_count: u8, pub data_block_compression_policy: CompressionPolicy, pub index_block_compression_policy: CompressionPolicy, pub data_block_restart_interval_policy: RestartIntervalPolicy, pub index_block_restart_interval_policy: RestartIntervalPolicy, pub data_block_size_policy: BlockSizePolicy, pub index_block_pinning_policy: PinningPolicy, pub filter_block_pinning_policy: PinningPolicy, pub top_level_index_block_pinning_policy: PinningPolicy, pub top_level_filter_block_pinning_policy: PinningPolicy, pub data_block_hash_ratio_policy: HashRatioPolicy, pub index_block_partitioning_policy: PartitioningPolicy, pub filter_block_partitioning_policy: PartitioningPolicy, pub index_block_partition_size_policy: BlockSizePolicy, pub filter_block_partition_size_policy: BlockSizePolicy, pub filter_policy: FilterPolicy, pub compaction_filter_factory: Option<Arc<dyn Factory>>, pub prefix_extractor: Option<Arc<dyn PrefixExtractor>>, pub merge_operator: Option<Arc<dyn MergeOperator>>, /* private fields */
}
Expand description

Tree configuration builder

The generic parameter F selects the filesystem backend. It defaults to StdFs, so existing code that writes Config without a type parameter continues to work unchanged.

Fields§

§level_count: u8

Number of levels of the LSM tree (depth of tree)

Once set, the level count is fixed (in the “manifest” file)

§data_block_compression_policy: CompressionPolicy

What type of compression is used for data blocks

§index_block_compression_policy: CompressionPolicy

What type of compression is used for index blocks

§data_block_restart_interval_policy: RestartIntervalPolicy

Restart interval inside data blocks

§index_block_restart_interval_policy: RestartIntervalPolicy

Restart interval inside index blocks

§data_block_size_policy: BlockSizePolicy

Block size of data blocks

§index_block_pinning_policy: PinningPolicy

Whether to pin index blocks

§filter_block_pinning_policy: PinningPolicy

Whether to pin filter blocks

§top_level_index_block_pinning_policy: PinningPolicy

Whether to pin top level index of partitioned index

§top_level_filter_block_pinning_policy: PinningPolicy

Whether to pin top level index of partitioned filter

§data_block_hash_ratio_policy: HashRatioPolicy

Data block hash ratio

§index_block_partitioning_policy: PartitioningPolicy

Whether to partition index blocks

§filter_block_partitioning_policy: PartitioningPolicy

Whether to partition filter blocks

§index_block_partition_size_policy: BlockSizePolicy

Partition size when using partitioned indexes

§filter_block_partition_size_policy: BlockSizePolicy

Partition size when using partitioned filters

§filter_policy: FilterPolicy

Filter construction policy

§compaction_filter_factory: Option<Arc<dyn Factory>>

Compaction filter factory

§prefix_extractor: Option<Arc<dyn PrefixExtractor>>

Prefix extractor for prefix bloom filters.

When set, the bloom filter indexes extracted prefixes in addition to full keys, allowing prefix scans to skip segments that contain no matching prefixes.

§merge_operator: Option<Arc<dyn MergeOperator>>

Merge operator for commutative operations

When set, enables merge() operations that store partial updates which are lazily combined during reads and compaction.

Implementations§

Source§

impl Config

Source

pub fn new<P: AsRef<Path>>( path: P, seqno: SequenceNumberCounter, visible_seqno: SequenceNumberCounter, ) -> Self

Initializes a new config

Source

pub fn open(self) -> Result<AnyTree>

Opens a tree using the config.

§Errors

Will return Err if an IO error occurs. Returns Error::ZstdDictMismatch if the compression policy references a dict_id that doesn’t match the configured dictionary.

Source

pub fn new_with_generators<P: AsRef<Path>>( path: P, seqno: SharedSequenceNumberGenerator, visible_seqno: SharedSequenceNumberGenerator, ) -> Self

Like Config::new, but accepts pre-built shared generators.

This is useful when the caller already has SharedSequenceNumberGenerator instances (e.g., from a higher-level database that shares generators across multiple trees).

Source§

impl<F: Fs> Config<F>

Source

pub fn seqno_generator(self, generator: SharedSequenceNumberGenerator) -> Self

Overrides the sequence number generator.

By default, SequenceNumberCounter is used. This allows plugging in a custom generator (e.g., HLC for distributed databases).

Source

pub fn visible_seqno_generator( self, generator: SharedSequenceNumberGenerator, ) -> Self

Overrides the visible sequence number generator.

Source

pub fn use_cache(self, cache: Arc<Cache>) -> Self

Sets the global cache.

You can create a global Cache and share it between multiple trees to cap global cache memory usage.

Defaults to a cache with 16 MiB of capacity per tree.

Source

pub fn use_descriptor_table( self, descriptor_table: Option<Arc<DescriptorTable>>, ) -> Self

Sets the file descriptor cache.

Can be shared across trees.

Source

pub fn expect_point_read_hits(self, b: bool) -> Self

If true, the last level will not build filters, reducing the filter size of a database by ~90% typically.

Enable this only if you know that point reads generally are expected to find a key-value pair.

Source

pub fn filter_block_partitioning_policy(self, policy: PinningPolicy) -> Self

Sets the partitioning policy for filter blocks.

Source

pub fn index_block_partitioning_policy(self, policy: PinningPolicy) -> Self

Sets the partitioning policy for index blocks.

Source

pub fn filter_block_pinning_policy(self, policy: PinningPolicy) -> Self

Sets the pinning policy for filter blocks.

Source

pub fn index_block_pinning_policy(self, policy: PinningPolicy) -> Self

Sets the pinning policy for index blocks.

Source

pub fn data_block_restart_interval_policy( self, policy: RestartIntervalPolicy, ) -> Self

Sets the restart interval inside data blocks.

A higher restart interval saves space while increasing lookup times inside data blocks.

Default = 16

Source

pub fn filter_policy(self, policy: FilterPolicy) -> Self

Sets the filter construction policy.

Source

pub fn data_block_compression_policy(self, policy: CompressionPolicy) -> Self

Sets the compression method for data blocks.

Source

pub fn index_block_compression_policy(self, policy: CompressionPolicy) -> Self

Sets the compression method for index blocks.

Source

pub fn data_block_size_policy(self, policy: BlockSizePolicy) -> Self

Sets the data block size policy.

Source

pub fn data_block_hash_ratio_policy(self, policy: HashRatioPolicy) -> Self

Sets the hash ratio policy for data blocks.

If greater than 0.0, a hash index is embedded into data blocks that can speed up reads inside the data block.

Source

pub fn with_kv_separation(self, opts: Option<KvSeparationOptions>) -> Self

Toggles key-value separation.

Source

pub fn with_compaction_filter_factory( self, factory: Option<Arc<dyn Factory>>, ) -> Self

Installs a custom compaction filter.

Source

pub fn prefix_extractor(self, extractor: Arc<dyn PrefixExtractor>) -> Self

Sets the prefix extractor for prefix bloom filters.

When configured, bloom filters will index key prefixes returned by the extractor. Prefix scans can then skip segments whose bloom filter reports no match for the scan prefix.

Source

pub fn with_merge_operator(self, op: Option<Arc<dyn MergeOperator>>) -> Self

Installs a merge operator for commutative operations.

When set, enables crate::AbstractTree::merge which stores partial updates (operands) that are lazily combined during reads and compaction.

Source

pub fn comparator(self, comparator: SharedComparator) -> Self

Sets a custom user key comparator.

When configured, all key ordering (memtable, block index, merge, range scans) uses this comparator instead of the default lexicographic byte ordering.

§Important

The comparator’s crate::UserComparator::name is persisted when a tree is first created. On subsequent opens the stored name is compared against the supplied comparator’s name — a mismatch causes the open to fail with Error::ComparatorMismatch.

Source

pub fn with_encryption( self, encryption: Option<Arc<dyn EncryptionProvider>>, ) -> Self

Sets the block-level encryption provider for encryption at rest.

When set, all blocks written to SST files are encrypted after compression and before checksumming, using the provided EncryptionProvider.

The caller is responsible for key management and rotation. See [crate::Aes256GcmProvider] (behind the encryption feature) for a ready-to-use AES-256-GCM implementation.

Important constraints:

  • Encryption state is NOT recorded in SST metadata. Opening an encrypted tree without the correct provider (or vice versa) will cause block validation errors, not silent corruption.
  • Blob files (KV-separated large values) are NOT covered by block-level encryption. Large values stored via KV separation remain in plaintext on disk.

Trait Implementations§

Source§

impl Default for Config

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<F> Freeze for Config<F>

§

impl<F = StdFs> !RefUnwindSafe for Config<F>

§

impl<F> Send for Config<F>

§

impl<F> Sync for Config<F>

§

impl<F> Unpin for Config<F>

§

impl<F> UnsafeUnpin for Config<F>

§

impl<F = StdFs> !UnwindSafe for Config<F>

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