an incremental filter of at most \( n \) keys of type T: bins of 25 fingerprints of 8 bits over 25 quotients, the overflow in a spare
More...
#include <ADS/set/PrefixFilter.h>
|
| | PrefixFilter (void) |
| | a filter for one key, empty
|
| | PrefixFilter (std::size_t n, H h=H()) |
| | the empty filter for \( n \) keys, its bins at the load 0.95 when they are in, at least one bin
|
| bool | insert (const T &x) |
| | \( x \) into the filter by insertHash() of its hash, false (and nothing changed) if \( n \) keys are in
|
| bool | maybe (const T &x) const |
| | whether \( x \) may be in the set, by maybeHash() of its hash: false only if \( x \) is not in the set
|
| bool | insertHash (std::uint64_t h) |
| | the hash \( h \) of 64 bits, which must be random, into the filter, false (and nothing changed) if \( n \) keys are in
|
| bool | maybeHash (std::uint64_t h) const |
| | whether the hash \( h \) may be in the set: false only if it is not
|
| void | clear (void) |
| | removes all the keys
|
| std::size_t | size (void) const |
| | the keys in, with their repetitions
|
| bool | empty (void) const |
| | whether no key is in
|
| std::size_t | capacity (void) const |
| | the keys that fit, the \( n \) of the constructor
|
| double | load (void) const |
| | size() / ( 25 bins() ), at most about 0.95
|
| std::size_t | bits (void) const |
| | the bits of the bins and of the spare
|
| std::size_t | bins (void) const |
| | the bins, of 256 bits each
|
| std::size_t | spareSize (void) const |
| | the fingerprints sent to the spare
|
| double | expectedSpareSize (void) const |
| | the expected fingerprints sent to the spare when capacity() keys are in, \( \mathrm{E}[ X ] = n - m \, \mathrm{E}[ \min( B , 25 ) ] \)
|
| double | falsePositiveRate (void) const |
| | the expected false positives at the current load, the sum of the analysis of PrefixFilter.h over the loads \( j \) of a bin
|
| 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
|
template<class T, class H = DefaultHash< T >>
class ADS::PrefixFilter< T, H >
an incremental filter of at most \( n \) keys of type T: bins of 25 fingerprints of 8 bits over 25 quotients, the overflow in a spare
◆ PrefixFilter() [1/2]
template<class T, class H = DefaultHash< T >>
a filter for one key, empty
◆ PrefixFilter() [2/2]
template<class T, class H = DefaultHash< T >>
the empty filter for \( n \) keys, its bins at the load 0.95 when they are in, at least one bin
- Precondition
- \( n < 2^{32} \)
◆ bins()
template<class T, class H = DefaultHash< T >>
the bins, of 256 bits each
◆ bits()
template<class T, class H = DefaultHash< T >>
the bits of the bins and of the spare
◆ capacity()
template<class T, class H = DefaultHash< T >>
the keys that fit, the \( n \) of the constructor
◆ clear()
template<class T, class H = DefaultHash< T >>
◆ empty()
template<class T, class H = DefaultHash< T >>
◆ expectedSpareSize()
template<class T, class H = DefaultHash< T >>
the expected fingerprints sent to the spare when capacity() keys are in, \( \mathrm{E}[ X ] = n - m \, \mathrm{E}[ \min( B , 25 ) ] \)
◆ falsePositiveRate()
template<class T, class H = DefaultHash< T >>
the expected false positives at the current load, the sum of the analysis of PrefixFilter.h over the loads \( j \) of a bin
◆ insert()
template<class T, class H = DefaultHash< T >>
\( x \) into the filter by insertHash() of its hash, false (and nothing changed) if \( n \) keys are in
- Postcondition
- maybe( x ) if true
◆ insertHash()
template<class T, class H = DefaultHash< T >>
the hash \( h \) of 64 bits, which must be random, into the filter, false (and nothing changed) if \( n \) keys are in
In pseudocode (Even, Even and Morrison), \( x_{\max} \) the largest mini-fingerprint of a full bin:
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{insertHash}( h ) \cr
2 & \quad \textbf{if}\ n \text{ keys are in }\ \textbf{then return
false} \cr
3 & \quad b \gets \lfloor h_1 m / 2^{32} \rfloor;\ x \gets \lfloor h_0
s / 2^{32} \rfloor \cr
4 & \quad \textbf{if}\ \text{the bin } b \text{ holds fewer than 25 }
\ \textbf{then}\ \text{put } ( \lfloor x / 2^8 \rfloor , x \bmod 2^8 )
\text{ in its run} \cr
5 & \quad \textbf{else if}\ x \ge x_{\max}\ \textbf{then}
\ \text{insert } s b + x \text{ into the spare} \cr
6 & \quad \textbf{else}\ \text{insert } s b + x_{\max} \text{ into the }
\text{spare, and put } x \text{ in the place of } x_{\max} \cr
7 & \quad \textbf{if}\ \text{the bin was full }\ \textbf{then}
\ \text{write the quotient of its maximum in the header} \cr
8 & \quad \textbf{return true}
\end{array}}
\]
◆ load()
template<class T, class H = DefaultHash< T >>
◆ maybe()
template<class T, class H = DefaultHash< T >>
whether \( x \) may be in the set, by maybeHash() of its hash: false only if \( x \) is not in the set
◆ maybeHash()
template<class T, class H = DefaultHash< T >>
whether the hash \( h \) may be in the set: false only if it is not
In pseudocode (Even, Even and Morrison), the bound of a bin being its largest mini-fingerprint once it overflowed, and above every mini-fingerprint before:
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{maybeHash}( h ) \cr
2 & \quad b \gets \lfloor h_1 m / 2^{32} \rfloor;\ x \gets \lfloor h_0
s / 2^{32} \rfloor \cr
3 & \quad q \gets \lfloor x / 2^8 \rfloor;\ r \gets x \bmod 2^8;
\ H \gets \text{the header of the bin } b;\ E \gets \text{the}
\text{ slots of its body that hold } r \cr
4 & \quad \textbf{if}\ E = \{ i \}\ \textbf{then}\ f \gets [ \text{the}
\text{ bit } i + q \text{ of } H \text{ is 1, with } i \text{ ones}
\text{ of } H \text{ below it} ] \cr
5 & \quad \textbf{else if}\ E \ne \emptyset\ \textbf{then}\ u \gets 2
H;\ z \gets \mathrm{select}_0( u , q );\ e \gets z + \text{the}
\text{ ones of } u \text{ above } z \text{, up to its next 0} \cr
6 & \qquad f \gets [ E \cap [ z - q , e - q ) \ne \emptyset ] \cr
7 & \quad \textbf{else}\ f \gets \textbf{false} \cr
8 & \quad \textbf{if}\ f\ \textbf{then return true} \cr
9 & \quad \textbf{if}\ x > \text{the bound of the bin } b
\ \textbf{then return}\ \text{the answer of the spare to } s b + x \cr
10 & \quad \textbf{return false}
\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 >>
the keys in, with their repetitions
◆ spareSize()
template<class T, class H = DefaultHash< T >>
the fingerprints sent to the spare
◆ persistName
template<class T, class H = DefaultHash< T >>
The documentation for this class was generated from the following file: