a filter of Bloom in blocks of 256 bits, 8 bits per item
More...
#include <ADS/set/BlockedBloomFilter.h>
|
| | BlockedBloomFilter (void) |
| | a filter of one block, empty
|
| | BlockedBloomFilter (std::size_t n, double bitsPerItem=10, H h=H()) |
| | the empty filter of about bitsPerItem bits for each of \( n \) items, in at least one block, \( \lceil n \cdot
\mathit{bitsPerItem} / 256 \rceil \) blocks
|
| void | insert (const T &x) |
| | \( x \) into the filter, by insertHash() of its hash
|
| bool | maybe (const T &x) const |
| | whether \( x \) may be in the set, by maybeHash() of its hash: false only if \( x \) was never inserted
|
| void | insertHash (std::uint64_t h) |
| | the hash \( h \) of 64 bits, which must be random, into the filter
|
| bool | maybeHash (std::uint64_t h) const |
| | whether the hash \( h \) may be in the set: false only if it was never inserted
|
| void | unite (const BlockedBloomFilter &o) |
| | the items of o added, as if they had been inserted here, by the OR of the blocks
|
| void | clear (void) |
| | removes all the items
|
| std::size_t | size (void) const |
| | the insertions made
|
| bool | empty (void) const |
| | whether no item was inserted
|
| std::size_t | bits (void) const |
| | the bits, 256 per block
|
| std::size_t | blocks (void) const |
| | the blocks \( B \)
|
| double | falsePositiveRate (void) const |
| | the expected false positives after the insertions made, the mean over the Poisson loads of the blocks, \( \sum_j e^{-\lambda} \lambda^j / j! \, ( 1 - ( 31 / 32 )^j )^8 \) with \( \lambda = n / B \)
|
| template<class A> |
| void | persist (A &a) |
| | the members written to, or read from, the archive \( a \) [see Persistence.h]
|
|
| static constexpr std::uint64_t | persistTag (void) |
| | the parameters of the layout, in a file
|
|
| static constexpr std::string_view | persistName = "BlockedBloomFilter" |
| | the name of the structure in a file [see Persistence.h]
|
template<class T, class H = DefaultHash< T >>
class ADS::BlockedBloomFilter< T, H >
a filter of Bloom in blocks of 256 bits, 8 bits per item
◆ BlockedBloomFilter() [1/2]
template<class T, class H = DefaultHash< T >>
a filter of one block, empty
◆ BlockedBloomFilter() [2/2]
template<class T, class H = DefaultHash< T >>
the empty filter of about bitsPerItem bits for each of \( n \) items, in at least one block, \( \lceil n \cdot
\mathit{bitsPerItem} / 256 \rceil \) blocks
- Precondition
- \( \mathit{bitsPerItem} > 0 \)
◆ bits()
template<class T, class H = DefaultHash< T >>
◆ blocks()
template<class T, class H = DefaultHash< T >>
◆ clear()
template<class T, class H = DefaultHash< T >>
◆ empty()
template<class T, class H = DefaultHash< T >>
whether no item was inserted
◆ falsePositiveRate()
template<class T, class H = DefaultHash< T >>
the expected false positives after the insertions made, the mean over the Poisson loads of the blocks, \( \sum_j e^{-\lambda} \lambda^j / j! \, ( 1 - ( 31 / 32 )^j )^8 \) with \( \lambda = n / B \)
In pseudocode (Putze, Sanders and Singler), the terms by the recurrence \( p_{j+1} = p_j \lambda / ( j + 1 ) \) from the mode \( j_0 = \lfloor \lambda \rfloor \) both ways, until they fall below \( 10^{-18} p_{j_0} \):
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{falsePositiveRate}() \cr
2 & \quad \lambda \gets n / B;\ \textbf{if}\ \lambda = 0
\ \textbf{then return}\ 0 \cr
3 & \quad j_0 \gets \lfloor \lambda \rfloor;\ p_{j_0} \gets e^{-\lambda}
\lambda^{j_0} / j_0! \cr
4 & \quad \textbf{return}\ \sum_j p_j ( 1 - ( 31 / 32 )^j )^8
\ \text{over the } j \text{ with } p_j \ge 10^{-18} p_{j_0}
\end{array}}
\]
◆ insert()
template<class T, class H = DefaultHash< T >>
\( x \) into the filter, by insertHash() of its hash
- Postcondition
- maybe( x )
◆ insertHash()
template<class T, class H = DefaultHash< T >>
the hash \( h \) of 64 bits, which must be random, into the filter
In pseudocode (Putze, Sanders and Singler, with the 8 words of the format Parquet), \( W_b \) the 8 words of 32 bits of the block \( b \) and \( s_i \) the 8 odd constants:
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{procedure}\ \mathrm{insertHash}( h ) \cr
2 & \quad b \gets \lfloor \lfloor h / 2^{32} \rfloor \cdot B / 2^{32}
\rfloor;\ h_0 \gets h \bmod 2^{32} \cr
3 & \quad \textbf{for}\ i \gets 0\ \textbf{to}\ 7\ \textbf{do}
\ W_b[ i ] \gets W_b[ i ] \vee 2^{\lfloor ( h_0 s_i \bmod 2^{32} ) /
2^{27} \rfloor}
\end{array}}
\]
◆ maybe()
template<class T, class H = DefaultHash< T >>
whether \( x \) may be in the set, by maybeHash() of its hash: false only if \( x \) was never inserted
◆ maybeHash()
template<class T, class H = DefaultHash< T >>
whether the hash \( h \) may be in the set: false only if it was never inserted
In pseudocode (Putze, Sanders and Singler), the 8 bits of insertHash() tested at once:
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{maybeHash}( h ) \cr
2 & \quad b \gets \text{the block of } h;\ M \gets \text{the 8 }
\text{words of the bits of } h \cr
3 & \quad \textbf{return}\ M[ i ] \wedge \lnot W_b[ i ] = 0
\ \text{for } i = 0 , \ldots , 7
\end{array}}
\]
◆ persist()
template<class T, class H = DefaultHash< T >>
template<class A>
the members written to, or read from, the archive \( a \) [see Persistence.h]
◆ persistTag()
template<class T, class H = DefaultHash< T >>
|
|
inlinestaticnodiscardconstexpr |
the parameters of the layout, in a file
◆ size()
template<class T, class H = DefaultHash< T >>
◆ unite()
template<class T, class H = DefaultHash< T >>
the items of o added, as if they had been inserted here, by the OR of the blocks
- Precondition
- o has the blocks of this filter
◆ persistName
template<class T, class H = DefaultHash< T >>
The documentation for this class was generated from the following file: