|
ADS
Algorithms and Data Structures
|
The LA-vector of Boffa, Ferragina and Vinciguerra, beyond the book: a non-decreasing sequence \( x_0 \le \cdots \le x_{n-1} \) of integers of 64 bits, i.e., the places of the 1s of a vector of bits, compressed by the regularities that a model of lines finds in it, with access(), the select of the vector of bits, and nextGEQ(), its rank (see Sequences compressed by a model of lines). More...
#include "ADS/Contract.h"#include "ADS/combinatorial/Bitwise.h"#include "ADS/search/PGMIndex.h"#include "ADS/succinct/BitVector.h"#include <bit>#include <cstddef>#include <cstdint>#include <cstring>#include <string_view>#include <utility>#include <vector>#include "ADS/succinct/impl/LAVector.tpp"Go to the source code of this file.
Classes | |
| class | ADS::LAVector |
| a non-decreasing sequence of integers of 64 bits as the segments of an optimal piecewise linear approximation and the corrections of the items More... | |
Namespaces | |
| namespace | ADS |
The LA-vector of Boffa, Ferragina and Vinciguerra, beyond the book: a non-decreasing sequence \( x_0 \le \cdots \le x_{n-1} \) of integers of 64 bits, i.e., the places of the 1s of a vector of bits, compressed by the regularities that a model of lines finds in it, with access(), the select of the vector of bits, and nextGEQ(), its rank (see Sequences compressed by a model of lines).
The points \( ( i , x_i ) \) are covered by the fewest segments whose lines predict each item within \( \epsilon \), the optimal piecewise linear approximation of the PGM-index [see PGMIndex.h], and each item is stored as its correction, its distance from the prediction of its segment, in \( c \) bits for \( \epsilon = 2^{c-1} - 1 \): the segment \( j \), from the place \( p_j \), predicts \( f_j( i ) = \beta_j + \lfloor \alpha_j ( i - p_j ) \rfloor \), and \( x_i = f_j( i ) + C[ i ] \) with \( 0 \le C[ i ] < 2^{w_j} \), the base \( \beta_j \) taking the least correction of the segment, so that \( w_j \) is the width of the range of its corrections (\( c \), one bit more where the rounding of the line in double spreads them); the sequence takes
\[ \sum_j w_j ( p_{j+1} - p_j ) + m \, ( 192 + \lceil \log_2 n \rceil + 2 \lceil \log_2 m \rceil ) \]
bits about for \( m \) segments: 24 bytes for the base, the slope and the place and the width of the corrections, the first place in a field of \( \lceil \log_2 n \rceil \) bits, and the two tables of the searches, about a segment number each, in fields of \( \lceil \log_2 m \rceil \) bits; the first item of a segment is not kept, but read as its base plus its first correction. On a sequence with long runs of nearly constant gaps (the places of a regular pattern, the keys of a data set produced by a process) \( m \) is small and \( c \) bits are well below the \( 2 + \log_2( u / n ) \) of Elias-Fano [see EliasFano.h]; on random gaps the corrections cost about what the low bits of Elias-Fano cost and the segments are pure overhead. tuned() picks the \( c \) of the fewest bits, by building the sequence for each \( c \) in turn. The LA-vector of the paper chooses \( c \) segment by segment, by a shortest path on the segments of all the \( c \); here the width \( w_j \) of each segment adapts to its corrections anyway, and on the sequences of the benchmark learned the shortest path changed the bits by a few hundredths of tuned(), at the price of a slower construction, which is why it is not kept.
The operations:
The contracts [see Contract.h]: the sequence is non-decreasing (an audit) with fewer than \( 2^{32} \) items, \( 0 \le c \le 63 \), access() needs \( i < n \); the audit of the construction is that access() gives back each item, and the postcondition of nextGEQ() is that the items before the place are \( < x \) and the one at it is not. The functions are defined in LAVector.tpp.