OmniSciDB  a987f07e93
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
anonymous_namespace{RelAlgExecutionDescriptor.cpp} Namespace Reference

Classes

struct  MatchBody
 

Functions

DAG build_dag (const RelAlgNode *sink, std::unordered_map< const RelAlgNode *, int > &node_ptr_to_vert_idx)
 
std::unordered_set< Vertexget_join_vertices (const std::vector< Vertex > &vertices, const DAG &graph)
 

Function Documentation

DAG anonymous_namespace{RelAlgExecutionDescriptor.cpp}::build_dag ( const RelAlgNode sink,
std::unordered_map< const RelAlgNode *, int > &  node_ptr_to_vert_idx 
)

Definition at line 135 of file RelAlgExecutionDescriptor.cpp.

References CHECK.

Referenced by RaExecutionSequence::RaExecutionSequence().

136  {
137  DAG graph(1);
138  graph[0] = sink;
139  node_ptr_to_vert_idx.emplace(std::make_pair(sink, 0));
140  std::vector<const RelAlgNode*> stack(1, sink);
141  while (!stack.empty()) {
142  const auto node = stack.back();
143  stack.pop_back();
144  if (dynamic_cast<const RelScan*>(node)) {
145  continue;
146  }
147 
148  const auto input_num = node->inputCount();
149  switch (input_num) {
150  case 0:
151  CHECK(dynamic_cast<const RelLogicalValues*>(node) ||
152  dynamic_cast<const RelTableFunction*>(node));
153  case 1:
154  break;
155  case 2:
156  CHECK(dynamic_cast<const RelJoin*>(node) ||
157  dynamic_cast<const RelLeftDeepInnerJoin*>(node) ||
158  dynamic_cast<const RelLogicalUnion*>(node) ||
159  dynamic_cast<const RelTableFunction*>(node));
160  break;
161  default:
162  CHECK(dynamic_cast<const RelLeftDeepInnerJoin*>(node) ||
163  dynamic_cast<const RelLogicalUnion*>(node) ||
164  dynamic_cast<const RelTableFunction*>(node));
165  }
166  for (size_t i = 0; i < input_num; ++i) {
167  const auto input = node->getInput(i);
168  CHECK(input);
169  const bool visited = node_ptr_to_vert_idx.count(input) > 0;
170  if (!visited) {
171  node_ptr_to_vert_idx.insert(std::make_pair(input, node_ptr_to_vert_idx.size()));
172  }
173  boost::add_edge(node_ptr_to_vert_idx[input], node_ptr_to_vert_idx[node], graph);
174  if (!visited) {
175  graph[node_ptr_to_vert_idx[input]] = input;
176  stack.push_back(input);
177  }
178  }
179  }
180  return graph;
181 }
#define CHECK(condition)
Definition: Logger.h:289
boost::adjacency_list< boost::setS, boost::vecS, boost::bidirectionalS, const RelAlgNode * > DAG

+ Here is the caller graph for this function:

std::unordered_set<Vertex> anonymous_namespace{RelAlgExecutionDescriptor.cpp}::get_join_vertices ( const std::vector< Vertex > &  vertices,
const DAG graph 
)

Definition at line 183 of file RelAlgExecutionDescriptor.cpp.

References CHECK.

Referenced by RaExecutionSequence::RaExecutionSequence().

184  {
185  std::unordered_set<Vertex> joins;
186  for (const auto vert : vertices) {
187  if (dynamic_cast<const RelLeftDeepInnerJoin*>(graph[vert])) {
188  joins.insert(vert);
189  continue;
190  }
191  if (!dynamic_cast<const RelJoin*>(graph[vert])) {
192  continue;
193  }
194  if (boost::out_degree(vert, graph) > 1) {
195  throw std::runtime_error("Join used more than once not supported yet");
196  }
197  auto [oe_iter, oe_end] = boost::out_edges(vert, graph);
198  CHECK(std::next(oe_iter) == oe_end);
199  const auto out_vert = boost::target(*oe_iter, graph);
200  if (!dynamic_cast<const RelJoin*>(graph[out_vert])) {
201  joins.insert(vert);
202  }
203  }
204  return joins;
205 }
#define CHECK(condition)
Definition: Logger.h:289

+ Here is the caller graph for this function: