a minimal perfect hash function of a static set of keys by recursive splitting, with leaves of at most L keys
More...
#include <ADS/dictionary/RecSplit.h>
|
| using | Key = T |
| | the type of the keys
|
|
| | RecSplit (void) |
| | the function of no key
|
| | RecSplit (const std::vector< T > &keys, std::size_t b=100, std::uint64_t seed=1, H h=H()) |
| | the function of the distinct keys, with \( b \) keys per bucket on average
|
| std::size_t | operator() (const T &k) const |
| | the value of \( k \), in \( [ 0 , n ) \); some value in it for a key out of \( S \)
|
| std::size_t | size (void) const |
| | the number \( n \) of keys
|
| bool | empty (void) const |
| | true if there are no keys
|
| std::size_t | bits (void) const |
| | the bits of the function: the codes, the two Elias-Fano sequences with their directories and the object
|
| std::size_t | buckets (void) const |
| | the number of buckets
|
| std::size_t | trials (void) const |
| | the seeds drawn by the build
|
| 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 parameters of the layout, in a file
|
template<class T, unsigned L = 8, class H = DefaultHash< T >>
class ADS::RecSplit< T, L, H >
a minimal perfect hash function of a static set of keys by recursive splitting, with leaves of at most L keys
◆ Key
template<class T, unsigned L = 8, class H = DefaultHash< T >>
◆ RecSplit() [1/2]
template<class T, unsigned L = 8, class H = DefaultHash< T >>
◆ RecSplit() [2/2]
template<class T, unsigned L = 8, class H = DefaultHash< T >>
| ADS::RecSplit< T, L, H >::RecSplit |
( |
const std::vector< T > & | keys, |
|
|
std::size_t | b = 100, |
|
|
std::uint64_t | seed = 1, |
|
|
H | h = H() ) |
|
explicit |
the function of the distinct keys, with \( b \) keys per bucket on average
In pseudocode (Esposito, Mueller Graf and Vigna, beyond the book), the recursive splitting of a node of \( m \) keys at the depth \( d \), its seeds written in preorder by the code of Golomb and Rice:
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{procedure}\ \mathrm{split}( K , m , d ) \cr
2 & \quad \textbf{if}\ m \le 1\ \textbf{then return} \cr
3 & \quad \textbf{if}\ m \le \ell\ \textbf{then}\ x \gets
\text{the first } \text{seed (with the rotation) that maps } K
\text{ onto } [ 0 , m ) \cr
4 & \quad \textbf{else} \cr
5 & \qquad k_0 , \ldots , k_{s-1} \gets \text{the sizes of the parts}
\text{ (lower, upper aggregation or two halves)} \cr
6 & \qquad x \gets \text{the first seed whose places give each part its }
\text{size} \cr
7 & \quad \text{write the code of } x \cr
8 & \quad \textbf{if}\ m > \ell\ \textbf{then foreach}\ \text{part } K_i
\ \textbf{do}\ \mathrm{split}( K_i , k_i , d + 1 ) \cr
9 & \textbf{procedure}\ \mathrm{build}( S , b ) \cr
10 & \quad \text{group the keys into } \lceil n / b \rceil
\text{ buckets } \text{by } h_1 \cr
11 & \quad \textbf{foreach}\ \text{bucket } B\ \textbf{do}
\ \mathrm{split}( \text{the } h_2 \text{ of } B , |B| , 0 ) \cr
12 & \quad \text{the keys before each bucket and the place of its codes }
\text{as Elias-Fano}
\end{array}}
\]
- Precondition
- the keys are distinct (an audit) and fewer than \( 2^{32} \), and \( 1 \le b \le 2000 \)
- Postcondition
- the keys are mapped onto \( \{ 0 , \ldots , n - 1 \} \) (an audit)
◆ bits()
template<class T, unsigned L = 8, class H = DefaultHash< T >>
the bits of the function: the codes, the two Elias-Fano sequences with their directories and the object
◆ buckets()
template<class T, unsigned L = 8, class H = DefaultHash< T >>
◆ empty()
template<class T, unsigned L = 8, class H = DefaultHash< T >>
true if there are no keys
◆ operator()()
template<class T, unsigned L = 8, class H = DefaultHash< T >>
| std::size_t ADS::RecSplit< T, L, H >::operator() |
( |
const T & | k | ) |
const |
|
nodiscard |
the value of \( k \), in \( [ 0 , n ) \); some value in it for a key out of \( S \)
In pseudocode (Esposito, Mueller Graf and Vigna, beyond the book), the descent of the splitting tree of the bucket of \( k \), the earlier siblings skipped by the tables of the sizes:
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{value}( k ) \cr
2 & \quad b \gets \text{the bucket of } h_1( k );\ \mathit{out} \gets
\text{the keys before } b;\ m \gets |b| \cr
3 & \quad \textbf{for}\ d \gets 0 , 1 , \ldots\ \textbf{do} \cr
4 & \qquad \textbf{if}\ m \le 1\ \textbf{then return}\ \mathit{out} \cr
5 & \qquad x \gets \text{the next seed};\ p \gets \rho_x( h_2( k ) )
\cr
6 & \qquad \textbf{if}\ m \le \ell\ \textbf{then return}\ \mathit{out} +
p\quad \triangleright\ \text{rotated if } k \in B \cr
7 & \qquad j \gets \text{the part of } p;\ \text{skip the codes of the }
\text{parts before } j \cr
8 & \qquad \mathit{out} \gets \mathit{out} + \text{the keys of the parts }
\text{before } j;\ m \gets k_j
\end{array}}
\]
- Precondition
- size() \( \ge 1 \)
◆ persist()
template<class T, unsigned L = 8, class H = DefaultHash< T >>
template<class A>
the members written to, or read from, the archive \( a \) [see Persistence.h]
◆ persistTag()
template<class T, unsigned L = 8, class H = DefaultHash< T >>
| constexpr std::uint64_t ADS::RecSplit< T, L, H >::persistTag |
( |
void | | ) |
|
|
inlinestaticnodiscardconstexpr |
the parameters of the layout, in a file
◆ size()
template<class T, unsigned L = 8, class H = DefaultHash< T >>
the number \( n \) of keys
◆ trials()
template<class T, unsigned L = 8, class H = DefaultHash< T >>
the seeds drawn by the build
◆ persistName
template<class T, unsigned L = 8, class H = DefaultHash< T >>
| std::string_view ADS::RecSplit< T, L, H >::persistName = "RecSplit" |
|
staticconstexpr |
The documentation for this class was generated from the following file: