https://github.com/freaky/blooming-rust
Disk-backed Bloom Filters for Rust
https://github.com/freaky/blooming-rust
Last synced: 11 months ago
JSON representation
Disk-backed Bloom Filters for Rust
- Host: GitHub
- URL: https://github.com/freaky/blooming-rust
- Owner: Freaky
- License: mit
- Created: 2019-06-20T16:26:20.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-20T16:34:22.000Z (almost 7 years ago)
- Last Synced: 2025-03-02T20:30:55.354Z (about 1 year ago)
- Language: Rust
- Size: 10.7 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Blooming Rust
Yet another Rust [bloom filter](https://en.wikipedia.org/wiki/Bloom_filter),
with a focus on disk-based storage.
This was going to be used for path storage in Compactor, my Windows 10 filesystem
compression tool, but I settled on a simpler structure that better fit my needs.
The basics look like they work, but it's incomplete and badly tested and mainly
here for curiosity's sake.
```rust
use blooming_rust::*;
// 1024 items, 1% false-positive rate
let mut filter = BloomFilter::with_capacity_p(1024, 0.01);
filter.insert("foo");
filter.insert("bar");
filter.save("filter.bloom").unwrap();
let mut filter = BloomFilter::load("filter.bloom").unwrap();
assert!(filter.contains("foo"));
assert!(filter.contains(BloomHash::from("bar")));
assert!(!filter.contains("baz"));
```
The filter accepts anything `Into`, which accepts anything `Hash`.
This allows for re-using the same hash calculation for multiple filters, which
might be nice for scalable filters.
It also means you can use the same filter for multiple types, which may or may
not be desirable. If not you may want to modify it to use `PhantomData` to tag
the filters and hashes with a given type.