165#ifndef __ADS_PrefixFilter
166 #define __ADS_PrefixFilter
187#include <string_view>
191#ifndef ADS_FILTER_INLINE
192 #define ADS_FILTER_INLINE ADS_ALWAYS_INLINE
196#ifndef ADS_FILTER_NOINLINE
197 #define ADS_FILTER_NOINLINE ADS_NOINLINE
213template<
class T ,
class H = DefaultHash< T > >
234 [[nodiscard]]
bool maybe(
const T & x )
const;
295 [[nodiscard]] std::size_t
size(
void )
const;
298 [[nodiscard]]
bool empty(
void )
const;
304 [[nodiscard]]
double load(
void )
const;
307 [[nodiscard]] std::size_t
bits(
void )
const;
310 [[nodiscard]] std::size_t
bins(
void )
const;
329 [[nodiscard]]
static constexpr std::uint64_t
persistTag(
void ) {
330 return( detail::persistMix( {
sizeof( T ) } ) );
343 struct alignas( 32 ) Bin
346 unsigned char b[ 32 ] = { 0 , 0 , 0 , 0 , 0 , 0 , 0xFC };
347 using persist_unit =
unsigned char;
350 static constexpr unsigned kK = 25;
351 static constexpr unsigned kQ = 25;
352 static constexpr std::uint32_t kS = kQ << 8;
353 static constexpr unsigned kBody = 7;
354 static constexpr std::uint64_t kHead = ( std::uint64_t( 1 ) << 50 ) - 1;
355 static constexpr std::uint64_t kTop = std::uint64_t( 63 ) << 50;
356 static constexpr double kAlpha = 0.95;
357 static constexpr double kSpareBits = 12;
360 [[nodiscard]]
static std::uint64_t header(
const Bin & B );
364 static void setHeader( Bin & B , std::uint64_t w );
369 [[nodiscard]]
static unsigned select0( std::uint64_t w ,
unsigned j );
372 static void run( std::uint64_t w ,
unsigned q ,
unsigned & s ,
unsigned & e );
376 [[nodiscard]]
static std::uint32_t equal(
const Bin & B ,
unsigned r );
380 [[nodiscard]]
static std::uint32_t below(
const Bin & B ,
unsigned r );
383 [[nodiscard]]
static std::uint32_t runMask( std::uint64_t w ,
unsigned q );
387 [[nodiscard]]
static bool find(
const Bin & B , std::uint64_t w ,
unsigned q ,
392 [[nodiscard]]
static std::uint32_t maximum(
const Bin & B , std::uint64_t w );
396 static void put( Bin & B , std::uint64_t w ,
unsigned q ,
unsigned r ,
400 [[nodiscard]]
static std::size_t binsFor( std::size_t n );
404 [[nodiscard]]
static double spareMean( std::size_t n , std::size_t m );
407 [[nodiscard]] std::uint64_t hash(
const T & x )
const;
410 [[nodiscard]] std::size_t bin( std::uint64_t h )
const;
413 [[nodiscard]]
static std::uint32_t mini( std::uint64_t h );
417 [[nodiscard]]
bool spare( std::size_t i , std::uint32_t x )
const;
421 [[nodiscard]]
static std::uint64_t spareHash( std::size_t i ,
424 std::vector< Bin , MappableAllocator< Bin > > f_B;
427 std::size_t f_spareN = 0;
428 BlockedBloomFilter< std::uint64_t > f_spare;
441#include "ADS/set/impl/PrefixFilter.tpp"
The vector of bits on which the succinct structures and the integer codes of ADS are built: the bits ...
The blocked filter of Bloom, beyond the book: the engineered filter of ADS [see BloomFilter....
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The engineered hash functions of ADS, beyond the book [see HashFunctions.h for those of section 7....
A file mapped in memory, shared by the structures that are read from it in place [see Persistence....
The primitives of the processor that the compilers spell each in their own way, in one form for all: ...
The vector kernels of ADS that are inlined in the middle of a search, on Google Highway,...
bool maybeHash(std::uint64_t h) const
whether the hash may be in the set: false only if it is not
PrefixFilter(void)
a filter for one key, empty
Definition PrefixFilter.h:220
std::size_t bins(void) const
the bins, of 256 bits each
std::size_t spareSize(void) const
the fingerprints sent to the spare
bool empty(void) const
whether no key is in
double expectedSpareSize(void) const
the expected fingerprints sent to the spare when capacity() keys are in,
static constexpr std::uint64_t persistTag(void)
the parameters of the layout, in a file
Definition PrefixFilter.h:329
double falsePositiveRate(void) const
the expected false positives at the current load, the sum of the analysis of PrefixFilter....
bool insert(const T &x)
into the filter by insertHash() of its hash, false (and nothing changed) if keys are in
std::size_t size(void) const
the keys in, with their repetitions
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
PrefixFilter(std::size_t n, H h=H())
the empty filter for keys, its bins at the load 0.95 when they are in, at least one bin
bool maybe(const T &x) const
whether may be in the set, by maybeHash() of its hash: false only if is not in the set
void persist(A &a)
the members written to, or read from, the archive [see Persistence.h]
bool insertHash(std::uint64_t h)
the hash of 64 bits, which must be random, into the filter, false (and nothing changed) if keys are...
void clear(void)
removes all the keys
static constexpr std::string_view persistName
the name of the structure in a file [see Persistence.h]
Definition PrefixFilter.h:326
std::size_t capacity(void) const
the keys that fit, the of the constructor