![]() |
ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
|
Persistent mmap-backed representation of the provenance circuit. More...
#include "MMappedCircuit.h"

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_t > | getChildren (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< GateInformation > | gates |
| Gate metadata array. | |
| MMappedVector< pg_uuid_t > | wires |
| 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. | |
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.
|
inlineexplicit |
Open all four mmap backing files.
| read_only | If true, all files are mapped read-only. |
Definition at line 90 of file MMappedCircuit.h.
|
inline |
Sync all backing files before destruction.
Definition at line 97 of file MMappedCircuit.h.

| 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.
| token | UUID identifying the new gate. |
| type | Gate type. |
| children | Ordered list of child gate UUIDs. |
Definition at line 48 of file MMappedCircuit.cpp.


Return the child UUIDs of the gate identified by token.
| token | UUID of the gate. |
Definition at line 71 of file MMappedCircuit.cpp.

| std::string MMappedCircuit::getExtra | ( | pg_uuid_t | token | ) | const |
Return the variable-length string annotation for gate token.
| token | UUID of the gate. |
Definition at line 135 of file MMappedCircuit.cpp.

Return the type of the gate identified by token.
| token | UUID of the gate. |
gate_invalid if not found. Definition at line 62 of file MMappedCircuit.cpp.

| std::pair< unsigned, unsigned > MMappedCircuit::getInfos | ( | pg_uuid_t | token | ) | const |
Return the info1 / info2 pair for the gate token.
| token | UUID of the gate. |
{info1, info2}, or {0,0} if not found. Definition at line 124 of file MMappedCircuit.cpp.

|
inline |
Return the total number of gates stored in the circuit.
Definition at line 181 of file MMappedCircuit.h.


| double MMappedCircuit::getProb | ( | pg_uuid_t | token | ) | const |
Return the probability stored for the gate identified by token.
| token | UUID of the gate. |
Definition at line 94 of file MMappedCircuit.cpp.

| void MMappedCircuit::setExtra | ( | pg_uuid_t | token, |
| const std::string & | s | ||
| ) |
Attach a variable-length string annotation to a gate.
| token | UUID of the gate. |
| s | String to store. |
Definition at line 113 of file MMappedCircuit.cpp.


| void MMappedCircuit::setInfos | ( | pg_uuid_t | token, |
| unsigned | info1, | ||
| unsigned | info2 | ||
| ) |
Update the info1 / info2 annotations of a gate.
| token | UUID of the gate to update. |
| info1 | New value for info1. |
| info2 | New value for info2. |
Definition at line 104 of file MMappedCircuit.cpp.

| bool MMappedCircuit::setProb | ( | pg_uuid_t | token, |
| double | prob | ||
| ) |
Set the probability associated with a gate.
| token | UUID of the gate. |
| prob | Probability value in [0, 1]. |
true if the gate was found and updated; false otherwise. Definition at line 83 of file MMappedCircuit.cpp.

| void MMappedCircuit::sync | ( | ) |
Flush all backing files to disk with msync().
Definition at line 331 of file MMappedCircuit.cpp.


|
private |
Variable-length string data.
Definition at line 78 of file MMappedCircuit.h.
|
staticconstexprprivate |
Backing file for extra.
Definition at line 83 of file MMappedCircuit.h.
|
private |
Gate metadata array.
Definition at line 76 of file MMappedCircuit.h.
|
staticconstexprprivate |
Backing file for gates.
Definition at line 80 of file MMappedCircuit.h.
|
private |
UUID → gate-index hash table.
Definition at line 75 of file MMappedCircuit.h.
|
staticconstexprprivate |
Backing file for mapping.
Definition at line 82 of file MMappedCircuit.h.
|
private |
Flattened child UUID array.
Definition at line 77 of file MMappedCircuit.h.
|
staticconstexprprivate |
Backing file for wires.
Definition at line 81 of file MMappedCircuit.h.