Module parquet::bloom_filter

source ·
Expand description

Bloom filter implementation specific to Parquet, as described in the spec.

§Bloom Filter Size

Parquet uses the Split Block Bloom Filter (SBBF) as its bloom filter implementation. For each column upon which bloom filters are enabled, the offset and length of an SBBF is stored in the metadata for each row group in the parquet file. The size of each filter is initialized using a calculation based on the desired number of distinct values (NDV) and false positive probability (FPP). The FPP for a SBBF can be approximated as1:

f = (1 - e^(-k * n / m))^k

Where, f is the FPP, k the number of hash functions, n the NDV, and m the total number of bits in the bloom filter. This can be re-arranged to determine the total number of bits required to achieve a given FPP and NDV:

m = -k * n / ln(1 - f^(1/k))

SBBFs use eight hash functions to cleanly fit in SIMD lanes2, therefore k is set to 8. The SBBF will spread those m bits accross a set of b blocks that are each 256 bits, i.e., 32 bytes, in size. The number of blocks is chosen as:

b = NP2(m/8) / 32

Where, NP2 denotes the next power of two, and m is divided by 8 to be represented as bytes.

Here is a table of calculated sizes for various FPP and NDV:

NDVFPPbSize (KB)
10,0000.12568
10,0000.0151216
10,0000.0011,02432
10,0000.00011,02432
100,0000.14,096128
100,0000.014,096128
100,0000.0018,192256
100,0000.000116,384512
100,0000.0000116,384512
1,000,0000.132,7681,024
1,000,0000.0165,5362,048
1,000,0000.00165,5362,048
1,000,0000.0001131,0724,096
1,000,0000.00001131,0724,096
1,000,0000.000001262,1448,192

Structs§

  • A split block Bloom filter.