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

Persistent mmap-backed representation of the provenance circuit. More...

#include "MMappedCircuit.h"

Collaboration diagram for MMappedCircuit:

Public Member Functions

 MMappedCircuit (bool read_only=false)
 Open all four mmap backing files.
 
 ~MMappedCircuit ()
 Sync all backing files before destruction.
 
void createGate (pg_uuid_t token, gate_type type, const std::vector< pg_uuid_t > &children)
 Persist a new gate to the mmap store.
 
void setInfos (pg_uuid_t token, unsigned info1, unsigned info2)
 Update the info1 / info2 annotations of a gate.
 
void setExtra (pg_uuid_t token, const std::string &s)
 Attach a variable-length string annotation to a gate.
 
bool setProb (pg_uuid_t token, double prob)
 Set the probability associated with a gate.
 
void sync ()
 Flush all backing files to disk with msync().
 
gate_type getGateType (pg_uuid_t token) const
 Return the type of the gate identified by token.
 
std::vector< pg_uuid_tgetChildren (pg_uuid_t token) const
 Return the child UUIDs of the gate identified by token.
 
double getProb (pg_uuid_t token) const
 Return the probability stored for the gate identified by token.
 
std::pair< unsigned, unsigned > getInfos (pg_uuid_t token) const
 Return the info1 / info2 pair for the gate token.
 
std::string getExtra (pg_uuid_t token) const
 Return the variable-length string annotation for gate token.
 
unsigned long getNbGates () const
 Return the total number of gates stored in the circuit.
 

Private Attributes

MMappedUUIDHashTable mapping
 UUID → gate-index hash table.
 
MMappedVector< GateInformationgates
 Gate metadata array.
 
MMappedVector< pg_uuid_twires
 Flattened child UUID array.
 
MMappedVector< char > extra
 Variable-length string data.
 

Static Private Attributes

static constexpr const char * GATES_FILENAME ="provsql_gates.mmap"
 Backing file for gates.
 
static constexpr const char * WIRES_FILENAME ="provsql_wires.mmap"
 Backing file for wires.
 
static constexpr const char * MAPPING_FILENAME ="provsql_mapping.mmap"
 Backing file for mapping.
 
static constexpr const char * EXTRA_FILENAME ="provsql_extra.mmap"
 Backing file for extra.
 

Detailed Description

Persistent mmap-backed representation of the provenance circuit.

MMappedCircuit is the single writer for circuit data; only the background worker should call its mutating methods. Reading methods may be called from any process that has mapped the files read-only.

Definition at line 73 of file MMappedCircuit.h.

Constructor & Destructor Documentation

◆ MMappedCircuit()

MMappedCircuit::MMappedCircuit ( bool  read_only = false)
inlineexplicit

Open all four mmap backing files.

Parameters
read_onlyIf true, all files are mapped read-only.

Definition at line 90 of file MMappedCircuit.h.

◆ ~MMappedCircuit()

MMappedCircuit::~MMappedCircuit ( )
inline

Sync all backing files before destruction.

Definition at line 97 of file MMappedCircuit.h.

Here is the call graph for this function:

Member Function Documentation

◆ createGate()

void MMappedCircuit::createGate ( pg_uuid_t  token,
gate_type  type,
const std::vector< pg_uuid_t > &  children 
)

Persist a new gate to the mmap store.

Allocates a GateInformation record, appends the children to the wires vector, and records the UUID→index mapping. Existing gates with the same token are silently skipped.

Parameters
tokenUUID identifying the new gate.
typeGate type.
childrenOrdered list of child gate UUIDs.

Definition at line 48 of file MMappedCircuit.cpp.

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

◆ getChildren()

std::vector< pg_uuid_t > MMappedCircuit::getChildren ( pg_uuid_t  token) const

Return the child UUIDs of the gate identified by token.

Parameters
tokenUUID of the gate.
Returns
Ordered vector of child UUIDs.

Definition at line 71 of file MMappedCircuit.cpp.

Here is the caller graph for this function:

◆ getExtra()

std::string MMappedCircuit::getExtra ( pg_uuid_t  token) const

Return the variable-length string annotation for gate token.

Parameters
tokenUUID of the gate.
Returns
The stored string, or empty if none.

