CMSketchAtomicUsize

Struct CMSketchAtomicUsize 

Source
pub struct CMSketchAtomicUsize { /* private fields */ }
Expand description

Count-Min Sketch that stores usize counters using atomics for concurrent updates.

Each bucket is backed by AtomicUsize, allowing lock-free increments and decrements.

Implementations§

Source§

impl CMSketchAtomicUsize

Source

pub fn new(eps: f64, confidence: f64) -> Self

Creates a new atomic sketch sized by error eps and confidence.

See CMSketchU32::new for the mapping between confidence and depth.

§Panics

Panics if eps <= 0.0 or confidence <= 0.0.

Source

pub fn inc(&self, hash: u64)

Atomically increments the count associated with hash by 1.

Source

pub fn inc_by(&self, hash: u64, count: usize)

Atomically increments the count associated with hash by count.

Saturates at the maximum value representable by the counter type and leaves the bucket unchanged if the update would overflow.

Source

pub fn dec(&self, hash: u64)

Atomically decrements the count associated with hash by 1.

Source

pub fn dec_by(&self, hash: u64, count: usize)

Atomically decrements the count associated with hash by count.

Leaves the counter unchanged if it would underflow.

Source

pub fn estimate(&self, hash: u64) -> usize

Returns the minimum counter across all rows for hash.

Source

pub fn clear(&self)

Resets all counters to zero.

Source

pub fn halve(&self)

Divides every counter by two using an atomic fetch-update.

Source

pub fn decay(&self, decay: f64)

Applies a floating-point decay factor to every counter.

Source

pub fn width(&self) -> usize

Returns the configured table width (number of columns).

Source

pub fn depth(&self) -> usize

Returns the number of hash rows.

Source

pub fn capacity(&self) -> usize

Returns the maximum representable counter for this sketch.

Source

pub fn memory(&self) -> usize

Returns the amount of memory used by the sketch in bytes.

Trait Implementations§

Source§

impl Debug for CMSketchAtomicUsize

Source§

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

Formats the value using the given formatter. 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> 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, 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.