Peter Toth created SPARK-62421:
----------------------------------

             Summary: Add BloomFilter V3 that keeps the expected false positive 
probability of small filters, and use it as default
                 Key: SPARK-62421
                 URL: https://issues.apache.org/jira/browse/SPARK-62421
             Project: Spark
          Issue Type: Improvement
          Components: Spark Core
    Affects Versions: 5.0.0
            Reporter: Peter Toth


{{BloomFilter}} V2 is far over its expected false positive probability when it 
is small and that probability is low. Measured with random long items, as a 
multiple of the expected probability:
- 16 items at 1e-4: 43 times;
- 16 items at 1e-5: 469 times;
- 100 items at 1e-5: 52 times;
- 1000 items at 1e-5: 7.9 times.

At the default 3% it is as expected.

V2 takes the k bit positions of an item as {{h1 * Integer.MAX_VALUE + i * h2}} 
modulo the number of bits. When {{h2}} and the number of bits share a large 
factor, the positions repeat after a few steps. The item then sets and checks 
only a few bits. The number of bits is always a multiple of 64, so such factors 
are common. Any scheme that takes all positions from two values modulo the 
number of bits also has only as many position patterns as the square of the 
number of bits, which shows in the smallest filters.

Per-partition runtime bloom filters (SPARK-60541) are this small, since the 
items of the creation side are split over its partition keys. Skipping a row 
group or a page with them needs a low false positive probability.

The proposal is a V3 with the binary format of V2, which takes each bit 
position from its own mix of the item's 64-bit hash. In the same measurement it 
stays at or under the expected probability. It makes {{mightContain}} about 
10-15% slower. V3 becomes the default, as V2 did in SPARK-47547. V1 and V2 
filters can still be read and created.




--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to