|
ADS
Algorithms and Data Structures
|
The blocked filter of Bloom, beyond the book: the engineered filter of ADS [see BloomFilter.h for the standard one and BloomVariants.h for its variants]. More...
#include "ADS/Contract.h"#include "ADS/SimdInline.h"#include "ADS/dictionary/FastHash.h"#include "ADS/external/MappedFile.h"#include <algorithm>#include <cmath>#include <cstddef>#include <cstdint>#include <string_view>#include <vector>#include "ADS/set/impl/BlockedBloomFilter.tpp"Go to the source code of this file.
Classes | |
| class | ADS::BlockedBloomFilter< T, H > |
| a filter of Bloom in blocks of 256 bits, 8 bits per item More... | |
Namespaces | |
| namespace | ADS |
The blocked filter of Bloom, beyond the book: the engineered filter of ADS [see BloomFilter.h for the standard one and BloomVariants.h for its variants].
Its bits are cut into blocks of 256 bits, 8 words of 32 bits, and an item sets 8 bits of one block, one in each word: the block is \( \lfloor h_1 B / 2^{32} \rfloor \) for \( B \) blocks, the bit of the word \( i \) is the top 5 bits of \( h_0 s_i \bmod 2^{32} \) for 8 odd constants \( s_i \), \( h_1 \) and \( h_0 \) being the high and the low half of the hash of the item. A query then reads one block, i.e., one line of cache, instead of the \( k \) lines of the standard filter, and makes its 8 bits by one product, one shift and one variable shift of a vector of 8 words (by the vectors of Highway, with ADS_WITH_HIGHWAY [see SimdInline.h]), or by 8 products of 32 bits on any machine, with the same result.
Putting the bits of an item in one block costs false positives: the blocks get different numbers of items (a Poisson number of mean \( \lambda = 256 n / m \)), and the crowded ones answer yes more often, so that the false positives are the mean over the loads \( j \) of the probability \( ( 1 - ( 1 - 1 / 32 )^j )^8 \) of a block of \( j \) items [see falsePositiveRate()]: about \( 1.26 \% \) at 10 bits per item, against \( 0.82 \% \) of the standard filter with 7 hashes, and \( 0.31 \% \) at 13.5 bits against \( 0.15 \% \) (Putze, Sanders and Singler). The split of the 8 bits into 8 words is that of the filters of Impala and of the format Parquet; the number of blocks is any, not a power of 2, so that the bits per item are those asked.
The hash of an item is h( x ), taken as it is if H declares is_avalanching [see FastHash.h], and mixed by hashWord() otherwise (the identity of std::hash on the integers); insertHash() and maybeHash() take a hash of 64 bits that is already random.
The contracts [see Contract.h]: at least one block; an item inserted is maybe there, a postcondition; two filters united have the same number of blocks. The operations are defined in BlockedBloomFilter.tpp.