142#ifndef __ADS_RibbonFilter
143 #define __ADS_RibbonFilter
164#include <string_view>
165#include <type_traits>
169#ifndef ADS_FILTER_INLINE
170 #define ADS_FILTER_INLINE ADS_ALWAYS_INLINE
186template<
class T ,
class F = std::u
int8_t ,
class H = DefaultHash< T > >
190 static_assert( std::is_unsigned_v< F > && (
sizeof( F ) <= 4 ) ,
191 "the results have at most 32 bits" );
231 std::uint64_t seed = 1 ,
251 [[nodiscard]]
bool maybe(
const T & x )
const;
254 [[nodiscard]] std::size_t
size(
void )
const;
257 [[nodiscard]]
bool empty(
void )
const;
260 [[nodiscard]] std::size_t
bits(
void )
const;
263 [[nodiscard]] std::size_t
rows(
void )
const;
266 [[nodiscard]] std::size_t
trials(
void )
const;
283 [[nodiscard]]
static constexpr std::uint64_t
persistTag(
void ) {
284 return( detail::persistMix( {
sizeof( T ) ,
sizeof( F ) } ) );
294 static constexpr int kR = 8 *
sizeof( F );
295 static constexpr std::size_t kMaxTrials = 1000;
296 static constexpr std::size_t kAhead = 16;
299 struct alignas( 64 ) Line
301 std::uint64_t w[ 8 ];
302 using persist_unit = std::uint64_t;
306 [[nodiscard]] std::uint64_t base(
const T & x )
const;
309 [[nodiscard]] std::uint64_t mixed( std::uint64_t b )
const;
312 [[nodiscard]] std::size_t start( std::uint64_t h )
const;
315 [[nodiscard]]
static std::uint64_t coefficients( std::uint64_t h );
318 [[nodiscard]] F fingerprint( std::uint64_t h )
const;
324 [[nodiscard]]
static std::uint32_t
325 parities(
const std::uint64_t * u , std::uint64_t lo , std::uint64_t hi );
328 bool build(
const std::vector< T > & keys );
332 void solve(
const std::vector< std::uint64_t > & C ,
333 const std::vector< F > & R );
336 std::vector< Line , MappableAllocator< Line > > f_Z;
338 std::uint64_t f_seed;
340 std::size_t f_trials = 0;
344 static constexpr std::uint64_t kProductBit = std::uint64_t( 1 ) << 63;
356#include "ADS/set/impl/RibbonFilter.tpp"
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 prefetch of a line of the cache, beyond the book: ADS::prefetch( p ) asks the processor to bring ...
The vector kernels of ADS that are inlined in the middle of a search, on Google Highway,...
static constexpr std::uint32_t persistOldestVersion
the oldest version read: 1, whose filters keep their fingerprints
Definition RibbonFilter.h:280
std::size_t bits(void) const
the bits of the solution, padding included
bool maybe(const T &x) const
whether may be in the set: true for every key of the set, and for any other with probability about ,...
std::size_t size(void) const
the keys of the build, with their repetitions
static constexpr std::uint32_t persistVersion
the version of the layout in a file: 2, whose bit 63 of the trials says that the fingerprints are by ...
Definition RibbonFilter.h:277
static constexpr std::uint64_t persistTag(void)
the parameters of the layout, in a file
Definition RibbonFilter.h:283
std::size_t trials(void) const
the seeds drawn by the build
std::size_t rows(void) const
the rows m of the solution
bool empty(void) const
whether the filter has no key
RibbonFilter(void)
the filter of no key
Definition RibbonFilter.h:196
static constexpr std::string_view persistName
the name of the structure in a file [see Persistence.h]
Definition RibbonFilter.h:271
RibbonFilter(const std::vector< T > &keys, std::uint64_t seed=1, H h=H())
the filter of the keys, which may repeat
void persist(A &a)
the members written to, or read from, the archive [see Persistence.h]