Expand description
Hashing infrastructure shared by every structure.
Probabilistic data structures live and die by the quality of their hash function: poor mixing inflates the false-positive rate and skews cardinality estimates. This module supplies a fast, high-quality, deterministic default hasher and the machinery to derive the multiple index hashes each structure needs from a single pass over the input.
§Choosing a hasher
Every structure is generic over core::hash::BuildHasher and defaults to
DefaultHashBuilder. The default is seeded with a fixed constant, which
makes hashing reproducible: two filters built with the default hasher are
always mergeable, and serialized state round-trips byte-for-byte across
runs. The trade-off is that a fixed seed offers no defence against an
adversary who crafts inputs to collide on purpose. When the inputs are
untrusted, substitute a randomly-seeded BuildHasher such as
std::collections::hash_map::RandomState:
use std::collections::hash_map::RandomState;
use bloom_lib::BloomFilter;
let filter: BloomFilter<&str, RandomState> =
BloomFilter::with_hasher(1_000, 0.01, RandomState::new()).unwrap();Structs§
- Default
Hash Builder - A
BuildHasherthat yieldsDefaultHasherinstances seeded with a fixed constant. - Default
Hasher - A fast, non-cryptographic 64-bit hasher with strong avalanche behaviour.