|
ADS
Algorithms and Data Structures
|
The compressed PGM-index of Ferragina and Vinciguerra, beyond the book: the segments of the PGM-index [see PGMIndex.h] on a sorted array of arithmetic keys in a few tens of bits each instead of 28 bytes, with the same search at the last level (see The PGM-index compressed and dynamic). More...
#include "ADS/Contract.h"#include "ADS/external/MappedFile.h"#include "ADS/memory/HugePageAllocator.h"#include "ADS/search/PGMIndex.h"#include "ADS/succinct/BitVector.h"#include "ADS/succinct/EliasFano.h"#include <cstddef>#include <cstdint>#include <string_view>#include <type_traits>#include <vector>#include "ADS/search/impl/CompressedPGMIndex.tpp"Go to the source code of this file.
Classes | |
| class | ADS::CompressedPGMIndex< K, E > |
| the compressed PGM-index on a sorted array of arithmetic keys K, with the error \( \epsilon = E \) More... | |
Namespaces | |
| namespace | ADS |
The compressed PGM-index of Ferragina and Vinciguerra, beyond the book: the segments of the PGM-index [see PGMIndex.h] on a sorted array of arithmetic keys in a few tens of bits each instead of 28 bytes, with the same search at the last level (see The PGM-index compressed and dynamic).
A segment of the optimal approximation with error \( \epsilon \) does not need its own slope: the lines within the error of its points are those of the slopes in an interval \( [ \alpha^- , \alpha^+ ] \), the two extreme lines of the algorithm of O'Rourke, and each slope of the interval has an intercept that keeps the line within the error (the feasible lines are a convex region of the plane of the slopes and the intercepts, and the interval is its shadow). The fewest slopes that hit every interval are found by the greedy of the stabbing of intervals: the intervals sorted by their left end, a group grows while the next interval meets the intersection of the group, and the middle of the intersection is the slope of the group; the intervals of least right end of the groups are pairwise disjoint, hence no set of fewer slopes hits them all. A segment then keeps the index of its slope in a table and, with that slope, the intercept in the middle of its interval of feasible intercepts, as its distance from the first place of the segment, which is at most \( \epsilon + 1 \); the first places of the segments, increasing, are kept by Elias-Fano [see EliasFano.h], and their first keys whole, with a PGM-index of their own (of error 4) in place of the levels above, as the levels of the paper:
\[ 64 + 2 + \Big\lceil \log_2 \frac{n}{m} \Big\rceil + \lceil \log_2 \sigma \rceil + \lceil \log_2( 2 \epsilon + 3 ) \rceil \]
bits per segment for \( m \) segments and \( \sigma \) slopes, plus the segments of the PGM-index of the keys, the directory of Elias-Fano and the table of the slopes, in single precision as in the implementation of the paper, \( 32 \sigma \) bits. The first keys could be kept by Elias-Fano too, saving \( 62 - \log_2( u / m ) \) bits a segment for keys in a universe of size \( u \); but its rank, the search of a segment, scans a bucket where the keys crowd (on skewed keys, most of them), and the PGM-index of the keys finds the segment in the time of the levels of the PGM-index, so that a search costs that, two selects for the first places of the segment and of the next one, a field of bits and the window of \( 2 \epsilon + 5 \) places. A segment whose points the line of the shared slope, rounded, leaves out by more than \( \epsilon + 1 \) (an effect of the floating point, which the construction checks) keeps a slope of its own, appended to the table, with the intercept in the middle of those of that slope.
The contracts [see Contract.h]: the keys sorted, an audit, and fewer than \( 2^{32} \) of them; each result \( r \) is such that the items before \( r \) are smaller than the key and those from \( r \) on are not, a postcondition. The functions are defined in CompressedPGMIndex.tpp.