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 <sstream>
#include "MMappedCircuit.h"
#include "GenericCircuit.h"
#include "Circuit.hpp"
#include "provsql_utils_cpp.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.
 
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.
 
GenericCircuit createGenericCircuit (pg_uuid_t token)
 Build an in-memory GenericCircuit rooted at token.
 

Variables

static MMappedCircuitcircuit = NULL
 Singleton pointer to the process-wide mmap-backed provenance circuit.
 

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

◆ createGenericCircuit()

GenericCircuit createGenericCircuit ( pg_uuid_t  token)

Build an in-memory GenericCircuit rooted at token.

Performs a depth-first traversal of the mmap-backed circuit starting from token and copies all reachable gates and wires into a newly constructed GenericCircuit.

Parameters
tokenUUID of the root gate.
Returns
An in-memory GenericCircuit containing the sub-circuit.

Definition at line 349 of file MMappedCircuit.cpp.

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

◆ 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 43 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 38 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 344 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 148 of file MMappedCircuit.cpp.

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

Variable Documentation

◆ circuit

MMappedCircuit* circuit = NULL
static

Singleton pointer to the process-wide mmap-backed provenance circuit.

Definition at line 36 of file MMappedCircuit.cpp.