94 else if(!result.empty())
99 return "("+result+
")";
104 vector<set<Locator>> v;
109 string table=
input_info.find(g)->second.first;
111 int nb_columns=
input_info.find(g)->second.second;
112 for(
int i=0;i<nb_columns;++i) {
114 s.insert(
Locator(table,tid,i+1));
128 vector<set<Locator>> w=
evaluate(g2);
129 v.insert(v.end(), w.begin(), w.end());
142 vector<set<Locator>> w=
evaluate(g2);
143 if(w.size()!=v.size())
146 for(
size_t k=0;k<v.size();++k) {
147 v[k].insert(w[k].begin(), w[k].end());
160 for(
auto i : positions) {
162 v.push_back(set<Locator>());
176 v[positions.first-1].insert(v[positions.second-1].begin(), v[positions.second-1].end());
177 v[positions.second-1].insert(v[positions.first-1].begin(), v[positions.first-1].end());
199 return table +
":" + tid +
":" +
to_string(position);
gate_t
Strongly-typed gate identifier.
std::string to_string(gate_t g)
Convert a gate_t to its decimal string representation.
Where-provenance circuit tracking column-level data origin.
WhereGate
Gate types for a where-provenance circuit.
@ PROJECT
Projection gate recording which attributes are kept.
@ EQ
Equijoin gate recording the joined attribute pair.
@ PLUS
Sum (disjunction) of child where-provenance sets.
@ TIMES
Product (conjunction) of child where-provenance sets.
@ IN
Input gate for a single base-relation tuple.
@ UNDETERMINED
Placeholder; should not appear in a complete circuit.
Exception type thrown by circuit operations on invalid input.
std::string uuid
UUID type used in this circuit (always std::string).
std::vector< gate_t > & getWires(gate_t g)
Return a mutable reference to the child-wire list of gate g.
WhereGate getGateType(gate_t g) const
Return the type of gate g.
virtual gate_t setGate(const uuid &u, gateType type)
Create or update the gate associated with UUID u.
std::unordered_map< gate_t, std::pair< int, int > > equality_info
Joined attribute pair (pos1, pos2) for EQ gates.
std::unordered_map< gate_t, uuid > input_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.
gate_t setGateInput(const uuid &u, std::string table, int nb_columns)
Create an input gate for a specific table row.
gate_t setGateEquality(const uuid &u, int pos1, int pos2)
Create an equality (equijoin) gate for two attribute positions.
gate_t setGate(const uuid &u, WhereGate type) override
Create or update the gate associated with UUID u.
std::string toString(gate_t g) const override
Return a textual description of gate g for debugging.
gate_t setGateProjection(const uuid &u, std::vector< int > &&infos)
Create a projection gate with column mapping.
std::vector< std::set< Locator > > evaluate(gate_t g) const
Evaluate the where-provenance circuit at gate g.
Core types, constants, and utilities shared across ProvSQL.
Describes the origin of a single attribute value.
std::string toString() const
Return a human-readable representation of this locator.
bool operator<(Locator that) const
Lexicographic ordering for use in std::set.
int position
Zero-based column index within the tuple.
std::string table
Name of the source relation.
uuid tid
UUID (row token) of the source tuple.