ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ADS::GrafiteFilter< T > Class Template Reference

a static range filter of the keys of type T, \( B \) bits per key, with false positive probability at most \( \ell / 2^{B-2} \) for a range of \( \ell \) keys, whatever the keys and the range More...

#include <ADS/set/GrafiteFilter.h>

Public member functions

 GrafiteFilter (void)
 the filter of no key
 GrafiteFilter (const std::vector< T > &keys, int B=16, std::uint64_t seed=1)
 the filter of the keys, which may repeat, in \( B \) bits per key
bool mayContain (const T &a, const T &b) const
 true if \( [ a , b ] \) holds a key, and with probability at most \( ( b - a + 1 ) / 2^{B-2} \) otherwise
bool maybe (const T &x) const
 mayContain( x , x ): true for a key, and with probability at most \( 2^{-(B-2)} \) otherwise
double falsePositiveBound (double l) const
 the bound \( \min( 1 , \ell / 2^{B-2} ) \) of the false positive probability of a range of \( \ell \) keys
std::size_t size (void) const
 the keys of the build, the repeated ones once each
bool empty (void) const
 true if the filter has no key
std::size_t codes (void) const
 the distinct codes, \( n \) less the keys of \( S \) that share a code
std::uint64_t reduced (void) const
 the reduced universe \( r = n \, 2^{B-2} \)
std::size_t sizeInBits (void) const
 the bits of the codes and of the directory of select
template<class A>
void persist (A &a)
 the members written to, or read from, the archive \( a \) [see Persistence.h]

Static public member functions

static constexpr std::uint64_t persistTag (void)
 the parameters of the layout, in a file

Static public attributes

static constexpr std::string_view persistName = "GrafiteFilter"
 the name of the structure in a file [see Persistence.h]

Detailed description

template<RadixKey T = std::uint64_t>
class ADS::GrafiteFilter< T >

a static range filter of the keys of type T, \( B \) bits per key, with false positive probability at most \( \ell / 2^{B-2} \) for a range of \( \ell \) keys, whatever the keys and the range

Constructor and destructor documentation

◆ GrafiteFilter() [1/2]

template<RadixKey T = std::uint64_t>
ADS::GrafiteFilter< T >::GrafiteFilter ( void )
inline

the filter of no key

◆ GrafiteFilter() [2/2]

template<RadixKey T = std::uint64_t>
ADS::GrafiteFilter< T >::GrafiteFilter ( const std::vector< T > & keys,
int B = 16,
std::uint64_t seed = 1 )
explicit

the filter of the keys, which may repeat, in \( B \) bits per key

In pseudocode (Costa, Ferragina and Vinciguerra, beyond the book), the words \( \alpha \) and \( \beta \) of \( q \) drawn from the seed:

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{procedure}\ \mathrm{build}( K , B ) \cr 2 & \quad n \gets \text{the number of distinct keys of } K;\ r \gets \max( 1 , n \, 2^{B-2} ) \cr 3 & \quad C \gets \text{the codes } h( x ) \text{ of the keys } x \in K \text{, sorted and once each} \cr 4 & \quad \text{keep } C \text{ by Elias-Fano in the universe } r \end{array}} \]

Precondition
\( 2 \le B \le 40 \) and \( n \, 2^{B-2} < 2^{63} \)
Postcondition
every key may be there (an audit)

Member function documentation

◆ codes()

template<RadixKey T = std::uint64_t>
std::size_t ADS::GrafiteFilter< T >::codes ( void ) const
nodiscard

the distinct codes, \( n \) less the keys of \( S \) that share a code

◆ empty()

template<RadixKey T = std::uint64_t>
bool ADS::GrafiteFilter< T >::empty ( void ) const
nodiscard

true if the filter has no key

◆ falsePositiveBound()

template<RadixKey T = std::uint64_t>
double ADS::GrafiteFilter< T >::falsePositiveBound ( double l) const
nodiscard

the bound \( \min( 1 , \ell / 2^{B-2} ) \) of the false positive probability of a range of \( \ell \) keys

◆ maybe()

template<RadixKey T = std::uint64_t>
bool ADS::GrafiteFilter< T >::maybe ( const T & x) const
nodiscard

mayContain( x , x ): true for a key, and with probability at most \( 2^{-(B-2)} \) otherwise

◆ mayContain()

template<RadixKey T = std::uint64_t>
bool ADS::GrafiteFilter< T >::mayContain ( const T & a,
const T & b ) const
nodiscard

true if \( [ a , b ] \) holds a key, and with probability at most \( ( b - a + 1 ) / 2^{B-2} \) otherwise

In pseudocode (Costa, Ferragina and Vinciguerra, beyond the book), the \( m \) codes sorted in \( C[ 0 .. m - 1 ] \):

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{mayContain}( a , b ) \cr 2 & \quad \textbf{if}\ m = 0\ \textbf{then return false} \cr 3 & \quad \textbf{if}\ b - a \ge r\ \textbf{then return true}\quad \triangleright\ \text{the bound is } 1 \cr 4 & \quad j_a \gets \lfloor a / r \rfloor;\ j_b \gets \lfloor b / r \rfloor \cr 5 & \quad \textbf{if}\ j_a = j_b\ \textbf{then return}\ \mathrm{meets}( h( a ) , h( b ) ) \cr 6 & \quad c \gets j_b \, r\quad \triangleright\ \text{the first key of } \text{the block of } b \cr 7 & \quad \textbf{return}\ \mathrm{meets}( h( a ) , h( c - 1 ) ) \ \textbf{or}\ \mathrm{meets}( h( c ) , h( b ) ) \cr 8 & \textbf{function}\ \mathrm{meets}( x , y )\quad \triangleright \ \text{a code in the cyclic range from } x \text{ to } y \cr 9 & \quad p \gets \mathrm{nextGEQ}( x ) \cr 10 & \quad \textbf{if}\ x \le y\ \textbf{then return}\ p < m \ \textbf{and}\ C[ p ] \le y \cr 11 & \quad \textbf{return}\ p < m\ \textbf{or}\ C[ 0 ] \le y\quad \triangleright\ \text{the range wraps around } r \end{array}} \]

Precondition
\( a \le b \)

◆ persist()

template<RadixKey T = std::uint64_t>
template<class A>
void ADS::GrafiteFilter< T >::persist ( A & a)

the members written to, or read from, the archive \( a \) [see Persistence.h]

◆ persistTag()

template<RadixKey T = std::uint64_t>
constexpr std::uint64_t ADS::GrafiteFilter< T >::persistTag ( void )
inlinestaticnodiscardconstexpr

the parameters of the layout, in a file

◆ reduced()

template<RadixKey T = std::uint64_t>
std::uint64_t ADS::GrafiteFilter< T >::reduced ( void ) const
nodiscard

the reduced universe \( r = n \, 2^{B-2} \)

◆ size()

template<RadixKey T = std::uint64_t>
std::size_t ADS::GrafiteFilter< T >::size ( void ) const
nodiscard

the keys of the build, the repeated ones once each

◆ sizeInBits()

template<RadixKey T = std::uint64_t>
std::size_t ADS::GrafiteFilter< T >::sizeInBits ( void ) const
nodiscard

the bits of the codes and of the directory of select

Member data documentation

◆ persistName

template<RadixKey T = std::uint64_t>
std::string_view ADS::GrafiteFilter< T >::persistName = "GrafiteFilter"
staticconstexpr

the name of the structure in a file [see Persistence.h]


The documentation for this class was generated from the following file: