87#ifndef __ADS_BloomVariants
88 #define __ADS_BloomVariants
106#include <string_view>
107#include <unordered_set>
153[[nodiscard]]
inline double bloomBits(
double n ,
double epsilon );
171[[nodiscard]]
inline std::pair< double , double >
196template<
class T ,
class H = std::hash< T > >
197[[nodiscard]] std::pair< std::vector< T > , std::vector< T > >
207template<
class T ,
class C = std::u
int32_t ,
class H = std::hash< T > >
262 [[nodiscard]] C
count(
const T & x )
const;
266 [[nodiscard]]
bool maybe(
const T & x )
const;
269 [[nodiscard]] std::size_t
stuck(
void )
const;
280 static constexpr std::string_view
persistName =
"SpectralBloomFilter";
283 [[nodiscard]]
static constexpr std::uint64_t
persistTag(
void ) {
284 return( detail::persistMix( {
sizeof( T ) ,
sizeof( C ) } ) );
295 [[nodiscard]] std::vector< std::size_t > places(
const T & x )
const;
297 std::vector< C > f_C;
309template<
class T ,
class H = std::hash< T > >
338 [[nodiscard]]
bool maybe(
const T & x )
const;
341 [[nodiscard]] std::size_t
ones(
void )
const;
344 [[nodiscard]] std::size_t
bits(
void )
const;
349 static constexpr std::string_view
persistName =
"PartitionedBloomFilter";
352 [[nodiscard]]
static constexpr std::uint64_t
persistTag(
void ) {
353 return( detail::persistMix( {
sizeof( T ) } ) );
365 [[nodiscard]] detail::BloomProbe probe(
const T & x )
const;
367 std::vector< bool > f_B;
382#include "ADS/set/impl/BloomVariants.tpp"
The filter of Bloom, beyond the book: a set that may answer yes for an item it does not hold,...
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
A file mapped in memory, shared by the structures that are read from it in place [see Persistence....
Hashing with random tables, beyond the book:
static constexpr std::string_view persistName
the name of the structure in a file [see Persistence.h]
Definition BloomVariants.h:349
PartitionedBloomFilter(std::size_t m, int r, H h=H())
the empty filter of about bits in parts
bool maybe(const T &x) const
whether may be in the set, its bit of each part read: false only if was never inserted
std::size_t bits(void) const
the bits, times those of a part
std::size_t ones(void) const
the bits set
PartitionedBloomFilter(void)
a filter of 64 bits and one part, empty
Definition BloomVariants.h:316
void persist(A &a)
the members written to, or read from, the archive [see Persistence.h]
void insert(const T &x)
into the filter, one bit in each part
static constexpr std::uint64_t persistTag(void)
the parameters of the layout, in a file
Definition BloomVariants.h:352
static constexpr std::uint64_t persistTag(void)
the parameters of the layout, in a file
Definition BloomVariants.h:283
void persist(A &a)
the members written to, or read from, the archive [see Persistence.h]
int hashes(void) const
the hashes
std::size_t stuck(void) const
the counters at their largest value, which no longer move
void remove(const T &x, C f=1)
subtracted from the multiplicity of ; a stuck counter stays
static constexpr std::string_view persistName
the name of the structure in a file [see Persistence.h]
Definition BloomVariants.h:280
void insert(const T &x, C f=1)
added to the multiplicity of
C count(const T &x) const
the least counter of (the minimum selection), never below its multiplicity
SpectralBloomFilter(void)
a filter of 64 counters and one hash, empty
Definition BloomVariants.h:214
SpectralBloomFilter(std::size_t m, int r, H h=H())
the empty filter of counters and hashes
bool maybe(const T &x) const
whether may be there, count( x ) : false only if is not there
std::size_t counters(void) const
the counters
double bloomFalsePositive(double m, double n, int r)
the probability of a false positive of a filter of bits and hashes after insertions,...
double bloomLowerBound(double n, double epsilon)
, the bits that any filter of keys with false positives needs
std::pair< std::vector< T >, std::vector< T > > bloomIntersection(const std::vector< T > &A, const std::vector< T > &B, std::size_t mA)
the intersection of and by a filter of of bits: the keys of that the filter accepts,...
double bloomBits(double n, double epsilon)
, the bits of a filter of Bloom with the best number of hashes and false positives
int bloomBestHashes(double m, double n)
the number of hashes, the floor or the ceiling of , of the least false positives; past the largest in...
std::pair< double, double > compressedBloom(double bitsPerKey, int r)
the false positives and the bits per key after an arithmetic coding, times the entropy of a bit,...