cmsketch

Crates.iocmsketch
lib.rscmsketch
version0.2.0
sourcesrc
created_at2023-05-17 08:42:19.62681
updated_at2024-03-08 09:01:01.687593
descriptionA count min sketch implementation in Rust
homepagehttps://github.com/mrcroxx/cmsketch-rs
repositoryhttps://github.com/mrcroxx/cmsketch-rs
max_upload_size
id866779
size28,803
Croxx (MrCroxx)

documentation

README

cmsketch

A count min sketch implementation in Rust.

Inspired by Facebook/CacheLib and Caffeine.

Usage

use cmsketch::CMSketchU32;

const ERROR: f64 = 0.01;
const CONFIDENCE: f64 = 0.95;

fn main() {
    let mut cms = CMSketchU32::new(ERROR, CONFIDENCE);
    for i in 0..10 {
        for _ in 0..i {
            cms.inc(i);
        }
    }
    
    for i in 0..10 {
        assert!(cms.estimate(i) >= i as u32);
    }
    
    cms.halve();
    
    for i in 0..10 {
        assert!(cms.estimate(i) >= (i as f64 * 0.5) as u32);
    }
}

Roadmap

  • simd halve
  • benchmark
Commit count: 7

cargo fmt