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,
) -> Result<Maplet<K, V, Op>, MapletError>
pub fn new( capacity: usize, false_positive_rate: f64, ) -> Result<Maplet<K, V, Op>, MapletError>
Create a new maplet with default configuration
Sourcepub fn with_operator(
capacity: usize,
false_positive_rate: f64,
operator: Op,
) -> Result<Maplet<K, V, Op>, MapletError>
pub fn with_operator( capacity: usize, false_positive_rate: f64, operator: Op, ) -> Result<Maplet<K, V, Op>, MapletError>
Create a new maplet with custom operator
Sourcepub fn with_config(
config: MapletConfig,
) -> Result<Maplet<K, V, Op>, MapletError>
pub fn with_config( config: MapletConfig, ) -> Result<Maplet<K, V, Op>, MapletError>
Create a new maplet with custom configuration
Sourcepub fn with_config_and_operator(
config: MapletConfig,
operator: Op,
) -> Result<Maplet<K, V, Op>, MapletError>
pub fn with_config_and_operator( config: MapletConfig, operator: Op, ) -> Result<Maplet<K, V, Op>, MapletError>
Create a new maplet with custom configuration and operator
Sourcepub async fn insert(&self, key: K, value: V) -> Result<(), MapletError>
pub async fn insert(&self, key: K, value: V) -> Result<(), MapletError>
Insert a key-value pair into the maplet
Sourcepub async fn delete(&self, key: &K, value: &V) -> Result<bool, MapletError>
pub async fn delete(&self, key: &K, value: &V) -> Result<bool, MapletError>
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
Trait Implementations§
Auto Trait Implementations§
impl<K, V, Op> Freeze for Maplet<K, V, Op>where
Op: Freeze,
impl<K, V, Op> !RefUnwindSafe for Maplet<K, V, Op>
impl<K, V, Op> Send for Maplet<K, V, Op>
impl<K, V, Op> Sync for Maplet<K, V, Op>
impl<K, V, Op> Unpin for Maplet<K, V, Op>
impl<K, V, Op> !UnwindSafe for Maplet<K, V, Op>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more