Maplet

Struct Maplet 

Source
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>
where K: Hash + Eq + Clone + Debug + Send + Sync, V: Clone + PartialEq + Debug + Send + Sync, Op: MergeOperator<V> + Default + Send + Sync,

Source

pub fn new( capacity: usize, false_positive_rate: f64, ) -> Result<Maplet<K, V, Op>, MapletError>

Create a new maplet with default configuration

Source

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

Source

pub fn with_config( config: MapletConfig, ) -> Result<Maplet<K, V, Op>, MapletError>

Create a new maplet with custom configuration

Source

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

Source

pub async fn insert(&self, key: K, value: V) -> Result<(), MapletError>

Insert a key-value pair into the maplet

Source

pub async fn query(&self, key: &K) -> Option<V>

Query a key to get its associated value

Source

pub async fn contains(&self, key: &K) -> bool

Check if a key exists in the maplet

Source

pub async fn delete(&self, key: &K, value: &V) -> Result<bool, MapletError>

Delete a key-value pair from the maplet

Source

pub async fn len(&self) -> usize

Get the current number of items stored

Source

pub async fn is_empty(&self) -> bool

Check if the maplet is empty

Source

pub fn error_rate(&self) -> f64

Get the configured false-positive rate

Source

pub async fn load_factor(&self) -> f64

Get the current load factor

Source

pub async fn stats(&self) -> MapletStats

Get statistics about the maplet

Source

pub async fn resize(&self, new_capacity: usize) -> Result<(), MapletError>

Resize the maplet to a new capacity

Source

pub async fn merge(&self, _other: &Maplet<K, V, Op>) -> Result<(), MapletError>

Merge another maplet into this one

Trait Implementations§

Source§

impl<K, V, Op> Debug for Maplet<K, V, Op>
where K: Debug + Hash + Eq + Clone + Send + Sync, V: Debug + Clone + Send + Sync, Op: Debug + MergeOperator<V> + Send + Sync,

Source§

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

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

impl<K, V, Op> Default for Maplet<K, V, Op>
where K: Hash + Eq + Clone + Debug + Send + Sync, V: Clone + PartialEq + Debug + Send + Sync, Op: MergeOperator<V> + Default + Send + Sync,

Source§

fn default() -> Maplet<K, V, Op>

Returns the “default value” for a type. Read more

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>
where Op: Unpin, K: Unpin,

§

impl<K, V, Op> !UnwindSafe for Maplet<K, V, Op>

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more