pub struct Maplet<K, V, Op>where
K: Hash + Eq + Clone + Debug + Send + Sync,
V: Clone + Debug + Send + Sync,
Op: MergeOperator<V> + Send + Sync,{ /* private fields */ }
Expand description
Core maplet data structure
A maplet provides space-efficient approximate key-value mappings with one-sided error guarantees. When queried with a key k, it returns a value m[k] that is an approximation of the true value M[k].
The maplet guarantees that M[k] ≺ m[k] for some application-specific ordering relation ≺, and that m[k] = M[k] with probability at least 1-ε.
Implementations§
Source§impl<K, V, Op> Maplet<K, V, Op>
impl<K, V, Op> Maplet<K, V, Op>
Sourcepub fn new(capacity: usize, false_positive_rate: f64) -> MapletResult<Self>
pub fn new(capacity: usize, false_positive_rate: f64) -> MapletResult<Self>
Create a new maplet with default configuration
Sourcepub fn with_operator(
capacity: usize,
false_positive_rate: f64,
operator: Op,
) -> MapletResult<Self>
pub fn with_operator( capacity: usize, false_positive_rate: f64, operator: Op, ) -> MapletResult<Self>
Create a new maplet with custom operator
Sourcepub fn with_config(config: MapletConfig) -> MapletResult<Self>
pub fn with_config(config: MapletConfig) -> MapletResult<Self>
Create a new maplet with custom configuration
Sourcepub fn with_config_and_operator(
config: MapletConfig,
operator: Op,
) -> MapletResult<Self>
pub fn with_config_and_operator( config: MapletConfig, operator: Op, ) -> MapletResult<Self>
Create a new maplet with custom configuration and operator
Sourcepub async fn insert(&self, key: K, value: V) -> MapletResult<()>
pub async fn insert(&self, key: K, value: V) -> MapletResult<()>
Insert a key-value pair into the maplet
Sourcepub async fn delete(&self, key: &K, value: &V) -> MapletResult<bool>
pub async fn delete(&self, key: &K, value: &V) -> MapletResult<bool>
Delete a key-value pair from the maplet
Sourcepub fn error_rate(&self) -> f64
pub fn error_rate(&self) -> f64
Get the configured false-positive rate
Sourcepub async fn load_factor(&self) -> f64
pub async fn load_factor(&self) -> f64
Get the current load factor
Sourcepub async fn stats(&self) -> MapletStats
pub async fn stats(&self) -> MapletStats
Get statistics about the maplet
Sourcepub async fn resize(&self, new_capacity: usize) -> MapletResult<()>
pub async fn resize(&self, new_capacity: usize) -> MapletResult<()>
Resize the maplet to a new capacity
Sourcepub async fn merge(&self, _other: &Maplet<K, V, Op>) -> MapletResult<()>
pub async fn merge(&self, _other: &Maplet<K, V, Op>) -> MapletResult<()>
Merge another maplet into this one