pub struct CountMinSketch { /* private fields */ }Expand description
Count-Min Sketch for approximate frequency estimation.
Uses depth independent hash functions (derived from a single hash via
mixing) and width counters per row. Each counter is a u8 saturating
at [CountMinSketch::MAX_COUNT] (15 by default, representing 4-bit counters).
§Error Bounds
For a sketch with width w and depth d, after N total increments:
estimate(x) <= true_count(x) + epsilon * Nwith probability>= 1 - delta- where
epsilon = e / wanddelta = (1/2)^d
Implementations§
Source§impl CountMinSketch
impl CountMinSketch
Sourcepub fn new(width: usize, depth: usize, reset_interval: u64) -> Self
pub fn new(width: usize, depth: usize, reset_interval: u64) -> Self
Create a new Count-Min Sketch with the given dimensions.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a sketch with default parameters (w=1024, d=4, reset=8192).
Sourcepub fn estimate(&self, hash: u64) -> u8
pub fn estimate(&self, hash: u64) -> u8
Estimate the frequency of a key (minimum across all rows).
Sourcepub fn total_increments(&self) -> u64
pub fn total_increments(&self) -> u64
Total number of increments since creation or last reset.
Trait Implementations§
Source§impl Clone for CountMinSketch
impl Clone for CountMinSketch
Source§fn clone(&self) -> CountMinSketch
fn clone(&self) -> CountMinSketch
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CountMinSketch
impl RefUnwindSafe for CountMinSketch
impl Send for CountMinSketch
impl Sync for CountMinSketch
impl Unpin for CountMinSketch
impl UnsafeUnpin for CountMinSketch
impl UnwindSafe for CountMinSketch
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