a static filter of the keys of type T with results of type F, one equation of 64 coefficients per key
More...
#include <ADS/set/RibbonFilter.h>
|
| | RibbonFilter (void) |
| | the filter of no key
|
| | RibbonFilter (const std::vector< T > &keys, std::uint64_t seed=1, H h=H()) |
| | the filter of the keys, which may repeat
|
| bool | maybe (const T &x) const |
| | whether \( x \) may be in the set: true for every key of the set, and for any other with probability about \( 2^{-r} \), \( r \) the bits of F
|
| std::size_t | size (void) const |
| | the keys of the build, with their repetitions
|
| bool | empty (void) const |
| | whether the filter has no key
|
| std::size_t | bits (void) const |
| | the bits of the solution, padding included
|
| std::size_t | rows (void) const |
| | the rows m of the solution
|
| std::size_t | trials (void) const |
| | the seeds drawn by the build
|
| 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 = "RibbonFilter" |
| | the name of the structure in a file [see Persistence.h]
|
| static constexpr std::uint32_t | persistVersion = 2 |
| | the version of the layout in a file: 2, whose bit 63 of the trials says that the fingerprints are by a second product; a filter read from a file of the version 1, where it is clear, keeps those of the bits of \( h \oplus ( h \gg 32 ) \)
|
| static constexpr std::uint32_t | persistOldestVersion = 1 |
| | the oldest version read: 1, whose filters keep their fingerprints
|
template<class T, class F = std::uint8_t, class H = DefaultHash< T >>
class ADS::RibbonFilter< T, F, H >
a static filter of the keys of type T with results of type F, one equation of 64 coefficients per key
◆ RibbonFilter() [1/2]
template<class T, class F = std::uint8_t, class H = DefaultHash< T >>
◆ RibbonFilter() [2/2]
template<class T, class F = std::uint8_t, class H = DefaultHash< T >>
| ADS::RibbonFilter< T, F, H >::RibbonFilter |
( |
const std::vector< T > & | keys, |
|
|
std::uint64_t | seed = 1, |
|
|
H | h = H() ) |
|
explicit |
the filter of the keys, which may repeat
In pseudocode (Dillinger and Walzer), \( C[ i ] \) and \( R[ i ] \) the coefficients and the right side of the equation of the row \( i \), \( C[ i ] = 0 \) if none, \( \mathrm{ctz} \) the number of the trailing zeros:
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{procedure}\ \mathrm{build}( K ) \cr
2 & \quad \textbf{repeat}\ \text{draw a seed};\ C \gets 0 ;\ R \gets 0
\cr
3 & \qquad \textbf{foreach}\ k \in K\ \textbf{do} \cr
4 & \qquad\quad ( s , c , f ) \gets ( s( h ) , c( h ) , f( h ) )
\text{ of the hash } h \text{ of } k \cr
5 & \qquad\quad \textbf{while}\ C[ s ] \ne 0\ \textbf{do} \cr
6 & \qquad\qquad c \gets c \oplus C[ s ];\ f \gets f \oplus R[ s ] \cr
7 & \qquad\qquad \textbf{if}\ c = 0\ \textbf{then break}\quad
\triangleright\ \text{redundant if } f = 0 \text{, unsolvable}
\text{ otherwise} \cr
8 & \qquad\qquad z \gets \mathrm{ctz}( c );\ s \gets s + z;\ c \gets
c / 2^z \cr
9 & \qquad\quad \textbf{if}\ c \ne 0\ \textbf{then}\ C[ s ] \gets c;
\ R[ s ] \gets f \cr
10 & \quad \textbf{until}\ \text{no equation was unsolvable} \cr
11 & \quad \textbf{for}\ i \gets m - 1\ \textbf{downto}\ 0
\ \textbf{do} \cr
12 & \qquad Z_i \gets R[ i ] \oplus \bigoplus_{j \ge 1} C[ i ]_j Z_{i+j}
\text{, or a pseudorandom value if } C[ i ] = 0
\end{array}}
\]
- Precondition
- fewer than \( 2^{32} \) keys
- Postcondition
- every key is maybe there (an audit)
◆ bits()
template<class T, class F = std::uint8_t, class H = DefaultHash< T >>
the bits of the solution, padding included
◆ empty()
template<class T, class F = std::uint8_t, class H = DefaultHash< T >>
whether the filter has no key
◆ maybe()
template<class T, class F = std::uint8_t, class H = DefaultHash< T >>
whether \( x \) may be in the set: true for every key of the set, and for any other with probability about \( 2^{-r} \), \( r \) the bits of F
In pseudocode (Dillinger and Walzer), the 64 rows from \( s \) read as the words of two blocks, a line of cache of 8 columns at a time:
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{maybe}( x ) \cr
2 & \quad ( s , c , f ) \gets ( s( h ) , c( h ) , f( h ) ) \text{ of }
\text{the hash } h \text{ of } x \cr
3 & \quad \textbf{foreach}\ \text{line of 8 columns } j\ \textbf{do} \cr
4 & \qquad \textbf{if}\ \bigoplus_{t = 0}^{63} c_t Z_{s+t , j} \ne f_j
\ \text{for one of its } j\ \textbf{then return false} \cr
5 & \quad \textbf{return true}
\end{array}}
\]
◆ persist()
template<class T, class F = std::uint8_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 F = std::uint8_t, class H = DefaultHash< T >>
|
|
inlinestaticnodiscardconstexpr |
the parameters of the layout, in a file
◆ rows()
template<class T, class F = std::uint8_t, class H = DefaultHash< T >>
the rows m of the solution
◆ size()
template<class T, class F = std::uint8_t, class H = DefaultHash< T >>
the keys of the build, with their repetitions
◆ trials()
template<class T, class F = std::uint8_t, class H = DefaultHash< T >>
the seeds drawn by the build
◆ persistName
template<class T, class F = std::uint8_t, class H = DefaultHash< T >>
◆ persistOldestVersion
template<class T, class F = std::uint8_t, class H = DefaultHash< T >>
the oldest version read: 1, whose filters keep their fingerprints
◆ persistVersion
template<class T, class F = std::uint8_t, class H = DefaultHash< T >>
the version of the layout in a file: 2, whose bit 63 of the trials says that the fingerprints are by a second product; a filter read from a file of the version 1, where it is clear, keeps those of the bits of \( h \oplus ( h \gg 32 ) \)
The documentation for this class was generated from the following file: