BloomFilterStat
Bloom filter - probabilistic set-membership test with no false negatives. bits bits are split across hashes positions per insert, derived from the hasher (default SplitMix64) via the Kirsch-Mitzenmacher double-hashing scheme.
False-positive rate is approximately (1 - e^(-hashes * n / bits))^hashes where n is the number of distinct inserts. Memory is bits / 64 Longs; mergeable element-wise via bitwise OR when bits and hashes match.
bits must be a power of two and a multiple of 64.
Use cases: membership queries with bounded memory; feature flags, deduplication of seen keys, "have we seen this user before". Tolerates false positives but never false negatives.
Memory: O(bits / 64) Longs, plus a totalSeen counter.
Update: O(hashes) per observation; hashes independent atomic OR ops.
Concurrency: Atomic OR on a striped Long array. Lock-free and exact under every Concurrency level; bit sets are idempotent and commutative.
Constructors
BloomFilterStat
Properties
bits
concurrency
Thread-safety mode fixed at construction. See Concurrency for the shared contract and the implementation's KDoc for its cell and lock strategy.
hasher
Mixer seeding the double-hashing scheme; defaults to SplitMix64.
hashes
Functions
create
Create an independent accumulator at the configured baseline. A null concurrency preserves this accumulator's mode; a non-null value overrides it. Modality subtypes narrow the return type to preserve the input shape.
merge
Fold a compatible snapshot values into this accumulator at timestampNanos. Implementations document whether the combine is exact or approximate and which state the snapshot omits. The source accumulator is unaffected.
Time-dependent statistics, such as windows, place the snapshot at timestampNanos, which must share the clock the caller uses for updates and reads. Time-independent statistics ignore it.
read
Return the current result evaluated at timestampNanos. Time-independent statistics ignore the timestamp. Reading does not add an observation.
Snapshot consistency depends on the implementation's synchronisation. Locks protect coupled state under Concurrency.Strict and Concurrency.HighWrite; independently updated cells and JVM striped adders can still yield a best-effort snapshot. Concurrency.Relaxed permits drift across coupled cells.
reset
Restore the configured baseline, including any prior seed. Preserves the configuration and concurrency.