ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
BloomFilter.h File Reference

The filter of Bloom, beyond the book: a set that may answer yes for an item it does not hold, but never no for one it holds, in \( m \) bits whatever the items. More...

#include "ADS/Contract.h"
#include "ADS/dictionary/RandomHashing.h"
#include "ADS/external/MappedFile.h"
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <string_view>
#include <vector>
#include "ADS/set/impl/BloomFilter.tpp"

Go to the source code of this file.

Classes

class  ADS::BloomFilter< T, H >
 a filter of Bloom of \( m \) bits and \( k \) hashes More...

Namespaces

namespace  ADS

Detailed description

The filter of Bloom, beyond the book: a set that may answer yes for an item it does not hold, but never no for one it holds, in \( m \) bits whatever the items.

An item sets the \( k \) bits \( h_1 + i h_2 \bmod m \), \( i = 0 , \ldots , k - 1 \), of two hashes, as Kirsch and Mitzenmacher showed to be as good as \( k \) independent hashes, and is maybe there if all its bits are set; after \( n \) insertions the probability of a false positive is about \( ( 1 - e^{-k n / m} )^k \), the least for \( k = ( m / n ) \ln 2 \), i.e., about \( 0.6185^{m/n} \) (\( 1 \% \) with about 9.6 bits per item). The two hashes come from the hash of the item mixed by splitmix64() [see RandomHashing.h].

The contracts [see Contract.h]: \( m \ge 1 \) and \( k \ge 1 \); an item inserted is always maybe there. The operations are defined in BloomFilter.tpp.

See also
P. Ferragina, Pearls of Algorithm Engineering, Cambridge University Press, 2023, chapter 8, The Dictionary Problem, doi:10.1017/9781009128933
B. H. Bloom, Space/time trade-offs in hash coding with allowable errors, Communications of the ACM 13(7), 422-426, 1970, doi:10.1145/362686.362692
A. Kirsch, M. Mitzenmacher, Less hashing, same performance: building a better Bloom filter, Proceedings of ESA 2006, LNCS 4168, 456-467, 2006, doi:10.1007/11841036_42
Author
Donato Meoli
Dipartimento di Informatica
Università di Pisa