| Crates.io | blewm |
| lib.rs | blewm |
| version | 0.1.0 |
| created_at | 2025-07-23 12:38:16.372291+00 |
| updated_at | 2025-07-23 12:38:16.372291+00 |
| description | Blewm: A Bloom Filter that Bloo(m) my Mind |
| homepage | https://github.com/H2CO3/blewm |
| repository | https://github.com/H2CO3/blewm |
| max_upload_size | |
| id | 1764746 |
| size | 948,464 |
Blewm is a fast, concurrent, lock-free Bloom filter.
The core idea of the fast implementation (deriving multiple bit indexes/positions from a single hash) was heavily insipred by fastbloom. Therefore, it retains its excellent theoretical guarantees and practical properties.
However, Blewm further enhances the implementation in a number of ways:
usize slot, while the lower-order
bits can be used for addressing individual bits within that slot, speeding up
accesses even further.true when equating two Blewm filters using different hashers.
It would not make sense to compare those as equal, since different hashers produce
potentially different bit patterns, which is very typical of randomized hashers of
high statistical (such as the std SipHash) or downright cryptographic (e.g. AHash)
quality.constuse blewm::Filter;
fn main() {
// creates a concurrent Bloom filter using the default std hasher,
// the specified capacity, and the desirable maximum false positive rate.
let filter = Filter::new(100_000, 0.00001);
// the filter is still empty
assert_eq!(filter.contains("foo"), false);
// insert some elements
filter.insert("foo");
filter.insert("bar");
// check that they are in fact inserted
assert!(filter.contains("bar"));
assert!(filter.contains("foo"));
// check that an unrelated element is not inserted.
// NOTE: this may fail with the probability specified above, i.e., 0.00001.
assert_eq!(filter.contains("qux"), false);
}
Run Criterion benchmarks using cargo bench. The results of benchmarking the library
on my own computer can be accessed here.
The main take-away is that Blewm is easily competitive with fastbloom.