scalable_cuckoo_filter

Crates.ioscalable_cuckoo_filter
lib.rsscalable_cuckoo_filter
version0.3.2
sourcesrc
created_at2018-01-20 08:06:17.24486
updated_at2024-04-24 08:25:32.897117
descriptionA variant of Cuckoo Filter whose size automatically scales as necessary
homepagehttps://github.com/sile/scalable_cuckoo_filter
repositoryhttps://github.com/sile/scalable_cuckoo_filter
max_upload_size
id47504
size41,933
Takeru Ohta (sile)

documentation

README

scalable_cuckoo_filter

scalable_cuckoo_filter Documentation Actions Status Coverage Status License: MIT

A variant of Cuckoo Filter whose size automatically scales as necessary.

Documentation

Examples

Basic usage:

use scalable_cuckoo_filter::ScalableCuckooFilter;

let mut filter = ScalableCuckooFilter::new(100, 0.001);
assert!(!filter.contains("foo"));
filter.insert("foo");
assert!(filter.contains("foo"));

Filter grows automatically:

use scalable_cuckoo_filter::ScalableCuckooFilter;

let mut filter = ScalableCuckooFilter::new(100, 0.001);
assert_eq!(filter.capacity(), 128);

for i in 0..1000 {
    filter.insert(&i);
}
assert_eq!(filter.capacity(), 1923);

Filter shrinking:

use scalable_cuckoo_filter::ScalableCuckooFilter;

let mut filter = ScalableCuckooFilter::new(1000, 0.001);
for i in 0..100 {
    filter.insert(&i);
}
assert_eq!(filter.capacity(), 1024);
assert_eq!(filter.bits(), 14336);

filter.shrink_to_fit();
for i in 0..100 {
    assert!(filter.contains(&i));
}
assert_eq!(filter.capacity(), 128);
assert_eq!(filter.bits(), 1792);

References

Commit count: 85

cargo fmt