100 else if(!result.empty())
117 return "("+result+
")";
122 vector<set<Locator> > v;
127 string table=
input_info.find(g)->second.first;
129 int nb_columns=
input_info.find(g)->second.second;
130 for(
int i=0; i<nb_columns; ++i) {
132 s.insert(
Locator(table,tid,i+1));
146 vector<set<Locator> > w=
evaluate(g2);
147 v.insert(v.end(), w.begin(), w.end());
160 vector<set<Locator> > w=
evaluate(g2);
161 if(w.size()!=v.size())
164 for(
size_t k=0; k<v.size(); ++k) {
165 v[k].insert(w[k].begin(), w[k].end());
178 for(
auto i : positions) {
179 if(i==0 || i>(
int)w.size())
180 v.push_back(set<Locator>());
194 if(positions.first>=1 && positions.first<=(
int)v.size() &&
195 positions.second>=1 && positions.second<=(
int)v.size()) {
196 v[positions.first-1].insert(v[positions.second-1].begin(), v[positions.second-1].end());
197 v[positions.second-1].insert(v[positions.first-1].begin(), v[positions.first-1].end());
214 return this->
tid < that.
tid;
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::vector< gate_t > & getWires(gate_t g)
WhereGate getGateType(gate_t g) const
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.
std::string toStringHelper(gate_t g, WhereGate parent) const
Recursive helper for toString that propagates the parent gate type for parenthesis elision.
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.