Given an expected number of distinct keys n and a target false positive rate
p, report the filter bloom_join() will build: total bits m, number of
hash functions k, and the false positive rate that combination achieves.
Value
A list with class "bloom_params" containing:
n: input n
p_target: target p
m_bits: total bits, a power of two
bytes: total bytes
bits_per_key: m_bits / n
k: number of hash functions
fpr_est: the rate that (m, n, k) achieves
Details
The numbers come from the same C++ routine the filter itself uses, so this
cannot describe a filter the package does not build. It used to: it advertised
a blocked layout, with a block_bits argument and a blocks count, that the
filter has never implemented, and reported an m and k the filter did not
use.
Sizing is the standard one (Broder & Mitzenmacher), as used by Guava's
BloomFilter.create and Spark's:
bits_per_key = -log(p) / (log(2)^2)
k = log(2) * (m / n)
fpr(m, n, k) = (1 - exp(-k * n / m))^k
m is then rounded up to a power of two, because the filter indexes with a
bit mask rather than a modulo, and k is taken from the rounded m. Rounding
only ever adds bits, so the achieved rate lands at or under the request.