The persistence of the static structures of ADS, beyond the book.
More...
|
| file | ADS/external/Persistence.h |
| | The persistence of the static structures of ADS, beyond the book: a structure built once (a succinct index, a filter, a minimal perfect hash function, a graph in CSR form) is written to a file, a stream or a buffer by store(), and read back by restore(), or opened in place by restoreMapped(), which maps the file [see MappedFile.h] and makes the large arrays of the structure views over its bytes, with no copy and no parsing, so that an index of any size is opened in \( O( 1 ) \) time and its pages are read from the disk at their first access.
|
|
| concept | ADS::Persistent |
| | a structure that store() writes and restore() reads: it names itself, lists its members in persist(), and is made empty by its default constructor or, if it has none, by its persistEmpty()
|
|
| template<Persistent T> |
| void | ADS::store (const T &x, std::ostream &s, ByteOrder o=ByteOrder::native) |
| | the structure \( x \) written to the stream \( s \), its payload in the order \( o \)
|
| template<Persistent T> |
| void | ADS::store (const T &x, const std::filesystem::path &p, ByteOrder o=ByteOrder::native) |
| | the structure \( x \) written to the file \( p \), made or replaced, its payload in the order \( o \)
|
| template<Persistent T> |
| std::vector< std::byte > | ADS::store (const T &x, ByteOrder o=ByteOrder::native) |
| | the bytes of the structure \( x \), as in a file, its payload in the order \( o \)
|
| template<Persistent T> |
| T | ADS::restore (std::istream &s) |
| | the structure read from the stream \( s \), its checksum checked
|
| template<Persistent T> |
| T | ADS::restore (std::span< const std::byte > b) |
| | the structure read from the bytes \( b \), its checksum checked
|
| template<Persistent T> |
| T | ADS::restore (const std::filesystem::path &p) |
| | the structure read from the file \( p \), its checksum checked
|
| template<Persistent T> |
| T | ADS::restoreMapped (const std::filesystem::path &p, bool verify=false) |
| | the structure of the file \( p \) mapped in memory, its arrays views over the mapping (copies if the file is of the other byte order, or the array is not on the allocator of the views), its checksum checked if \( \mathit{verify} \); the mapping lives as long as a view of it
|
The persistence of the static structures of ADS, beyond the book.
The definitions, the invariants and the costs of the area are in Theory of external memory.
◆ ByteOrder
the byte order of the payload of a file
| Enumerator |
|---|
| little | the least significant byte first
|
| big | the most significant byte first
|
| native | the order of the machine
|
◆ restore() [1/3]
template<Persistent T>
| T ADS::restore |
( |
const std::filesystem::path & | p | ) |
|
|
nodiscard |
the structure read from the file \( p \), its checksum checked
- Exceptions
-
| PersistError | if the file does not hold a valid \( T \) |
◆ restore() [2/3]
template<Persistent T>
| T ADS::restore |
( |
std::istream & | s | ) |
|
|
nodiscard |
the structure read from the stream \( s \), its checksum checked
- Exceptions
-
| PersistError | if the stream does not hold a valid \( T \) |
◆ restore() [3/3]
template<Persistent T>
| T ADS::restore |
( |
std::span< const std::byte > | b | ) |
|
|
nodiscard |
the structure read from the bytes \( b \), its checksum checked
- Exceptions
-
| PersistError | if the bytes are not a valid \( T \) |
◆ restoreMapped()
template<Persistent T>
| T ADS::restoreMapped |
( |
const std::filesystem::path & | p, |
|
|
bool | verify = false ) |
|
nodiscard |
the structure of the file \( p \) mapped in memory, its arrays views over the mapping (copies if the file is of the other byte order, or the array is not on the allocator of the views), its checksum checked if \( \mathit{verify} \); the mapping lives as long as a view of it
- Exceptions
-
| PersistError | if the file does not hold a valid \( T \) |
◆ store() [1/3]
the bytes of the structure \( x \), as in a file, its payload in the order \( o \)
◆ store() [2/3]
the structure \( x \) written to the file \( p \), made or replaced, its payload in the order \( o \)
- Exceptions
-
| PersistError | if the file cannot be written |
◆ store() [3/3]
the structure \( x \) written to the stream \( s \), its payload in the order \( o \)
- Exceptions
-
| PersistError | if the stream fails |