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

a static range filter of the keys of type T, \( B \) bits per key: the buckets of \( 2^w / ( n \, 2^{B-2} ) \) keys that hold a key of the set, \( w \) the bits of T, with no bound on the false positives of the queries near a key More...

#include <ADS/set/GrafiteFilter.h>

Public member functions

 BucketingFilter (void)
 the filter of no key
 BucketingFilter (const std::vector< T > &keys, int B=16)
 the filter of the keys, which may repeat, in at most \( B \) bits per key
bool mayContain (const T &a, const T &b) const
 true if \( [ a , b ] \) holds a key, and if a bucket of a key meets it
bool maybe (const T &x) const
 mayContain( x , x )
std::uint64_t bucketWidth (void) const
 the keys of a bucket, \( s \)
std::size_t buckets (void) const
 the buckets that hold a key
std::size_t sizeInBits (void) const
 the bits of the buckets 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 = "BucketingFilter"
 the name of the structure in a file [see Persistence.h]

Detailed description

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

a static range filter of the keys of type T, \( B \) bits per key: the buckets of \( 2^w / ( n \, 2^{B-2} ) \) keys that hold a key of the set, \( w \) the bits of T, with no bound on the false positives of the queries near a key

Constructor and destructor documentation

◆ BucketingFilter() [1/2]

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

the filter of no key

◆ BucketingFilter() [2/2]

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

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

In pseudocode (the bucketing of Costa, Ferragina and Vinciguerra, beyond the book):

\[\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;\ s \gets \lceil 2^w / ( n \, 2^{B-2} ) \rceil \cr 3 & \quad \text{keep by Elias-Fano the buckets } \lfloor x / s \rfloor \text{ of the keys } x \in K \text{, sorted and once each} \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

◆ buckets()

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

the buckets that hold a key

◆ bucketWidth()

template<RadixKey T = std::uint64_t>
std::uint64_t ADS::BucketingFilter< T >::bucketWidth ( void ) const
nodiscard

the keys of a bucket, \( s \)

◆ maybe()

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

mayContain( x , x )

◆ mayContain()

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

true if \( [ a , b ] \) holds a key, and if a bucket of a key meets it

In pseudocode (as the build):

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{mayContain}( a , b ) \cr 2 & \quad p \gets \mathrm{nextGEQ}( \lfloor a / s \rfloor ) \cr 3 & \quad \textbf{return}\ p \text{ is a bucket kept } \ \textbf{and}\ \mathrm{access}( p ) \le \lfloor b / s \rfloor \end{array}} \]

Precondition
\( a \le b \)

◆ persist()

template<RadixKey T = std::uint64_t>
template<class A>
void ADS::BucketingFilter< 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::BucketingFilter< T >::persistTag ( void )
inlinestaticnodiscardconstexpr

the parameters of the layout, in a file

◆ sizeInBits()

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

the bits of the buckets and of the directory of select

Member data documentation

◆ persistName

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

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


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