CountMinSketch

Struct CountMinSketch 

Source
pub struct CountMinSketch<K: ?Sized, C: New> { /* private fields */ }
Expand description

An implementation of a count-min sketch data structure with conservative updating for increased accuracy.

This data structure is also known as a counting Bloom filter.

See An Improved Data Stream Summary: The Count-Min Sketch and its Applications and New Directions in Traffic Measurement and Accounting for background on the count-min sketch with conservative updating.

Implementations§

Source§

impl<K, C> CountMinSketch<K, C>
where K: Hash + ?Sized, C: New + for<'a> UnionAssign<&'a C> + Intersect,

Source

pub fn new(probability: f64, tolerance: f64, config: C::Config) -> Self

Create an empty CountMinSketch data structure with the specified error tolerance.

Source

pub fn push<Q, V: ?Sized>(&mut self, key: &Q, value: &V) -> C
where Q: Hash + ?Sized, K: Borrow<Q>, C: for<'a> AddAssign<&'a V> + IntersectPlusUnionIsPlus,

“Visit” an element.

Source

pub fn union_assign<Q>(&mut self, key: &Q, value: &C)
where Q: Hash + ?Sized, K: Borrow<Q>,

Union the aggregated value for key with value.

Source

pub fn get<Q>(&self, key: &Q) -> C
where Q: Hash + ?Sized, K: Borrow<Q>,

Retrieve an estimate of the aggregated value for key.

Source

pub fn clear(&mut self)

Clears the CountMinSketch data structure, as if it was new.

Trait Implementations§

Source§

impl<K: ?Sized, C: New + Clone> Clone for CountMinSketch<K, C>

Source§

fn clone(&self) -> Self

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<K: ?Sized, C: New> Debug for CountMinSketch<K, C>

Source§

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

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

impl<'de, K: ?Sized, C> Deserialize<'de> for CountMinSketch<K, C>
where C: Deserialize<'de> + New, <C as New>::Config: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<K: ?Sized, C> Serialize for CountMinSketch<K, C>
where C: Serialize + New, <C as New>::Config: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<K, C> Freeze for CountMinSketch<K, C>
where <C as New>::Config: Freeze, K: ?Sized,

§

impl<K, C> RefUnwindSafe for CountMinSketch<K, C>
where <C as New>::Config: RefUnwindSafe, C: RefUnwindSafe, K: ?Sized,

§

impl<K, C> Send for CountMinSketch<K, C>
where <C as New>::Config: Send, C: Send, K: ?Sized,

§

impl<K, C> Sync for CountMinSketch<K, C>
where <C as New>::Config: Sync, C: Sync, K: ?Sized,

§

impl<K, C> Unpin for CountMinSketch<K, C>
where <C as New>::Config: Unpin, C: Unpin, K: ?Sized,

§

impl<K, C> UnwindSafe for CountMinSketch<K, C>
where <C as New>::Config: UnwindSafe, C: UnwindSafe, K: ?Sized,

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> 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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,