|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Premium MapArena example: persistence, offsets, and restart. More...
#include <ah-map-arena.H>#include <cstddef>#include <cstdint>#include <cstring>#include <filesystem>#include <iostream>#include <limits>#include <stdexcept>#include <string>#include <vector>Go to the source code of this file.
Functions | |
| int | main () |
Premium MapArena example: persistence, offsets, and restart.
This example focuses on a typical Aleph::MapArena use case (defined in ah-map-arena.H): building a persistent, append-only log backed by a memory-mapped file that can be recovered after reopening the file.
end (a size_t) holding the logical end offset (committed bytes).MapArena reads a size_t from the beginning of the file on open.[uint32_t len][len bytes payload].mremap():reserve() may trigger mremap() and move the region, invalidating previously returned pointers. Therefore, we use the pattern: reserve -> write -> commit -> (optional) sync, and we avoid keeping pointers for long periods.base + offset.This file is built as part of the examples (see Examples/CMakeLists.txt) when -DBUILD_EXAMPLES=ON.
The example creates a temporary file in /tmp and simulates a "restart" by reopening the file multiple times within the same process.
Definition in file map_arena_persistence_example.cc.
| int main | ( | ) |
Definition at line 236 of file map_arena_persistence_example.cc.
References Aleph::maps().