the compressed PGM-index on a sorted array of arithmetic keys K, with the error \( \epsilon = E \)
More...
#include <ADS/search/CompressedPGMIndex.h>
|
| using | Item = K |
| | the type of the items
|
|
| | CompressedPGMIndex (void)=default |
| | an empty index
|
| | CompressedPGMIndex (std::vector< K > A) |
| | the index on the sorted items of \( A \)
|
| std::size_t | lowerBound (const K &v) const |
| | the first place of an item not smaller than \( v \), size() if none
|
| bool | contains (const K &v) const |
| | true if \( v \) is an item, by lowerBound( v )
|
| const K & | operator[] (std::size_t i) const |
| | the item of place \( i \)
|
| std::size_t | size (void) const |
| | the number \( n \) of the items
|
| bool | empty (void) const |
| | true if there are no items
|
| std::size_t | segments (void) const |
| | the segments, \( m \)
|
| std::size_t | slopes (void) const |
| | the distinct slopes, \( \sigma \)
|
| std::size_t | bytes (void) const |
| | the bytes of the index, the items aside
|
| template<class A> |
| void | persist (A &a) |
| | the members written to, or read from, the archive \( a \) [see Persistence.h]
|
|
| static constexpr std::uint64_t | persistTag (void) |
| | the type of the keys and the error, in a file
|
|
| static constexpr std::string_view | persistName = "CompressedPGMIndex" |
| | the name of the structure in a file [see Persistence.h]
|
template<class K, std::size_t E = 64>
requires std::is_arithmetic_v< K >
class ADS::CompressedPGMIndex< K, E >
the compressed PGM-index on a sorted array of arithmetic keys K, with the error \( \epsilon = E \)
◆ Item
template<class K, std::size_t E = 64>
◆ CompressedPGMIndex() [1/2]
template<class K, std::size_t E = 64>
◆ CompressedPGMIndex() [2/2]
template<class K, std::size_t E = 64>
the index on the sorted items of \( A \)
In pseudocode (Ferragina and Vinciguerra, beyond the book), the segments \( g \) of the optimal approximation with their intervals of slopes \( [ g.\alpha^- , g.\alpha^+ ] \):
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{procedure}\ \mathrm{build}( A ) \cr
2 & \quad G \gets \mathrm{approximate}( \text{the distinct keys of } A
, \text{their first places} , \epsilon )\quad \triangleright
\ \text{see } \mathrm{PGMIndex} \cr
3 & \quad S \gets \text{an empty table};\ I \gets [ -\infty , \infty ]
\cr
4 & \quad \textbf{foreach}\ g \in G \text{ by increasing }
g.\alpha^-\ \textbf{do}\quad \triangleright\ \text{the stabbing of }
\text{the intervals} \cr
5 & \qquad \textbf{if}\ g.\alpha^- > \max I\ \textbf{then}
\ \mathrm{append}( S , \text{the middle of } I );\ I \gets [
g.\alpha^- , g.\alpha^+ ] \cr
6 & \qquad \textbf{else}\ I \gets I \cap [ g.\alpha^- , g.\alpha^+ ] \cr
7 & \qquad g.\sigma \gets | S | \cr
8 & \quad \mathrm{append}( S , \text{the middle of } I ) \cr
9 & \quad \textbf{foreach}\ g \in G\ \textbf{do} \cr
10 & \qquad \alpha \gets S[ g.\sigma ];\ \beta \gets \text{the middle }
\text{of } [ \max_i ( y_i - \alpha x_i ) - \epsilon ,
\min_i ( y_i - \alpha x_i ) + \epsilon ] \text{ on its points} \cr
11 & \qquad \textbf{if}\ \text{the line } ( \alpha , \beta )
\text{ misses a point by more than } \epsilon + 1\ \textbf{then}
\ \text{give } g \text{ its own slope} \cr
12 & \qquad \text{write } g.\sigma \text{ and } \beta \text{ less its }
\text{first place in a field of bits} \cr
13 & \quad \text{the first places of } G \text{ by Elias-Fano, the }
\text{first keys with a PGM-index}
\end{array}}
\]
- Precondition
- \( A \) is sorted (audit), \( n < 2^{32} \)
◆ bytes()
template<class K, std::size_t E = 64>
the bytes of the index, the items aside
◆ contains()
template<class K, std::size_t E = 64>
true if \( v \) is an item, by lowerBound( v )
◆ empty()
template<class K, std::size_t E = 64>
true if there are no items
◆ lowerBound()
template<class K, std::size_t E = 64>
the first place of an item not smaller than \( v \), size() if none
In pseudocode (Ferragina and Vinciguerra, beyond the book), \( k_s \) and \( p_s \) the first key and the first place of the segment \( s \):
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{lowerBound}( v ) \cr
2 & \quad \textbf{if}\ n = 0 \text{ or } v < A[ 0 ]
\ \textbf{then return}\ 0 \cr
3 & \quad s \gets \text{the last first key not larger than } v
\text{, by their PGM-index} \cr
4 & \quad p \gets p_s + \delta_s + S[ \sigma_s ] ( v - k_s )
\text{, clamped to } [ p_s , p_{s+1} ] \cr
5 & \quad \textbf{return}\ \mathrm{lowerBound}( A , v , p - \epsilon - 2
, p + \epsilon + 3 )\quad \triangleright\ \text{galloping out of }
\text{the window if needed}
\end{array}}
\]
- Postcondition
- \( A[ r - 1 ] < v \le A[ r ] \)
◆ operator[]()
template<class K, std::size_t E = 64>
the item of place \( i \)
- Precondition
- \( i < n \)
◆ persist()
template<class K, std::size_t E = 64>
template<class A>
the members written to, or read from, the archive \( a \) [see Persistence.h]
◆ persistTag()
template<class K, std::size_t E = 64>
|
|
inlinestaticnodiscardconstexpr |
the type of the keys and the error, in a file
◆ segments()
template<class K, std::size_t E = 64>
◆ size()
template<class K, std::size_t E = 64>
the number \( n \) of the items
◆ slopes()
template<class K, std::size_t E = 64>
the distinct slopes, \( \sigma \)
◆ persistName
template<class K, std::size_t E = 64>
The documentation for this class was generated from the following file: