ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
WhereCircuit Class Reference

Circuit encoding where-provenance (column-level data origin). More...

#include "WhereCircuit.h"

Inheritance diagram for WhereCircuit:
Collaboration diagram for WhereCircuit:

Classes

struct  Locator
 Describes the origin of a single attribute value. More...
 

Public Member Functions

gate_t setGate (const uuid &u, WhereGate type) override
 Create or update the gate associated with UUID u.
 
gate_t setGateInput (const uuid &u, std::string table, int nb_columns)
 Create an input gate for a specific table row.
 
gate_t setGateProjection (const uuid &u, std::vector< int > &&infos)
 Create a projection gate with column mapping.
 
gate_t setGateEquality (const uuid &u, int pos1, int pos2)
 Create an equality (equijoin) gate for two attribute positions.
 
std::string toString (gate_t g) const override
 Return a textual description of gate g for debugging.
 
std::vector< std::set< Locator > > evaluate (gate_t g) const
 Evaluate the where-provenance circuit at gate g.
 
- Public Member Functions inherited from Circuit< WhereGate >
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.
 
WhereGate 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, WhereGate type)
 Create or update the gate associated with UUID u.
 
virtual gate_t setGate (WhereGate 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::unordered_map< gate_t, uuidinput_token
 UUID of the source tuple for each IN gate.
 
std::unordered_map< gate_t, std::pair< std::string, int > > input_info
 (table name, nb_columns) for each IN gate
 
std::unordered_map< gate_t, std::vector< int > > projection_info
 Projected attribute positions for PROJECT gates.
 
std::unordered_map< gate_t, std::pair< int, int > > equality_info
 Joined attribute pair (pos1, pos2) for EQ gates.
 

Additional Inherited Members

- Public Types inherited from Circuit< WhereGate >
using uuid = std::string
 UUID type used in this circuit (always std::string).
 
- Protected Member Functions inherited from Circuit< WhereGate >
void setGateType (gate_t g, WhereGate t)
 Update the type of an existing gate.
 
virtual gate_t addGate ()
 Allocate a new gate with a default-initialised type.
 
- Protected Attributes inherited from Circuit< WhereGate >
std::unordered_map< uuid, gate_tuuid2id
 UUID string → gate index.
 
std::unordered_map< gate_t, uuidid2uuid
 Gate index → UUID string.
 
std::vector< WhereGategates
 Gate type for each gate.
 
std::vector< std::vector< gate_t > > wires
 Child wire lists for each gate.
 

Detailed Description

Circuit encoding where-provenance (column-level data origin).

Stores extra per-gate metadata that relates each gate to its position in the original query plan (table name, row UUID, column index).

Definition at line 53 of file WhereCircuit.h.

Member Function Documentation

◆ evaluate()

vector< set< WhereCircuit::Locator > > WhereCircuit::evaluate ( gate_t  g) const

Evaluate the where-provenance circuit at gate g.

Returns one set of Locator values per output column position. Each Locator in the set identifies a base-relation cell that contributed the value at that output position.

Parameters
gRoot gate to evaluate.
Returns
Vector (indexed by output column) of sets of Locator values.

Definition at line 102 of file WhereCircuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setGate()

gate_t WhereCircuit::setGate ( const uuid u,
WhereGate  type 
)
override

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.

Parameters
uUUID string to associate with the gate.
typeGate type.
Returns
Gate identifier.

Definition at line 30 of file WhereCircuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setGateEquality()

gate_t WhereCircuit::setGateEquality ( const uuid u,
int  pos1,
int  pos2 
)

Create an equality (equijoin) gate for two attribute positions.

Parameters
uUUID to associate with this gate.
pos1Left-side attribute position.
pos2Right-side attribute position.
Returns
Gate identifier.

Definition at line 42 of file WhereCircuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setGateInput()

gate_t WhereCircuit::setGateInput ( const uuid u,
std::string  table,
int  nb_columns 
)

Create an input gate for a specific table row.

Parameters
uUUID of the source tuple (row token).
tableName of the source relation.
nb_columnsNumber of columns in the source tuple.
Returns
Gate identifier.

Definition at line 49 of file WhereCircuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setGateProjection()

gate_t WhereCircuit::setGateProjection ( const uuid u,
std::vector< int > &&  infos 
)

Create a projection gate with column mapping.

Parameters
uUUID to associate with this gate.
infosList of attribute positions surviving the projection.
Returns
Gate identifier.

Definition at line 35 of file WhereCircuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toString()

string WhereCircuit::toString ( gate_t  g) const
overridevirtual

Return a textual description of gate g for debugging.

Pure virtual; each concrete circuit class provides its own formatting.

Parameters
gGate to describe.
Returns
Human-readable string.

Implements Circuit< WhereGate >.

Definition at line 57 of file WhereCircuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ equality_info

std::unordered_map<gate_t, std::pair<int,int> > WhereCircuit::equality_info
private

Joined attribute pair (pos1, pos2) for EQ gates.

Definition at line 58 of file WhereCircuit.h.

◆ input_info

std::unordered_map<gate_t, std::pair<std::string,int> > WhereCircuit::input_info
private

(table name, nb_columns) for each IN gate

Definition at line 56 of file WhereCircuit.h.

◆ input_token

std::unordered_map<gate_t, uuid> WhereCircuit::input_token
private

UUID of the source tuple for each IN gate.

Definition at line 55 of file WhereCircuit.h.

◆ projection_info

std::unordered_map<gate_t, std::vector<int> > WhereCircuit::projection_info
private

Projected attribute positions for PROJECT gates.

Definition at line 57 of file WhereCircuit.h.


The documentation for this class was generated from the following files: