pub struct CountMinSketch { /* private fields */ }Expand description
Count-Min Sketch for space-efficient frequency estimation.
Uses multiple hash functions to estimate item frequencies with bounded error. Space usage is O(width * depth) regardless of stream size.
Implementations§
Source§impl CountMinSketch
impl CountMinSketch
Sourcepub fn new(width: usize, depth: usize) -> Self
pub fn new(width: usize, depth: usize) -> Self
Create a new sketch with given width and depth.
width: Number of counters per row (larger = more accurate)depth: Number of hash functions (larger = lower error probability)
Typical values: width=1000, depth=5 for ~1% error with 99% confidence.
Sourcepub fn with_seed(width: usize, depth: usize, seed: u64) -> Self
pub fn with_seed(width: usize, depth: usize, seed: u64) -> Self
Create a sketch with a specific seed for reproducibility.
Sourcepub fn estimate(&self, item: &str) -> u64
pub fn estimate(&self, item: &str) -> u64
Estimate the frequency of an item.
Returns the minimum count across all hash functions, which is guaranteed to be >= true count (never underestimates).
Sourcepub fn total_count(&self) -> u64
pub fn total_count(&self) -> u64
Get the total count of all items added.
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 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CountMinSketch
impl Debug for CountMinSketch
Source§impl<'de> Deserialize<'de> for CountMinSketch
impl<'de> Deserialize<'de> for CountMinSketch
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto 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