#scale #bloom-filter #cuckoo #cuckoo-filter #scalable #automatic

scalable_cuckoo_filter

A variant of Cuckoo Filter whose size automatically scales as necessary

11 releases

0.3.2 Apr 24, 2024
0.3.1 Apr 20, 2024
0.2.4 Mar 11, 2024
0.2.3 Oct 31, 2023
0.1.1 Jan 20, 2018

#253 in Data structures

Download history 95/week @ 2024-06-13 107/week @ 2024-06-20 100/week @ 2024-06-27 117/week @ 2024-07-04 120/week @ 2024-07-11 41/week @ 2024-07-18 9/week @ 2024-07-25 227/week @ 2024-08-01 263/week @ 2024-08-08 217/week @ 2024-08-15 148/week @ 2024-08-22 196/week @ 2024-08-29 208/week @ 2024-09-05 139/week @ 2024-09-12 199/week @ 2024-09-19 195/week @ 2024-09-26

795 downloads per month
Used in 2 crates

MIT license

37KB
793 lines

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

Dependencies

~295–540KB
~10K SLoC