Expand description
§roughly
Probabilistic data structures for Rust — because sometimes close enough is good enough.
This crate provides space-efficient, approximate data structures for common tasks:
BloomFilter— membership testing with configurable false positive rateHyperLogLog— cardinality estimation (count distinct elements)CountMinSketch— frequency estimation (how often items appear)
§Quick Start
use roughly::prelude::*;
// Bloom filter: "Have I seen this before?"
let mut bloom = BloomFilter::builder()
.expected_items(10_000)
.false_positive_rate(0.01)
.build();
bloom.insert(&"hello");
assert!(bloom.contains(&"hello"));
// HyperLogLog: "How many unique items?"
let mut hll = HyperLogLog::builder().std_error(0.01).build();
for i in 0..100_000u64 {
hll.insert(&i);
}
println!("Estimated unique count: {}", hll.count());
// Count-Min Sketch: "How often did this appear?"
let mut cms = CountMinSketch::builder().build();
cms.insert_many(&"popular", 1000);
println!("Estimated frequency: {}", cms.estimate(&"popular"));Re-exports§
pub use bloom::BloomFilter;pub use countmin::CountMinSketch;pub use hyperloglog::HyperLogLog;
Modules§
- bloom
- Bloom filter implementation for probabilistic set membership testing.
- countmin
- Count-Min Sketch implementation for frequency estimation.
- hash
- Hashing utilities for probabilistic data structures.
- hyperloglog
- HyperLogLog implementation for cardinality estimation.
- prelude
- Convenient re-exports of the main types and traits.
- traits
- Traits defining common interfaces for probabilistic data structures.