17#include <boost/archive/binary_iarchive.hpp>
18#include <boost/iostreams/device/array.hpp>
19#include <boost/iostreams/stream.hpp>
43 provsql_error(
"Cannot write to pipe (message type %c)", message_char);
46 if(!
READB(size,
unsigned long))
47 provsql_error(
"Cannot read from pipe (message type %c)", message_char);
49 char *buf =
new char[size], *p = buf;
50 ssize_t actual_read, remaining_size=size;
55 provsql_error(
"Cannot read from pipe (message type %c)", message_char);
57 remaining_size-=actual_read;
63 boost::iostreams::stream<boost::iostreams::array_source> stream(buf, size);
64 boost::archive::binary_iarchive ia(stream);
78 std::unordered_map<gate_t, gate_t> mapping;
83 auto u=
static_cast<gate_t>(i);
101 return getCircuitFromMMap<GenericCircuit>(token,
'g');
Boolean-expression (lineage formula) semiring.
@ IN
Input (variable) gate representing a base tuple.
@ MULIN
Multivalued-input gate (one of several options)
BooleanCircuit getBooleanCircuit(pg_uuid_t token, gate_t &gate)
Build a BooleanCircuit from the mmap store rooted at token.
static C getCircuitFromMMap(pg_uuid_t token, char message_char)
Read and deserialise a circuit rooted at token from the mmap worker.
GenericCircuit getGenericCircuit(pg_uuid_t token)
Build a GenericCircuit from the mmap store rooted at token.
Build in-memory circuits from the mmap-backed persistent store.
gate_t
Strongly-typed gate identifier.
Boolean circuit for provenance formula evaluation.
gate_t setGate(BooleanGate type) override
Allocate a new gate with type type and no UUID.
void setInfo(gate_t g, unsigned info)
Store an integer annotation on gate g.
std::vector< gate_t > & getWires(gate_t g)
Return a mutable reference to the child-wire list of gate g.
gateType getGateType(gate_t g) const
Return the type of gate g.
void addWire(gate_t f, gate_t t)
Add a directed wire from gate f (parent) to gate t (child).
uuid getUUID(gate_t g) const
Return the UUID string associated with gate g.
gate_t getGate(const uuid &u)
Return (or create) the gate associated with UUID u.
std::vector< gate_t >::size_type getNbGates() const
Return the total number of gates in the circuit.
In-memory provenance circuit with semiring-generic evaluation.
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.
double getProb(gate_t g) const
Return the probability for gate g.
const std::set< gate_t > & getInputs() const
Return the set of input (leaf) gates.
std::pair< unsigned, unsigned > getInfos(gate_t g) const
Return the integer annotation pair for gate g.
Provenance-as-Boolean-circuit semiring.
void provsql_try_having_boolexpr(GenericCircuit &c, semiring::BoolExpr &be, gate_t g, std::unordered_map< gate_t, gate_t > &mapping)
Evaluate the HAVING sub-circuit at g over the BoolExpr semiring.
Provenance evaluation helpers for HAVING-clause circuits.
#define provsql_error(fmt,...)
Report a fatal ProvSQL error and abort the current transaction.
Background worker and IPC primitives for mmap-backed circuit storage.
#define WRITEM(pvar, type)
Write one value of type to the background-to-main pipe.
#define READB(var, type)
Read one value of type from the main-to-background pipe.
void provsql_shmem_unlock(void)
Release the ProvSQL LWLock.
void provsql_shmem_lock_exclusive(void)
Acquire the ProvSQL LWLock in exclusive mode.
provsqlSharedState * provsql_shared_state
Pointer to the ProvSQL shared-memory segment (set in provsql_shmem_startup).
Shared-memory segment and inter-process pipe management.
@ gate_mulinput
Multivalued input (for Boolean provenance)
string uuid2string(pg_uuid_t uuid)
Format a pg_uuid_t as a std::string.
C++ utility functions for UUID manipulation.
long pipembr
Main-to-background pipe: read end (worker reads)