ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
MMappedCircuit.cpp File Reference

Persistent mmap-backed circuit: implementation and background-worker entry points. More...

#include <cerrno>
#include <cmath>
#include <map>
#include <sstream>
#include <string>
#include "MMappedCircuit.h"
#include "GenericCircuit.h"
#include "Circuit.hpp"
#include "provsql_utils_cpp.h"
#include "miscadmin.h"
#include "provsql_mmap.h"
#include "provsql_shmem.h"
Include dependency graph for MMappedCircuit.cpp:

Go to the source code of this file.

Functions

void initialize_provsql_mmap ()
 Open (or create) the mmap files and initialise the circuit store.
void destroy_provsql_mmap ()
 Unmap and close the mmap files.
static MMappedCircuitgetCircuit (Oid db_oid)
 Return (creating lazily if needed) the circuit for db_oid.
void provsql_mmap_main_loop ()
 Main processing loop of the mmap background worker.
bool operator< (const pg_uuid_t a, const pg_uuid_t b)
 Lexicographic less-than comparison for pg_uuid_t.

Variables

static std::map< Oid, MMappedCircuit * > circuits
 Per-database mmap-backed provenance circuits, keyed by database OID.

Detailed Description

Persistent mmap-backed circuit: implementation and background-worker entry points.

Implements the MMappedCircuit methods declared in MMappedCircuit.h, the createGenericCircuit() free function, and the background-worker entry points declared in provsql_mmap.h:

The createGenericCircuit() function performs a BFS from a root UUID, reading gates from the mmap store and building an in-memory GenericCircuit.

Definition in file MMappedCircuit.cpp.

Function Documentation

◆ destroy_provsql_mmap()

void destroy_provsql_mmap ( void )

Unmap and close the mmap files.

Called by the background worker on shutdown to release resources and ensure all dirty pages are synced to disk via msync().

Definition at line 60 of file MMappedCircuit.cpp.

Here is the caller graph for this function:

◆ getCircuit()

MMappedCircuit * getCircuit ( Oid db_oid)
static

Return (creating lazily if needed) the circuit for db_oid.

Definition at line 197 of file MMappedCircuit.cpp.

Here is the caller graph for this function:

◆ initialize_provsql_mmap()

void initialize_provsql_mmap ( void )

Open (or create) the mmap files and initialise the circuit store.

Called once by the background worker at startup. Creates the four mmap-backed data files if they do not yet exist and maps them into the worker's address space.

Definition at line 55 of file MMappedCircuit.cpp.

Here is the caller graph for this function:

◆ operator<()

bool operator< ( const pg_uuid_t a,
const pg_uuid_t b )

Lexicographic less-than comparison for pg_uuid_t.

Parameters
aLeft UUID.
bRight UUID.
Returns
true if a is lexicographically less than b.

Definition at line 645 of file MMappedCircuit.cpp.

◆ provsql_mmap_main_loop()

void provsql_mmap_main_loop ( void )

Main processing loop of the mmap background worker.

Waits for gate-creation requests from backend processes, processes them by writing to the mmap files, and handles SIGTERM for graceful shutdown.

Definition at line 207 of file MMappedCircuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ circuits

std::map<Oid, MMappedCircuit*> circuits
static

Per-database mmap-backed provenance circuits, keyed by database OID.

Definition at line 39 of file MMappedCircuit.cpp.