pub struct Config {
pub expansion_factor: f64,
pub auto_rebuild: bool,
pub rebuild_depth_threshold: usize,
pub tombstone_ratio_threshold: f64,
pub range_headroom: f64,
}Expand description
Configuration parameters for LearnedMap.
Fields§
§expansion_factor: f64Expansion factor for node arrays.
Controls the ratio of array size to key count. A factor of 2.0 means the array is twice as large as the number of keys (50% gaps), leaving room for future inserts without conflicts.
Higher values reduce conflicts but use more memory.
Default: 2.0. Must be >= 1.0.
auto_rebuild: boolWhether to automatically rebuild the tree after a threshold of inserts.
When enabled, the map periodically rebuilds with optimal FMCD model
fitting to keep the tree shallow and lookups fast. The rebuild threshold
is (len / 4).clamp(16, 10_000).
Default: true.
rebuild_depth_threshold: usizeMaximum subtree depth before a localized rebuild is triggered.
When an insert descends through more child nodes than this threshold,
the inserting thread rebuilds the degraded subtree inline. Only applies
when auto_rebuild is true. Set to usize::MAX to disable.
Default: 8.
tombstone_ratio_threshold: f64Maximum tombstone ratio before a localized rebuild is triggered.
When a node’s tombstone count (slots nulled by remove) exceeds this
fraction of its capacity, the removing thread rebuilds the parent
subtree inline. Only applies when auto_rebuild is true.
Set to 1.0 to disable tombstone compaction.
Default: 0.5 (compact when >50% of slots are tombstones).
range_headroom: f64Extra key range headroom for model fitting.
When greater than 0, the model covers (1 + range_headroom) times the
actual key range, leaving space for keys beyond the current max. This
prevents all out-of-range keys from clamping to the last slot.
The array size grows proportionally to maintain per-key slot density. Only applies during model fitting (bulk load and rebuild).
Default: 0.0 (no headroom). Root rebuilds internally use 1.0.
Implementations§
Source§impl Config
impl Config
Sourcepub fn expansion_factor(self, factor: f64) -> Self
pub fn expansion_factor(self, factor: f64) -> Self
Sourcepub fn auto_rebuild(self, enabled: bool) -> Self
pub fn auto_rebuild(self, enabled: bool) -> Self
Enable or disable automatic rebuilds.
Sourcepub fn rebuild_depth_threshold(self, threshold: usize) -> Self
pub fn rebuild_depth_threshold(self, threshold: usize) -> Self
Set the maximum subtree depth before localized rebuild triggers.