|
ADS
Algorithms and Data Structures
|
The variants and the analysis of the filter of Bloom [see BloomFilter.h for the standard one], beyond the book: More...
#include "ADS/Contract.h"#include "ADS/dictionary/RandomHashing.h"#include "ADS/external/MappedFile.h"#include "ADS/set/BloomFilter.h"#include <algorithm>#include <cmath>#include <cstddef>#include <cstdint>#include <functional>#include <limits>#include <string_view>#include <unordered_set>#include <utility>#include <vector>#include "ADS/set/impl/BloomVariants.tpp"Go to the source code of this file.
Classes | |
| class | ADS::SpectralBloomFilter< T, C, H > |
| a filter of Bloom of \( m \) counters of the type C and \( r \) hashes, for multisets More... | |
| class | ADS::PartitionedBloomFilter< T, H > |
| a filter of Bloom of \( r \) parts of \( m / r \) bits, a hash for each part More... | |
Namespaces | |
| namespace | ADS |
Functions | |
| double | ADS::bloomFalsePositive (double m, double n, int r) |
| the probability \( ( 1 - ( 1 - 1 / m )^{r n} )^r \) of a false positive of a filter of \( m \) bits and \( r \) hashes after \( n \) insertions, 0 for \( n = 0 \) | |
| int | ADS::bloomBestHashes (double m, double n) |
| the number of hashes, the floor or the ceiling of \( ( m / n ) \ln 2 \), of the least false positives; past the largest int (\( m / n \) above about \( 3 \cdot 10^9 \)) the floor is cut to the largest int less one | |
| double | ADS::bloomLowerBound (double n, double epsilon) |
| \( n \log_2( 1 / \epsilon ) \), the bits that any filter of \( n \) keys with false positives \( \epsilon \) needs | |
| double | ADS::bloomBits (double n, double epsilon) |
| \( n \log_2( 1 / \epsilon ) / \ln 2 \), the bits of a filter of Bloom with the best number of hashes and false positives \( \epsilon \) | |
| std::pair< double, double > | ADS::compressedBloom (double bitsPerKey, int r) |
| the false positives and the bits per key after an arithmetic coding, \( m / n \) times the entropy of a bit, of a filter of \( m / n = \mathit{bitsPerKey} \) bits per key and \( r \) hashes | |
| template<class T, class H = std::hash< T >> | |
| std::pair< std::vector< T >, std::vector< T > > | ADS::bloomIntersection (const std::vector< T > &A, const std::vector< T > &B, std::size_t mA) |
| the intersection of \( A \) and \( B \) by a filter of \( A \) of \( m_A \) bits: the keys \( Q \) of \( B \) that the filter accepts, and the keys of \( A \) in \( Q \), in the order of \( B \) | |
The variants and the analysis of the filter of Bloom [see BloomFilter.h for the standard one], beyond the book:
The \( r \) hashes of a key are \( h_1 + i h_2 \bmod m \) of two hashes, as in BloomFilter. Other filters of today, closer to the lower bound for small false positives, are the quotient filters (Bender et al.), the cuckoo filters (Fan et al.) and the xor filters (Graf and Lemire), the latter with about \( 1.23 \log_2( 1 / \epsilon ) \) bits per key.
The contracts [see Contract.h]: \( m \ge 1 \) and \( r \ge 1 \) (\( m \ge r \) for the partitioned filter); a removal of \( x \) with multiplicity \( f \) only if the estimate of \( x \) is at least \( f \); an item inserted is always maybe there and its estimate is at least its multiplicity, postconditions; for the analysis \( m \ge 1 \), \( n \ge 0 \), \( r \ge 1 \), \( 0 < \epsilon < 1 \). The functions are defined in BloomVariants.tpp.