![]() |
ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
|
In-memory provenance circuit with semiring-generic evaluation. More...
#include "GenericCircuit.h"


Public Member Functions | |
| virtual std::string | toString (gate_t g) const override |
| Return a placeholder debug string (not intended for display). | |
| void | setInfos (gate_t g, unsigned info1, unsigned info2) |
Set the integer annotation pair for gate g. | |
| std::pair< unsigned, unsigned > | getInfos (gate_t g) const |
Return the integer annotation pair for gate g. | |
| void | setExtra (gate_t g, const std::string &ex) |
Attach a string extra to gate g. | |
| std::string | getExtra (gate_t g) const |
Return the string extra for gate g. | |
| gate_t | addGate () override |
| Allocate a new gate with a default-initialised type. | |
| gate_t | setGate (gate_type type) override |
Allocate a new gate with type type and no UUID. | |
| gate_t | setGate (const uuid &u, gate_type type) override |
Create or update the gate associated with UUID u. | |
| const std::set< gate_t > & | getInputs () const |
| Return the set of input (leaf) gates. | |
| void | setProb (gate_t g, double p) |
Set the probability for gate g. | |
| double | getProb (gate_t g) const |
Return the probability for gate g. | |
| template<class Archive > | |
| void | serialize (Archive &ar, const unsigned int version) |
| Boost serialisation support. | |
| template<typename S , std::enable_if_t< std::is_base_of_v< semiring::Semiring< typename S::value_type >, S >, int > = 0> | |
| S::value_type | evaluate (gate_t g, std::unordered_map< gate_t, typename S::value_type > &provenance_mapping, S semiring) const |
Evaluate the sub-circuit rooted at gate g over semiring semiring. | |
Public Member Functions inherited from Circuit< gate_type > | |
| virtual | ~Circuit () |
| std::vector< gate_t >::size_type | getNbGates () const |
| Return the total number of gates in the circuit. | |
| gate_t | getGate (const uuid &u) |
Return (or create) the gate associated with UUID u. | |
| uuid | getUUID (gate_t g) const |
Return the UUID string associated with gate g. | |
| gate_type | getGateType (gate_t g) const |
Return the type of gate g. | |
| std::vector< gate_t > & | getWires (gate_t g) |
Return a mutable reference to the child-wire list of gate g. | |
| const std::vector< gate_t > & | getWires (gate_t g) const |
Return a const reference to the child-wire list of gate g. | |
| virtual gate_t | setGate (const uuid &u, gate_type type) |
Create or update the gate associated with UUID u. | |
| virtual gate_t | setGate (gate_type type) |
Allocate a new gate with type type and no UUID. | |
| bool | hasGate (const uuid &u) const |
Test whether a gate with UUID u exists. | |
| void | addWire (gate_t f, gate_t t) |
Add a directed wire from gate f (parent) to gate t (child). | |
Private Attributes | |
| std::map< gate_t, std::pair< unsigned, unsigned > > | infos |
| Per-gate (info1, info2) annotations. | |
| std::map< gate_t, std::string > | extra |
| Per-gate string extras. | |
| std::set< gate_t > | inputs |
| Set of input (leaf) gate IDs. | |
| std::vector< double > | prob |
| Per-gate probability values. | |
Friends | |
| class | dDNNFTreeDecompositionBuilder |
| class | boost::serialization::access |
Additional Inherited Members | |
Public Types inherited from Circuit< gate_type > | |
| using | uuid = std::string |
UUID type used in this circuit (always std::string). | |
Protected Member Functions inherited from Circuit< gate_type > | |
| void | setGateType (gate_t g, gate_type t) |
| Update the type of an existing gate. | |
Protected Attributes inherited from Circuit< gate_type > | |
| std::unordered_map< uuid, gate_t > | uuid2id |
| UUID string → gate index. | |
| std::unordered_map< gate_t, uuid > | id2uuid |
| Gate index → UUID string. | |
| std::vector< gate_type > | gates |
| Gate type for each gate. | |
| std::vector< std::vector< gate_t > > | wires |
| Child wire lists for each gate. | |
In-memory provenance circuit with semiring-generic evaluation.
Gate types are the PostgreSQL gate_type values. The circuit is constructed from the persistent mmap store and then evaluated in-memory.
Definition at line 48 of file GenericCircuit.h.
|
overridevirtual |
Allocate a new gate with a default-initialised type.
Derived classes override this to perform additional initialisation (e.g. resizing auxiliary vectors).
gate_t identifier of the newly created gate. Reimplemented from Circuit< gate_type >.
Definition at line 34 of file GenericCircuit.cpp.

| S::value_type GenericCircuit::evaluate | ( | gate_t | g, |
| std::unordered_map< gate_t, typename S::value_type > & | provenance_mapping, | ||
| S | semiring | ||
| ) | const |
Evaluate the sub-circuit rooted at gate g over semiring semiring.
Performs a post-order traversal from g, mapping each input gate to its semiring value via provenance_mapping, and combining the results using the semiring operations.
| S | A concrete semiring::Semiring subclass. |
| g | Root gate of the sub-circuit to evaluate. |
| provenance_mapping | Map from input gate IDs to semiring values. |
| semiring | Semiring instance providing zero(), one(), plus(), times(), etc. |
g. Definition at line 35 of file GenericCircuit.hpp.


|
inline |
Return the string extra for gate g.
| g | Gate identifier. |
Definition at line 105 of file GenericCircuit.h.

|
inline |
Return the integer annotation pair for gate g.
| g | Gate identifier. |
{info1, info2}, or {-1,-1} if not set. Definition at line 82 of file GenericCircuit.h.

|
inline |
Return the set of input (leaf) gates.
Definition at line 125 of file GenericCircuit.h.

|
inline |
Return the probability for gate g.
| g | Gate identifier. |
Definition at line 143 of file GenericCircuit.h.

|
inline |
Boost serialisation support.
| ar | Boost archive (input or output). |
| version | Archive version (unused). |
Definition at line 153 of file GenericCircuit.h.
|
inline |
Attach a string extra to gate g.
| g | Gate identifier. |
| ex | String to store. |
Definition at line 95 of file GenericCircuit.h.

Create or update the gate associated with UUID u.
If the UUID is already mapped the existing gate's type is updated. Otherwise a new gate is allocated.
| u | UUID string to associate with the gate. |
| type | Gate type. |
Definition at line 25 of file GenericCircuit.cpp.

Allocate a new gate with type type and no UUID.
| type | Gate type. |
Definition at line 16 of file GenericCircuit.cpp.


|
inline |
Set the integer annotation pair for gate g.
| g | Gate identifier. |
| info1 | First annotation integer. |
| info2 | Second annotation integer. |
Definition at line 72 of file GenericCircuit.h.

|
inline |
Set the probability for gate g.
| g | Gate identifier. |
| p | Probability in [0, 1]. |
Definition at line 134 of file GenericCircuit.h.

|
inlineoverridevirtual |
Return a placeholder debug string (not intended for display).
| g | Gate identifier (unused). |
"<GenericCircuit>". Implements Circuit< gate_type >.
Definition at line 62 of file GenericCircuit.h.
|
friend |
Definition at line 166 of file GenericCircuit.h.
|
friend |
Definition at line 165 of file GenericCircuit.h.
|
private |
Per-gate string extras.
Definition at line 52 of file GenericCircuit.h.
|
private |
Per-gate (info1, info2) annotations.
Definition at line 51 of file GenericCircuit.h.
|
private |
Set of input (leaf) gate IDs.
Definition at line 53 of file GenericCircuit.h.
|
private |
Per-gate probability values.
Definition at line 54 of file GenericCircuit.h.