|
ADS
Algorithms and Data Structures
|
The persistent structures of ADS [see Persistence.h] in the archives of cereal (https://uscilab.github.io/cereal/), beside the format of ADS: a program that includes this header writes a RankSelect, a WaveletMatrix or a BinaryFuseFilter with ar( x ) into its own archives, binary, portable binary, JSON or XML, next to its other data, and reads it back in the same way. More...
#include "ADS/external/Persistence.h"#include "ADS/succinct/BitVector.h"#include <cereal/cereal.hpp>#include <cereal/types/array.hpp>#include <cereal/types/string.hpp>#include <cereal/types/utility.hpp>#include <cstddef>#include <cstdint>#include <cstring>#include <string>#include <type_traits>#include <vector>Go to the source code of this file.
Namespaces | |
| namespace | ADS |
Functions | |
| template<class Ar, Persistent T> | |
| void | ADS::save (Ar &a, const T &x) |
| the structure \( x \) written to the archive \( a \) of cereal | |
| template<class Ar, Persistent T> | |
| void | ADS::load (Ar &a, T &x) |
| the structure \( x \) read from the archive \( a \) of cereal | |
| template<class Ar> | |
| void | ADS::save (Ar &a, const BitVector &b) |
| the bits \( b \) written to the archive \( a \) of cereal, as sdsl-lite writes a bit_vector | |
| template<class Ar> | |
| void | ADS::load (Ar &a, BitVector &b) |
| the bits \( b \) read from the archive \( a \) of cereal, as sdsl-lite writes a bit_vector | |
The persistent structures of ADS [see Persistence.h] in the archives of cereal (https://uscilab.github.io/cereal/), beside the format of ADS: a program that includes this header writes a RankSelect, a WaveletMatrix or a BinaryFuseFilter with ar( x ) into its own archives, binary, portable binary, JSON or XML, next to its other data, and reads it back in the same way.
The non-member save() and load() below, found by cereal by the lookup that depends on the arguments, run the same persist() of the structure as store() and restore() do, through an archive that hands each member to cereal: a number, a string, a std::array and a std::pair as cereal writes them, an array of numbers as its size and, in a binary archive, its bytes at once, a nested structure as a structure of its own; and the invariants that the structure requires are checked on a reading, which throws PersistError if one fails. A mapped file has no equivalent here, since an archive of cereal is read by parsing it.
A BitVector is written as sdsl-lite writes its bit_vector (the int_vector< 1 > of its version 3, which serializes by cereal): the width 1 as an 8-bit size, the factor of growth as a float, the number of bits as a 64-bit size, and the words that hold them, \( \lceil n / 64 \rceil \), the bit \( i \) in the bit \( i \bmod 64 \) of the word \( \lfloor i / 64 \rfloor \) in both libraries; in an archive that is not binary, the bits one by one as integers of 64 bits (the value_type of a bit_vector), under the names of sdsl. The two libraries thus read the vectors of bits that the other writes, and the structures built on them hold them in the same form; the directories of rank and select, whose layouts differ, are not interchangeable, and neither are PackedArray and int_vector< w >, since the former keeps its fields within a word and the latter lets them cross.
This header is of the set interop: no entry point of ADS includes it, and it needs the headers of cereal (1.3 or later), found by CMake when ADS_WITH_CEREAL is AUTO or ON.