Definition at line 135 of file MMappedCircuit.cpp.

Here is the caller graph for this function:

◆ getGateType()

gate_type MMappedCircuit::getGateType ( pg_uuid_t  token) const

Return the type of the gate identified by token.

Parameters
tokenUUID of the gate.
Returns
The gate's type, or gate_invalid if not found.

Definition at line 62 of file MMappedCircuit.cpp.

Here is the caller graph for this function:

◆ getInfos()

std::pair< unsigned, unsigned > MMappedCircuit::getInfos ( pg_uuid_t  token) const

Return the info1 / info2 pair for the gate token.

Parameters
tokenUUID of the gate.
Returns
Pair {info1, info2}, or {0,0} if not found.

Definition at line 124 of file MMappedCircuit.cpp.

Here is the caller graph for this function:

◆ getNbGates()

unsigned long MMappedCircuit::getNbGates ( ) const
inline

Return the total number of gates stored in the circuit.

Returns
Total gate count.

Definition at line 181 of file MMappedCircuit.h.

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

◆ getProb()

double MMappedCircuit::getProb ( pg_uuid_t  token) const

Return the probability stored for the gate identified by token.

Parameters
tokenUUID of the gate.
Returns
The probability, or 1.0 if the gate is not found.

Definition at line 94 of file MMappedCircuit.cpp.

Here is the caller graph for this function:

◆ setExtra()

void MMappedCircuit::setExtra ( pg_uuid_t  token,
const std::string &  s 
)

Attach a variable-length string annotation to a gate.

Parameters
tokenUUID of the gate.
sString to store.

Definition at line 113 of file MMappedCircuit.cpp.

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

◆ setInfos()

void MMappedCircuit::setInfos ( pg_uuid_t  token,
unsigned  info1,
unsigned  info2 
)

Update the info1 / info2 annotations of a gate.

Parameters
tokenUUID of the gate to update.
info1New value for info1.
info2New value for info2.

Definition at line 104 of file MMappedCircuit.cpp.

Here is the caller graph for this function:

◆ setProb()

bool MMappedCircuit::setProb ( pg_uuid_t  token,
double  prob 
)

Set the probability associated with a gate.

Parameters
tokenUUID of the gate.
probProbability value in [0, 1].
Returns
true if the gate was found and updated; false otherwise.

Definition at line 83 of file MMappedCircuit.cpp.

Here is the caller graph for this function:

◆ sync()

void MMappedCircuit::sync ( )

Flush all backing files to disk with msync().

Definition at line 331 of file MMappedCircuit.cpp.

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

Member Data Documentation

◆ extra

MMappedVector<char> MMappedCircuit::extra
private

Variable-length string data.

Definition at line 78 of file MMappedCircuit.h.

◆ EXTRA_FILENAME

constexpr const char* MMappedCircuit::EXTRA_FILENAME ="provsql_extra.mmap"
staticconstexprprivate

Backing file for extra.

Definition at line 83 of file MMappedCircuit.h.

◆ gates

MMappedVector<GateInformation> MMappedCircuit::gates
private

Gate metadata array.

Definition at line 76 of file MMappedCircuit.h.

◆ GATES_FILENAME

constexpr const char* MMappedCircuit::GATES_FILENAME ="provsql_gates.mmap"
staticconstexprprivate

Backing file for gates.

Definition at line 80 of file MMappedCircuit.h.

◆ mapping

MMappedUUIDHashTable MMappedCircuit::mapping
private

UUID → gate-index hash table.

Definition at line 75 of file MMappedCircuit.h.

◆ MAPPING_FILENAME

constexpr const char* MMappedCircuit::MAPPING_FILENAME ="provsql_mapping.mmap"
staticconstexprprivate

Backing file for mapping.

Definition at line 82 of file MMappedCircuit.h.

◆ wires

MMappedVector<pg_uuid_t> MMappedCircuit::wires
private

Flattened child UUID array.

Definition at line 77 of file MMappedCircuit.h.

◆ WIRES_FILENAME

constexpr const char* MMappedCircuit::WIRES_FILENAME ="provsql_wires.mmap"
staticconstexprprivate

Backing file for wires.

Definition at line 81 of file MMappedCircuit.h.


The documentation for this class was generated from the following files: