![]() |
ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
|
File-backed memory region with two interchangeable backends. More...
#include <cerrno>#include <cstddef>#include <cstdlib>#include <cstring>#include <stdexcept>#include <fcntl.h>#include <unistd.h>#include "provsql_config.h"#include <sys/mman.h>

Go to the source code of this file.
Classes | |
| class | MappedRegion |
File-backed memory region with two interchangeable backends.
A MappedRegion owns a backing file and a base pointer to length() bytes of it, with map() / remap() / sync() / close(). It is the single storage primitive under MMappedVector and MMappedUUIDHashTable.
Multi-process build: the region is a shared (MAP_SHARED) mmap of the file. The kernel keeps the mapping coherent across the backends and the worker and flushes dirty pages, so a backend's writes are visible to the others through the same file.
Single-process build (PROVSQL_INPROCESS_STORE): the region is a heap buffer loaded from the file on map() and written back explicitly on sync() / close(). Emscripten does not support MAP_SHARED write-back, and with a single process a shared mapping has no purpose; the file still lives under $PGDATA, so PGlite persists it. Write-back timing is the caller's responsibility (the store registers an on_proc_exit hook so a backend flushes before it exits).
Definition in file MappedRegion.h.