ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
CompressedPGMIndex.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*------------------------ File CompressedPGMIndex.h -----------------------*/
3/*--------------------------------------------------------------------------*/
69/*--------------------------------------------------------------------------*/
70/*----------------------------- DEFINITIONS --------------------------------*/
71/*--------------------------------------------------------------------------*/
72
73#ifndef __ADS_CompressedPGMIndex
74 #define __ADS_CompressedPGMIndex
75/* self-identification: #endif constant */
76
77/*--------------------------------------------------------------------------*/
78/*------------------------------ INCLUDES ----------------------------------*/
79/*--------------------------------------------------------------------------*/
80
81#include "ADS/Contract.h"
84#include "ADS/search/PGMIndex.h"
87
88#include <cstddef>
89#include <cstdint>
90#include <string_view>
91#include <type_traits>
92#include <vector>
93
94/*--------------------------------------------------------------------------*/
95/*--------------------------- NAMESPACE ------------------------------------*/
96/*--------------------------------------------------------------------------*/
97
98namespace ADS
99{
100
101/*--------------------------------------------------------------------------*/
102/*----------------------- CLASS CompressedPGMIndex -------------------------*/
103/*--------------------------------------------------------------------------*/
104
107template< class K , std::size_t E = 64 >
108 requires std::is_arithmetic_v< K >
110{
111
112 static_assert( E >= 1 , "the error is at least 1" );
113
114/*--------------------------------------------------------------------------*/
115 public:
116 using Item = K;
117
119 CompressedPGMIndex( void ) = default;
120
157 explicit CompressedPGMIndex( std::vector< K > A );
158
180 [[nodiscard]] std::size_t lowerBound( const K & v ) const;
181
183 [[nodiscard]] bool contains( const K & v ) const;
184
187 [[nodiscard]] const K & operator[]( std::size_t i ) const;
188
190 [[nodiscard]] std::size_t size( void ) const;
191
193 [[nodiscard]] bool empty( void ) const;
194
196 [[nodiscard]] std::size_t segments( void ) const;
197
199 [[nodiscard]] std::size_t slopes( void ) const;
200
202 [[nodiscard]] std::size_t bytes( void ) const;
203
204/*----------------------------- THE PERSISTENCE ----------------------------*/
205
207 static constexpr std::string_view persistName = "CompressedPGMIndex";
208
210 [[nodiscard]] static constexpr std::uint64_t persistTag( void ) {
211 return( detail::persistMix( { sizeof( K ) , std::is_signed_v< K > ,
212 std::is_floating_point_v< K > , E } ) );
213 }
214
217 template< class A >
218 void persist( A & a );
219
220/*--------------------------------------------------------------------------*/
221 private:
222 std::vector< K , HugePageAllocator< K > > f_A;
223 std::size_t f_m = 0;
225 EliasFano f_start;
226 std::vector< float > f_slope;
227 BitVector f_code;
228 int f_ws = 0;
229 int f_wd = 0;
230 std::int64_t f_dmin = 0;
231
232 }; // end( class CompressedPGMIndex )
233
234/*--------------------------------------------------------------------------*/
235
236} // end( namespace ADS )
237
238/*--------------------------------------------------------------------------*/
239/*-------------------------- IMPLEMENTATION --------------------------------*/
240/*--------------------------------------------------------------------------*/
241
242#include "ADS/search/impl/CompressedPGMIndex.tpp"
243
244/*--------------------------------------------------------------------------*/
245
246#endif /* CompressedPGMIndex.h included */
247
248/*--------------------------------------------------------------------------*/
249/*---------------------- End File CompressedPGMIndex.h ---------------------*/
250/*--------------------------------------------------------------------------*/
The vector of bits on which the succinct structures and the integer codes of ADS are built: the bits ...
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The Elias-Fano representation of a non-decreasing sequence of integers in (chapters 11,...
An allocator for the large blocks of a structure, beyond the book: a request of at least one huge pag...
A file mapped in memory, shared by the structures that are read from it in place [see Persistence....
The piecewise geometric model index of Ferragina and Vinciguerra, beyond the book: a learned index on...
a vector of bits packed in words of 64 bits
Definition BitVector.h:479
bool contains(const K &v) const
true if is an item, by lowerBound( v )
std::size_t lowerBound(const K &v) const
the first place of an item not smaller than , size() if none
static constexpr std::uint64_t persistTag(void)
the type of the keys and the error, in a file
Definition CompressedPGMIndex.h:210
std::size_t size(void) const
the number of the items
std::size_t slopes(void) const
the distinct slopes,
CompressedPGMIndex(void)=default
an empty index
void persist(A &a)
the members written to, or read from, the archive [see Persistence.h]
std::size_t segments(void) const
the segments,
CompressedPGMIndex(std::vector< K > A)
the index on the sorted items of
const K & operator[](std::size_t i) const
the item of place
bool empty(void) const
true if there are no items
std::size_t bytes(void) const
the bytes of the index, the items aside
static constexpr std::string_view persistName
the name of the structure in a file [see Persistence.h]
Definition CompressedPGMIndex.h:207
K Item
the type of the items
Definition CompressedPGMIndex.h:116
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
BasicEliasFano< false > EliasFano
Elias-Fano with the inventories of built in the constructor, the fastest access() and nextGEQ().
Definition EliasFano.h:291
Definition ADT.h:96