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: u8Number of levels of the LSM tree (depth of tree)
Once set, the level count is fixed (in the “manifest” file)
data_block_compression_policy: CompressionPolicyWhat type of compression is used for data blocks
index_block_compression_policy: CompressionPolicyWhat type of compression is used for index blocks
data_block_restart_interval_policy: RestartIntervalPolicyRestart interval inside data blocks
index_block_restart_interval_policy: RestartIntervalPolicyRestart interval inside index blocks
data_block_size_policy: BlockSizePolicyBlock size of data blocks
index_block_pinning_policy: PinningPolicyWhether to pin index blocks
filter_block_pinning_policy: PinningPolicyWhether to pin filter blocks
top_level_index_block_pinning_policy: PinningPolicyWhether to pin top level index of partitioned index
top_level_filter_block_pinning_policy: PinningPolicyWhether to pin top level index of partitioned filter
data_block_hash_ratio_policy: HashRatioPolicyData block hash ratio
index_block_partitioning_policy: PartitioningPolicyWhether to partition index blocks
filter_block_partitioning_policy: PartitioningPolicyWhether to partition filter blocks
index_block_partition_size_policy: BlockSizePolicyPartition size when using partitioned indexes
filter_block_partition_size_policy: BlockSizePolicyPartition size when using partitioned filters
filter_policy: FilterPolicyFilter 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
impl Config
Sourcepub fn new<P: AsRef<Path>>(
path: P,
seqno: SequenceNumberCounter,
visible_seqno: SequenceNumberCounter,
) -> Self
pub fn new<P: AsRef<Path>>( path: P, seqno: SequenceNumberCounter, visible_seqno: SequenceNumberCounter, ) -> Self
Initializes a new config
Sourcepub fn open(self) -> Result<AnyTree>
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.
Sourcepub fn new_with_generators<P: AsRef<Path>>(
path: P,
seqno: SharedSequenceNumberGenerator,
visible_seqno: SharedSequenceNumberGenerator,
) -> Self
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>
impl<F: Fs> Config<F>
Sourcepub fn seqno_generator(self, generator: SharedSequenceNumberGenerator) -> Self
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).
Sourcepub fn visible_seqno_generator(
self,
generator: SharedSequenceNumberGenerator,
) -> Self
pub fn visible_seqno_generator( self, generator: SharedSequenceNumberGenerator, ) -> Self
Overrides the visible sequence number generator.
Sourcepub fn use_cache(self, cache: Arc<Cache>) -> Self
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.
Sourcepub fn use_descriptor_table(
self,
descriptor_table: Option<Arc<DescriptorTable>>,
) -> Self
pub fn use_descriptor_table( self, descriptor_table: Option<Arc<DescriptorTable>>, ) -> Self
Sets the file descriptor cache.
Can be shared across trees.
Sourcepub fn expect_point_read_hits(self, b: bool) -> Self
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.
Sourcepub fn filter_block_partitioning_policy(self, policy: PinningPolicy) -> Self
pub fn filter_block_partitioning_policy(self, policy: PinningPolicy) -> Self
Sets the partitioning policy for filter blocks.
Sourcepub fn index_block_partitioning_policy(self, policy: PinningPolicy) -> Self
pub fn index_block_partitioning_policy(self, policy: PinningPolicy) -> Self
Sets the partitioning policy for index blocks.
Sourcepub fn filter_block_pinning_policy(self, policy: PinningPolicy) -> Self
pub fn filter_block_pinning_policy(self, policy: PinningPolicy) -> Self
Sets the pinning policy for filter blocks.
Sourcepub fn index_block_pinning_policy(self, policy: PinningPolicy) -> Self
pub fn index_block_pinning_policy(self, policy: PinningPolicy) -> Self
Sets the pinning policy for index blocks.
Sourcepub fn data_block_restart_interval_policy(
self,
policy: RestartIntervalPolicy,
) -> Self
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
Sourcepub fn filter_policy(self, policy: FilterPolicy) -> Self
pub fn filter_policy(self, policy: FilterPolicy) -> Self
Sets the filter construction policy.
Sourcepub fn data_block_compression_policy(self, policy: CompressionPolicy) -> Self
pub fn data_block_compression_policy(self, policy: CompressionPolicy) -> Self
Sets the compression method for data blocks.
Sourcepub fn index_block_compression_policy(self, policy: CompressionPolicy) -> Self
pub fn index_block_compression_policy(self, policy: CompressionPolicy) -> Self
Sets the compression method for index blocks.
Sourcepub fn data_block_size_policy(self, policy: BlockSizePolicy) -> Self
pub fn data_block_size_policy(self, policy: BlockSizePolicy) -> Self
Sets the data block size policy.
Sourcepub fn data_block_hash_ratio_policy(self, policy: HashRatioPolicy) -> Self
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.
Sourcepub fn with_kv_separation(self, opts: Option<KvSeparationOptions>) -> Self
pub fn with_kv_separation(self, opts: Option<KvSeparationOptions>) -> Self
Toggles key-value separation.
Sourcepub fn with_compaction_filter_factory(
self,
factory: Option<Arc<dyn Factory>>,
) -> Self
pub fn with_compaction_filter_factory( self, factory: Option<Arc<dyn Factory>>, ) -> Self
Installs a custom compaction filter.
Sourcepub fn prefix_extractor(self, extractor: Arc<dyn PrefixExtractor>) -> Self
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.
Sourcepub fn with_merge_operator(self, op: Option<Arc<dyn MergeOperator>>) -> Self
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.
Sourcepub fn comparator(self, comparator: SharedComparator) -> Self
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.
Sourcepub fn with_encryption(
self,
encryption: Option<Arc<dyn EncryptionProvider>>,
) -> Self
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.