91#ifndef __ADS_DynamicPGMIndex
92 #define __ADS_DynamicPGMIndex
109#include <type_traits>
128template<
class K ,
class V , std::size_t E = 16 , std::size_t B = 8 ,
129 std::size_t I = ( std::size_t( 1 ) << 24 ) >
130 requires std::is_arithmetic_v< K >
134 static_assert( B >= 2 ,
"the ratio of the levels is at least 2" );
149 static constexpr std::size_t
kFiltered = std::size_t( 1 ) << 12;
183 void insert(
const K & k ,
const V & v );
209 [[nodiscard]]
const V *
find(
const K & k )
const;
234 [[nodiscard]] std::optional< std::pair< K , V > >
240 void forEach(
const K & lo ,
const K & hi , F && f )
const;
244 [[nodiscard]] std::size_t
entries(
void )
const;
247 [[nodiscard]] std::size_t
levels(
void )
const;
255 std::vector< K > key;
257 bool indexed =
false;
258 std::vector< V > val;
259 std::vector< K > dead;
261 bool filtered =
false;
262 std::size_t room = 0;
265 [[nodiscard]] std::size_t size(
void )
const {
266 return( indexed ? idx.
size() : key.size() );
269 [[nodiscard]]
const K & at( std::size_t i )
const {
270 return( indexed ? idx[ i ] : key[ i ] );
273 [[nodiscard]]
const K * keys(
void )
const {
274 return( indexed ? ( idx.
empty() ?
nullptr : &idx[ 0 ] ) : key.data() );
278 [[nodiscard]]
bool isDead(
const K & k )
const {
279 return( ! dead.empty() &&
280 std::binary_search( dead.begin() , dead.end() , k ) );
285 [[nodiscard]] std::size_t
lowerBound(
const K & k )
const;
292 std::vector< K > key;
293 std::vector< V > val;
294 std::vector< K > dead;
298 [[nodiscard]]
static std::size_t capacity( std::size_t i );
302 [[nodiscard]] std::size_t bufferBound(
const K & k )
const;
306 void put(
const K & k ,
const V & v ,
bool dead );
312 static void merge(
const Run & M ,
const Level & L , Run & T );
316 [[nodiscard]]
static std::uint64_t hashOf(
const K & k );
321 void scan(
const K & lo , F && f )
const;
324 std::vector< Level > f_lev;
337#include "ADS/search/impl/DynamicPGMIndex.tpp"
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....
The piecewise geometric model index of Ferragina and Vinciguerra, beyond the book: a learned index on...
The prefetch of a line of the cache, beyond the book: ADS::prefetch( p ) asks the processor to bring ...
V mapped_type
the type of the values
Definition DynamicPGMIndex.h:139
DynamicPGMIndex(const std::vector< std::pair< K, V > > &P)
the map of the pairs , put in the one level that holds them
const V * find(const K &k) const
the value of , nullptr if absent; valid until the next insertion or removal
std::size_t entries(void) const
the pairs stored, the tombstones and the pairs hidden by newer ones included
void forEach(const K &lo, const K &hi, F &&f) const
calls on the pairs with , by increasing key, by the merge of lowerBound()
static constexpr std::size_t kFiltered
the least capacity of a level with a filter of its keys
Definition DynamicPGMIndex.h:149
void erase(const K &k)
removes , if there, by the insertion of a tombstone
DynamicPGMIndex(void)=default
an empty map
std::optional< std::pair< K, V > > lowerBound(const K &k) const
the pair of the least key , none if there is none
K key_type
the type of the keys
Definition DynamicPGMIndex.h:138
bool contains(const K &k) const
whether is there, by find()
static constexpr std::size_t kIndexed
the least capacity of a level with a PGM-index, , the smaller ones being searched by a binary search ...
Definition DynamicPGMIndex.h:146
void insert(const K &k, const V &v)
maps to , whether was there or not
std::size_t levels(void) const
the levels below the buffer, empty or not
static constexpr std::size_t kBuffer
the pairs in the buffer,
Definition DynamicPGMIndex.h:142
the PGM-index on a sorted array of arithmetic keys K, with the error at the last level and at the o...
Definition PGMIndex.h:124
bool empty(void) const
true if there are no items
std::size_t size(void) const
the number of the items
std::size_t lowerBound(const std::vector< T > &A, const T &v, std::size_t lo, std::size_t hi, C less=C())
the first place in of an item not smaller than , if none
SortedListSet< T > merge(const SortedListSet< T > &A, const SortedListSet< T > &B, bool a, bool b, bool both)
the merge of the sorted lists of and : an item of only, of only or of both goes into the result if...