Expand description
OFilter is a fast thread-safe Bloom filter.
§Examples
Basic Bloom filter:
use ofilter::Bloom;
let mut filter: Bloom<usize> = Bloom::new(100);
filter.set(&42);
assert!(filter.check(&42));
Thread-safe version:
use ofilter::SyncBloom;
// does not need to be `mut`
let filter: SyncBloom<usize> = SyncBloom::new(100);
filter.set(&42);
assert!(filter.check(&42));
Streaming Bloom filter:
use ofilter::Stream;
use std::collections::HashSet;
let mut set: HashSet<usize> = HashSet::new();
let mut filter: Stream<usize> = Stream::new(100);
for i in 0..1_000 {
for j in 0..1_000 {
let item = i * 1_000 + j;
filter.set(&item);
set.insert(item);
}
set.retain(|x| filter.check(x));
}
println!("{}", set.len());
// Out of 1 million entries, only a few hundreds left
assert!(set.len() < 500);
Thread-safe streaming version:
use ofilter::SyncStream;
use std::collections::HashSet;
let mut set: HashSet<usize> = HashSet::new();
// does not need to be `mut`
let filter: SyncStream<usize> = SyncStream::new(100);
for i in 0..1_000 {
for j in 0..1_000 {
let item = i * 1_000 + j;
filter.set(&item);
set.insert(item);
}
set.retain(|x| filter.check(x));
}
println!("{}", set.len());
// Out of 1 million entries, only a few hundreds left
assert!(set.len() < 500);
Structs§
- Bit-Precision Dynamic Array
- Bloom filter.
- Parameters used to build bloom filters.
- Streaming Bloom filter.
- Thread-safe Bloom filter.
- Thread-safe streaming Bloom filter.
Constants§
- URL to report bugs.
- Default size of the bit vector, in bits.
- Default false positive rate.
- Default number of hash functions.
- Default number of items the filter should contain.