![]() |
ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
|
Build in-memory circuits from the mmap-backed store. More...
#include <cmath>#include <boost/archive/binary_iarchive.hpp>#include <boost/iostreams/device/array.hpp>#include <boost/iostreams/stream.hpp>#include "CircuitFromMMap.h"#include "HybridEvaluator.h"#include "RangeCheck.h"#include "having_semantics.hpp"#include "semiring/BoolExpr.h"#include "provsql_utils_cpp.h"#include <vector>#include "miscadmin.h"#include "provsql_shmem.h"#include "provsql_mmap.h"#include "provsql_utils.h"
Go to the source code of this file.
Functions | |
| template<typename C> | |
| static C | getCircuitFromMMap (pg_uuid_t token, char message_char) |
Read and deserialise a circuit rooted at token from the mmap worker. | |
| BooleanCircuit | getBooleanCircuit (GenericCircuit &gc, pg_uuid_t token, gate_t &gate, std::unordered_map< gate_t, gate_t > &gc_to_bc) |
Build a BooleanCircuit from an already-loaded GenericCircuit. | |
| BooleanCircuit | getBooleanCircuit (pg_uuid_t token, gate_t &gate) |
Build a BooleanCircuit from the mmap store rooted at token. | |
| static void | applyLoadTimeSimplification (GenericCircuit &gc) |
Apply the universal load-time simplification passes to gc. | |
| GenericCircuit | getGenericCircuit (pg_uuid_t token) |
Build a GenericCircuit from the mmap store rooted at token. | |
| static GenericCircuit | getJointCircuitFromMMap (pg_uuid_t root_token, pg_uuid_t event_token) |
IPC: ship a 'j' (joint) request to the mmap worker and deserialise the returned GenericCircuit. | |
| GenericCircuit | getJointCircuit (pg_uuid_t root_token, pg_uuid_t event_token, gate_t &root_gate, gate_t &event_gate) |
Build a GenericCircuit containing the closures of two roots, with shared subgraphs unified. | |
Build in-memory circuits from the mmap-backed store.
Implements the free functions declared in CircuitFromMMap.h:
getBooleanCircuit(): reads the mmap store (via the background worker IPC channel) and constructs a BooleanCircuit.getGenericCircuit(): same but constructs a GenericCircuit.The internal getCircuitFromMMap<C>() template handles the IPC protocol: it sends a request through the shared-memory pipe, receives a Boost-serialised circuit blob from the background worker, and deserialises it into the appropriate circuit type.
Definition in file CircuitFromMMap.cpp.
|
static |
Apply the universal load-time simplification passes to gc.
Extracted from getGenericCircuit so the joint-circuit loader (getJointCircuit) runs the same passes on its multi-root output. Gated by the provsql.simplify_on_load GUC, identical semantics.
Definition at line 126 of file CircuitFromMMap.cpp.


| BooleanCircuit getBooleanCircuit | ( | GenericCircuit & | gc, |
| pg_uuid_t | token, | ||
| gate_t & | gate, | ||
| std::unordered_map< gate_t, gate_t > & | gc_to_bc ) |
Build a BooleanCircuit from an already-loaded GenericCircuit.
Variant of getBooleanCircuit() that reuses an existing GenericCircuit (typically obtained via getGenericCircuit()) and additionally exposes the GenericCircuit-to- mapping, so that callers can translate input-side annotations (e.g., user-supplied leaf labels) from BooleanCircuit gategc to the constructed BooleanCircuit.
| gc | Source generic circuit (mutated through HAVING evaluation). |
| token | UUID of the root gate. |
| gate | Output: gate_t of the root within the returned circuit. |
| gc_to_bc | Output: mapping from gc input/mulinput gates to the corresponding gates in the returned BooleanCircuit. |
BooleanCircuit. Definition at line 84 of file CircuitFromMMap.cpp.


| BooleanCircuit getBooleanCircuit | ( | pg_uuid_t | token, |
| gate_t & | gate ) |
Build a BooleanCircuit from the mmap store rooted at token.
Performs a depth-first traversal of the persistent circuit starting at token, translating each gate_type to the corresponding BooleanGate and copying probabilities and info integers.
On return, gate is set to the gate_t identifier within the returned circuit that corresponds to token.
| token | UUID of the root gate. |
| gate | Output: gate_t of the root within the returned circuit. |
BooleanCircuit. Definition at line 112 of file CircuitFromMMap.cpp.

|
static |
Read and deserialise a circuit rooted at token from the mmap worker.
| C | Circuit type to deserialise (BooleanCircuit or GenericCircuit). |
| token | UUID of the root gate to retrieve. |
| message_char | IPC message-type byte sent to the background worker. |
C. Definition at line 45 of file CircuitFromMMap.cpp.


| GenericCircuit getGenericCircuit | ( | pg_uuid_t | token | ) |
Build a GenericCircuit from the mmap store rooted at token.
Equivalent to createGenericCircuit() declared in MMappedCircuit.h. Performs a depth-first traversal and copies all gate metadata (type, info1/info2, extra strings, probabilities) into the returned GenericCircuit.
| token | UUID of the root gate. |
GenericCircuit. Definition at line 155 of file CircuitFromMMap.cpp.


| GenericCircuit getJointCircuit | ( | pg_uuid_t | root_token, |
| pg_uuid_t | event_token, | ||
| gate_t & | root_gate, | ||
| gate_t & | event_gate ) |
Build a GenericCircuit containing the closures of two roots, with shared subgraphs unified.
Loads the union of every gate reachable from root_token and every gate reachable from event_token in a single in-memory GenericCircuit. Because GenericCircuit's UUID-to-gate mapping is idempotent, a gate_rv (or any other gate) reachable from both roots gets exactly one gate_t – the property the conditional MC sampler needs to couple the indicator's draw with the value's draw through Sampler's per-iteration cache.
The on-load simplification passes that getGenericCircuit runs (runRangeCheck and foldSemiringIdentities, gated by provsql.simplify_on_load) are applied to the joint circuit too. Both passes are in-place: gate types may change, but UUID-to-gate_t mappings stay valid, so callers can resolve their two roots via getGate after the call returns.
Output parameters root_gate and event_gate are the resolved gate_t for the two input UUIDs.
| root_token | First root UUID (e.g. an RV's gate). |
| event_token | Second root UUID (e.g. the conditioning gate). |
| root_gate | Output: gate_t for root_token in the returned circuit. |
| event_gate | Output: gate_t for event_token in the returned circuit. |
GenericCircuit. Definition at line 229 of file CircuitFromMMap.cpp.


|
static |
IPC: ship a 'j' (joint) request to the mmap worker and deserialise the returned GenericCircuit.
Mirrors getCircuitFromMMap but writes the multi-root payload the worker's 'j' handler expects: 'j' Oid nb_roots {pg_uuid_t}*. The response shape is identical to 'g' – unsigned long size prefix followed by a Boost-serialised GenericCircuit.
Definition at line 185 of file CircuitFromMMap.cpp.

