Implementation of Xor Filters: Faster and Smaller Than Bloom and Cuckoo Filters in rust-lang, Journal of Experimental Algorithmics (to appear).
This package is a port from its golang implementation.
Add the following under project's Cargo.toml:
[dependencies]
xorfilter-rs = "0.2.0"or
[dependencies]
xorfilter-rs = { git = "https://github.com/prataprc/xorfilter" }use xorfilter::{xor8::Xor8Builder, BuildHasherDefault};
fn main() {
let num_keys = 1000;
let lookup = 10;
let mut b = Xor8Builder::<BuildHasherDefault>::default();
for i in 0..num_keys {
if i % 2 == 0 {
b.insert(&i);
}
}
// build bitmap.
let filter = b.build().unwrap();
for key in 0..lookup {
// there can be false positives, but no false negatives.
println!("{key}: {}", filter.contains(&key));
}
}- Serialize / Deserialize Xor8 type.
- Incrementally adding keys to a pre-built Xor8 instance.
- Gather benchmark results for other implementations - Go, C, C++, Erlang, Java, Python.
Following are the results for a set of 10-million u64 keys:
- Build time is measured in
Seconds, for 10 million entries. - Membership is measured in
Nanosec, for single lookup in a set of 10 million entries. - FPP = False Positive Probability measured in percentage
- Simple workflow. Fork - Modify - Pull request.
- Before creating a PR,
- Run
make buildto confirm all versions of build is passing with 0 warnings and 0 errors. - Run
check.shwith 0 warnings, 0 errors and all test-cases passing. - Run
perf.shwith 0 warnings, 0 errors and all test-cases passing. - Install and run
cargo spellcheckto remove common spelling mistakes.
- Run
- Developer certificate of origin is preferred.
