Skip to main content

Config

Struct Config 

Source
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: f64

Expansion 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: bool

Whether 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: usize

Maximum 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: f64

Maximum 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: f64

Extra 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

Source

pub fn new() -> Self

Create a new configuration with default values.

Source

pub fn expansion_factor(self, factor: f64) -> Self

Set the expansion factor.

§Panics

Panics if factor < 1.0.

Source

pub fn auto_rebuild(self, enabled: bool) -> Self

Enable or disable automatic rebuilds.

Source

pub fn rebuild_depth_threshold(self, threshold: usize) -> Self

Set the maximum subtree depth before localized rebuild triggers.

Source

pub fn tombstone_ratio_threshold(self, threshold: f64) -> Self

Set the tombstone ratio threshold for compaction.

§Panics

Panics if threshold is not in (0.0, 1.0].

Source

pub fn range_headroom(self, headroom: f64) -> Self

Set the key range headroom for model fitting.

§Panics

Panics if headroom < 0.0.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

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 Config

Source§

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

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

impl Default for Config

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

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.