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

Functions

std::vector< Vertexmerge_sort_with_input (const std::vector< Vertex > &vertices, const DAG &graph)
 
DAG build_dag (const RelAlgNode *sink)
 
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)

Definition at line 163 of file RelAlgExecutionDescriptor.cpp.

References CHECK, and i.

Referenced by RaExecutionSequence::RaExecutionSequence().

163  {
164  DAG graph(1);
165  graph[0] = sink;
166  std::unordered_map<const RelAlgNode*, int> node_ptr_to_vert_idx{
167  std::make_pair(sink, 0)};
168  std::vector<const RelAlgNode*> stack(1, sink);
169  while (!stack.empty()) {
170  const auto node = stack.back();
171  stack.pop_back();
172  if (dynamic_cast<const RelScan*>(node)) {
173  continue;
174  }
175 
176  const auto input_num = node->inputCount();
177  switch (input_num) {
178  case 0:
179  CHECK(dynamic_cast<const RelLogicalValues*>(node));
180  case 1:
181  break;
182  case 2:
183  CHECK(dynamic_cast<const RelJoin*>(node) ||
184  dynamic_cast<const RelLeftDeepInnerJoin*>(node) ||
185  dynamic_cast<const RelLogicalUnion*>(node) ||
186  dynamic_cast<const RelTableFunction*>(node));
187  break;
188  default:
189  CHECK(dynamic_cast<const RelLeftDeepInnerJoin*>(node) ||
190  dynamic_cast<const RelLogicalUnion*>(node) ||
191  dynamic_cast<const RelTableFunction*>(node));
192  }
193  for (size_t i = 0; i < input_num; ++i) {
194  const auto input = node->getInput(i);
195  CHECK(input);
196  const bool visited = node_ptr_to_vert_idx.count(input) > 0;
197  if (!visited) {
198  node_ptr_to_vert_idx.insert(std::make_pair(input, node_ptr_to_vert_idx.size()));
199  }
200  boost::add_edge(node_ptr_to_vert_idx[input], node_ptr_to_vert_idx[node], graph);
201  if (!visited) {
202  graph[node_ptr_to_vert_idx[input]] = input;
203  stack.push_back(input);
204  }
205  }
206  }
207  return graph;
208 }
#define CHECK(condition)
Definition: Logger.h:197
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 210 of file RelAlgExecutionDescriptor.cpp.

References CHECK.

Referenced by RaExecutionSequence::RaExecutionSequence().

211  {
212  std::unordered_set<Vertex> joins;
213  for (const auto vert : vertices) {
214  if (dynamic_cast<const RelLeftDeepInnerJoin*>(graph[vert])) {
215  joins.insert(vert);
216  continue;
217  }
218  if (!dynamic_cast<const RelJoin*>(graph[vert])) {
219  continue;
220  }
221  if (boost::out_degree(vert, graph) > 1) {
222  throw std::runtime_error("Join used more than once not supported yet");
223  }
224  auto [oe_iter, oe_end] = boost::out_edges(vert, graph);
225  CHECK(std::next(oe_iter) == oe_end);
226  const auto out_vert = boost::target(*oe_iter, graph);
227  if (!dynamic_cast<const RelJoin*>(graph[out_vert])) {
228  joins.insert(vert);
229  }
230  }
231  return joins;
232 }
#define CHECK(condition)
Definition: Logger.h:197

+ Here is the caller graph for this function:

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

Definition at line 133 of file RelAlgExecutionDescriptor.cpp.

References CHECK, and gpu_enabled::sort().

Referenced by RaExecutionSequence::RaExecutionSequence().

134  {
135  DAG::in_edge_iterator ie_iter, ie_end;
136  std::unordered_set<Vertex> inputs;
137  for (const auto vert : vertices) {
138  if (const auto sort = dynamic_cast<const RelSort*>(graph[vert])) {
139  boost::tie(ie_iter, ie_end) = boost::in_edges(vert, graph);
140  CHECK(size_t(1) == sort->inputCount() && boost::next(ie_iter) == ie_end);
141  const auto in_vert = boost::source(*ie_iter, graph);
142  const auto input = graph[in_vert];
143  if (dynamic_cast<const RelScan*>(input)) {
144  throw std::runtime_error("Standalone sort not supported yet");
145  }
146  if (boost::out_degree(in_vert, graph) > 1) {
147  throw std::runtime_error("Sort's input node used by others not supported yet");
148  }
149  inputs.insert(in_vert);
150  }
151  }
152 
153  std::vector<Vertex> new_vertices;
154  for (const auto vert : vertices) {
155  if (inputs.count(vert)) {
156  continue;
157  }
158  new_vertices.push_back(vert);
159  }
160  return new_vertices;
161 }
DEVICE void sort(ARGS &&...args)
Definition: gpu_enabled.h:105
#define CHECK(condition)
Definition: Logger.h:197

+ Here is the call graph for this function:

+ Here is the caller graph for this function: