Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Matts966 committed Jan 19, 2022
1 parent 4b82e3b commit 584b5c3
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions alphasql/alphacheck.cc
Original file line number Diff line number Diff line change
Expand Up @@ -348,15 +348,19 @@ struct cycle_detector : public boost::dfs_visitor<> {
bool &_has_cycle;
};

struct DotVertex {
std::string name;
std::string type;
};

bool GetExecutionPlan(const std::string dot_path,
std::vector<std::string> &execution_plan) {
using namespace boost;
typedef adjacency_list<vecS, vecS, directedS,
property<vertex_name_t, std::string>>
Graph;
typedef adjacency_list<vecS, vecS, directedS, DotVertex> Graph;
Graph g;
dynamic_properties dp(ignore_other_properties);
dp.property("label", get(vertex_name, g));
dp.property("label", get(&DotVertex::name, g));
dp.property("type", get(&DotVertex::type, g));
std::filesystem::path file_path(dot_path);
std::ifstream file(file_path, std::ios::in);
if (!boost::read_graphviz(file, g, dp)) {
Expand All @@ -374,9 +378,12 @@ bool GetExecutionPlan(const std::string dot_path,

std::list<int> result;
topological_sort(g, std::front_inserter(result));
property_map<Graph, vertex_name_t>::type names = get(vertex_name, g);
property_map<Graph, std::string DotVertex::*>::type names = get(&DotVertex::name, g);
property_map<Graph, std::string DotVertex::*>::type types = get(&DotVertex::type, g);
for (int i : result) {
execution_plan.push_back(names[i]);
if (types[i] == "query") {
execution_plan.push_back(names[i]);
}
}
return true;
}
Expand Down

0 comments on commit 584b5c3

Please sign in to comment.