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
:
toml
[dependencies]
xorfilter-rs = "0.2.0"
or
toml
[dependencies]
xorfilter-rs = { git = "https://github.com/bnclabs/xorfilter" }
```rust use xorfilter::Xor8;
let mut keys: Vec
let mut filter = Xor8::new(); // new filter. filter.populate_keys(&keys); // populate keys. filter.build(); // build bitmap.
for key in 0..lookup { // there can be false positives, but no false negatives. filter.contains_key(key); } ```
Benchmark number for original golang implementation.
text
BenchmarkPopulate100000-32 2000 695796 ns/op
BenchmarkContains100000-32 200000000 7.03 ns/op
Benchmark number for this rust-lang implementation.
test
test bench_populate_100000 ... bench: 274,349 ns/iter (+/- 18,650)
test bench_contains_100000 ... bench: 7 ns/iter (+/- 0)
Measure of false-positive-rate and bits-per-entry in original golang implementation, using random set of keys.
text
bits per entry 9.864
false positive rate 0.3874
Measure of false-positive-rate and bits-per-entry in this rust-lang implementation, using random set of keys.
text
bits per entry 9.864 bits
false positive rate 0.3866%
make build
to confirm all versions of build is passing with
0 warnings and 0 errors.check.sh
with 0 warnings, 0 errors and all testcases passing.perf.sh
with 0 warnings, 0 errors and all testcases passing.cargo spellcheck
to remove common spelling mistakes.