OmniSciDB  471d68cefb
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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  dynamic_cast<const RelTableFunction*>(node));
181  case 1:
182  break;
183  case 2:
184  CHECK(dynamic_cast<const RelJoin*>(node) ||
185  dynamic_cast<const RelLeftDeepInnerJoin*>(node) ||
186  dynamic_cast<const RelLogicalUnion*>(node) ||
187  dynamic_cast<const RelTableFunction*>(node));
188  break;
189  default:
190  CHECK(dynamic_cast<const RelLeftDeepInnerJoin*>(node) ||
191  dynamic_cast<const RelLogicalUnion*>(node) ||
192  dynamic_cast<const RelTableFunction*>(node));
193  }
194  for (size_t i = 0; i < input_num; ++i) {
195  const auto input = node->getInput(i);
196  CHECK(input);
197  const bool visited = node_ptr_to_vert_idx.count(input) > 0;
198  if (!visited) {
199  node_ptr_to_vert_idx.insert(std::make_pair(input, node_ptr_to_vert_idx.size()));
200  }
201  boost::add_edge(node_ptr_to_vert_idx[input], node_ptr_to_vert_idx[node], graph);
202  if (!visited) {
203  graph[node_ptr_to_vert_idx[input]] = input;
204  stack.push_back(input);
205  }
206  }
207  }
208  return graph;
209 }
#define CHECK(condition)
Definition: Logger.h:209
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 211 of file RelAlgExecutionDescriptor.cpp.

References CHECK.

Referenced by RaExecutionSequence::RaExecutionSequence().

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

+ 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:209

+ Here is the call graph for this function:

+ Here is the caller graph for this function: