ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
LAVector.h File Reference

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

Detailed description

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:

  • access( i ) finds the segment of \( i \) through a table of the segment of every \( 2^t \)-th place (\( 2^t \approx n / m \), so that a block of places meets one segment or two on the average), and returns \( f_j( i ) + C[ i ] \), in \( O( 1 ) \) expected time;
  • nextGEQ( x ), the place of the first item \( \ge x \), finds the last segment whose first item is smaller than \( x \) through a table on the high bits of the items (\( m \) buckets, the first segment of each), then inverts the line: since \( f_j( i ) \le x_i < f_j( i ) + 2^{w_j} \), the answer lies between the places where \( f_j \) reaches \( x - 2^{w_j} + 1 \) and \( x \), \( 2^{w_j} / \alpha_j + 2 \) places, searched by a binary search on the corrections, in \( O( c - \log_2 \alpha_j ) \) time once the segment is found; the whole segment is searched when the floating point misplaces the window, which is checked.

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.

See also
A. Boffa, P. Ferragina, G. Vinciguerra, A "learned" approach to quicken and compress rank/select dictionaries, Proceedings of the 23rd ALENEX, 46-59, 2021, doi:10.1137/1.9781611976472.4
A. Boffa, P. Ferragina, G. Vinciguerra, A learned approach to design compressed rank/select data structures, ACM Transactions on Algorithms 18(3), 1-28, 2022, doi:10.1145/3524060
P. Ferragina, G. Vinciguerra, The PGM-index: a fully-dynamic compressed learned index with provable worst-case bounds, Proceedings of the VLDB Endowment 13(8), 1162-1175, 2020, doi:10.14778/3389133.3389135
Author
Donato Meoli
Dipartimento di Informatica
Università di Pisa