36#ifndef MMAPPED_CIRCUIT_H
37#define MMAPPED_CIRCUIT_H
105static std::string
makePath(Oid db_oid,
const char *filename);
109 const std::string &wp,
const std::string &ep,
110 const std::string &tp,
121 uint64_t(
'P') | uint64_t(
'v') << 8 | uint64_t(
'S') << 16 | uint64_t(
'G') << 24 |
122 uint64_t(
'a') << 32 | uint64_t(
't') << 40 | uint64_t(
'e') << 48 | uint64_t(
's') << 56;
124 uint64_t(
'P') | uint64_t(
'v') << 8 | uint64_t(
'S') << 16 | uint64_t(
'W') << 24 |
125 uint64_t(
'i') << 32 | uint64_t(
'r') << 40 | uint64_t(
'e') << 48 | uint64_t(
's') << 56;
127 uint64_t(
'P') | uint64_t(
'v') << 8 | uint64_t(
'S') << 16 | uint64_t(
'M') << 24 |
128 uint64_t(
'a') << 32 | uint64_t(
'p') << 40 | uint64_t(
'n') << 48 | uint64_t(
'g') << 56;
130 uint64_t(
'P') | uint64_t(
'v') << 8 | uint64_t(
'S') << 16 | uint64_t(
'E') << 24 |
131 uint64_t(
'x') << 32 | uint64_t(
't') << 40 | uint64_t(
'r') << 48 | uint64_t(
'a') << 56;
133 uint64_t(
'P') | uint64_t(
'v') << 8 | uint64_t(
'S') << 16 | uint64_t(
'T') << 24 |
134 uint64_t(
'b') << 32 | uint64_t(
'l') << 40 | uint64_t(
'I') << 48 | uint64_t(
'n') << 56;
230 return gates.nbElements();
266 const Oid *ancestors);
329 const std::vector<pg_uuid_t> &roots)
const;
Semiring-agnostic in-memory provenance circuit.
Per-table provenance metadata persisted alongside the circuit store.
Open-addressing hash table mapping UUIDs to integers, backed by an mmap file.
Template implementation of MMappedVector<T>.
In-memory provenance circuit with semiring-generic evaluation.
void setTableAncestry(Oid relid, uint16_t ancestor_n, const Oid *ancestors)
Insert or update the ancestor set of a per-table metadata record, preserving any existing kind / bloc...
void setExtra(pg_uuid_t token, const std::string &s)
Attach a variable-length string annotation to a gate.
static constexpr uint64_t MAGIC_TABLE_INFO
void setTableInfo(const ProvenanceTableInfo &info)
Insert or update the kind / block_key half of a per-table metadata record, preserving any existing an...
void removeTableInfo(Oid relid)
Remove a per-table metadata entry (both halves).
MMappedUUIDHashTable mapping
UUID → gate-index hash table.
void createGate(pg_uuid_t token, gate_type type, const std::vector< pg_uuid_t > &children)
Persist a new gate to the mmap store.
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.
static constexpr const char * GATES_FILENAME
Backing file for gates.
gate_type getGateType(pg_uuid_t token) const
Return the type of the gate identified by token.
static constexpr const char * TABLE_INFO_FILENAME
Backing file for tableInfo.
void removeTableAncestry(Oid relid)
Clear just the ancestor set of a per-table metadata record, preserving kind / block_key.
void sync()
Flush all backing files to disk with msync().
MMappedVector< ProvenanceTableInfo > tableInfo
Per-relation TID/BID metadata (safe-query optimisation).
static constexpr const char * WIRES_FILENAME
Backing file for wires.
GenericCircuit createGenericCircuit(pg_uuid_t token) const
Build an in-memory GenericCircuit rooted at token.
static std::string makePath(Oid db_oid, const char *filename)
Build the full path for a mmap file under $PGDATA/base/<db_oid>/.
bool setProb(pg_uuid_t token, double prob)
Set the probability associated with a gate.
static constexpr const char * EXTRA_FILENAME
Backing file for extra.
static constexpr uint64_t MAGIC_WIRES
static constexpr uint64_t MAGIC_GATES
8-byte magic constants identifying each mmap file type.
static constexpr const char * MAPPING_FILENAME
Backing file for mapping.
bool getTableInfo(Oid relid, ProvenanceTableInfo &out) const
Look up the full per-table metadata record (both halves).
MMappedVector< char > extra
Variable-length string data.
static constexpr uint64_t MAGIC_EXTRA
double getProb(pg_uuid_t token) const
Return the probability stored for 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.
MMappedVector< GateInformation > gates
Gate metadata array.
~MMappedCircuit()
Sync all backing files before destruction.
MMappedVector< pg_uuid_t > wires
Flattened child UUID array.
void setInfos(pg_uuid_t token, unsigned info1, unsigned info2)
Update the info1 / info2 annotations of a gate.
MMappedCircuit(const std::string &mp, const std::string &gp, const std::string &wp, const std::string &ep, const std::string &tp, bool read_only)
Delegating constructor that accepts pre-built paths.
static constexpr uint64_t MAGIC_MAPPING
std::pair< unsigned, unsigned > getInfos(pg_uuid_t token) const
Return the info1 / info2 pair for the gate token.
Persistent open-addressing hash table mapping UUIDs to integers.
Append-only, mmap-backed vector of elements of type T.
Core types, constants, and utilities shared across ProvSQL.
Per-relation metadata for the safe-query optimisation.