OmniSciDB  d2f719934e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RelRexDagVisitor Class Reference

#include <RelRexDagVisitor.h>

+ Inheritance diagram for RelRexDagVisitor:

Public Member Functions

virtual ~RelRexDagVisitor ()=default
 
void visit (RelAlgNode const *)
 
virtual void visit (RexScalar const *)
 

Protected Member Functions

virtual void visit (RelAggregate const *)
 
virtual void visit (RelCompound const *)
 
virtual void visit (RelFilter const *)
 
virtual void visit (RelJoin const *)
 
virtual void visit (RelLeftDeepInnerJoin const *)
 
virtual void visit (RelLogicalUnion const *)
 
virtual void visit (RelLogicalValues const *)
 
virtual void visit (RelModify const *)
 
virtual void visit (RelProject const *)
 
virtual void visit (RelScan const *)
 
virtual void visit (RelSort const *)
 
virtual void visit (RelTableFunction const *)
 
virtual void visit (RelTranslatedJoin const *)
 
virtual void visit (RexAbstractInput const *)
 
virtual void visit (RexCase const *)
 
virtual void visit (RexFunctionOperator const *)
 
virtual void visit (RexInput const *)
 
virtual void visit (RexLiteral const *)
 
virtual void visit (RexOperator const *)
 
virtual void visit (RexRef const *)
 
virtual void visit (RexSubQuery const *)
 
virtual void visit (RexWindowFunctionOperator const *)
 

Private Types

template<typename T , size_t N>
using Handlers = std::array< TypeHandler< RelRexDagVisitor, T >, N >
 

Private Member Functions

template<typename T , typename U >
void cast (T const *node)
 

Static Private Member Functions

template<typename T , typename... Ts>
static Handlers< T, sizeof...(Ts)> make_handlers ()
 

Detailed Description

Definition at line 34 of file RelRexDagVisitor.h.

Member Typedef Documentation

template<typename T , size_t N>
using RelRexDagVisitor::Handlers = std::array<TypeHandler<RelRexDagVisitor, T>, N>
private

Definition at line 72 of file RelRexDagVisitor.h.

Constructor & Destructor Documentation

virtual RelRexDagVisitor::~RelRexDagVisitor ( )
virtualdefault

Member Function Documentation

template<typename T , typename U >
void RelRexDagVisitor::cast ( T const node)
inlineprivate

Definition at line 67 of file RelRexDagVisitor.h.

References visit().

67  {
68  visit(dynamic_cast<U const*>(node));
69  }
void visit(RelAlgNode const *)

+ Here is the call graph for this function:

template<typename T , typename... Ts>
RelRexDagVisitor::Handlers< T, sizeof...(Ts)> RelRexDagVisitor::make_handlers ( )
staticprivate

Definition at line 32 of file RelRexDagVisitor.cpp.

References gpu_enabled::sort(), and omnisci.dtypes::T.

Referenced by visit().

32  {
33  RelRexDagVisitor::Handlers<T, sizeof...(Ts)> handlers{
34  {{std::type_index(typeid(Ts)), &RelRexDagVisitor::cast<T, Ts>}...}};
35  std::sort(handlers.begin(), handlers.end());
36  return handlers;
37 }
DEVICE void sort(ARGS &&...args)
Definition: gpu_enabled.h:105
std::array< TypeHandler< RelRexDagVisitor, T >, N > Handlers

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void RelRexDagVisitor::visit ( RelAlgNode const rel_alg_node)

Definition at line 41 of file RelRexDagVisitor.cpp.

References logger::FATAL, RelAlgNode::getInput(), i, RelAlgNode::inputCount(), LOG, gpu_enabled::lower_bound(), make_handlers(), and RelAlgNode::toString().

Referenced by cast(), QueryPlanDagChecker::check(), RexSubQueryIdCollector::visit(), visit(), and QueryPlanDagChecker::visit().

41  {
42  // Array that pairs std::type_index(typeid(*rel_alg_node)) -> method pointer.
43  static auto const handlers = make_handlers<RelAlgNode,
46  RelFilter,
47  RelJoin,
51  RelModify,
52  RelProject,
53  RelScan,
54  RelSort,
57  static_assert(std::is_trivially_destructible_v<decltype(handlers)>);
58  // Will throw std::bad_typeid if rel_alg_node == nullptr.
59  auto const& type_index = std::type_index(typeid(*rel_alg_node));
60  auto const itr = std::lower_bound(handlers.cbegin(), handlers.cend(), type_index);
61  if (itr != handlers.cend() && itr->type_index == type_index) {
62  (this->*itr->handler)(rel_alg_node);
63  } else {
64  LOG(FATAL) << "Unhandled RelAlgNode type: " << rel_alg_node->toString();
65  }
66  for (size_t i = 0; i < rel_alg_node->inputCount(); ++i) {
67  visit(rel_alg_node->getInput(i));
68  }
69 }
void visit(RelAlgNode const *)
#define LOG(tag)
Definition: Logger.h:205
static Handlers< T, sizeof...(Ts)> make_handlers()
DEVICE auto lower_bound(ARGS &&...args)
Definition: gpu_enabled.h:78

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void RelRexDagVisitor::visit ( RexScalar const rex_scalar)
virtual

Definition at line 124 of file RelRexDagVisitor.cpp.

References logger::FATAL, LOG, gpu_enabled::lower_bound(), make_handlers(), and Rex::toString().

124  {
125  // Array that pairs std::type_index(typeid(*rex_scalar)) -> method pointer.
126  static auto const handlers = make_handlers<RexScalar,
128  RexCase,
130  RexInput,
131  RexLiteral,
132  RexOperator,
133  RexRef,
134  RexSubQuery,
136  static_assert(std::is_trivially_destructible_v<decltype(handlers)>);
137  // Will throw std::bad_typeid if rex_scalar == nullptr.
138  auto const& type_index = std::type_index(typeid(*rex_scalar));
139  auto const itr = std::lower_bound(handlers.cbegin(), handlers.cend(), type_index);
140  if (itr != handlers.cend() && itr->type_index == type_index) {
141  (this->*itr->handler)(rex_scalar);
142  } else {
143  LOG(FATAL) << "Unhandled RexScalar type: " << rex_scalar->toString();
144  }
145 }
#define LOG(tag)
Definition: Logger.h:205
static Handlers< T, sizeof...(Ts)> make_handlers()
DEVICE auto lower_bound(ARGS &&...args)
Definition: gpu_enabled.h:78

+ Here is the call graph for this function:

virtual void RelRexDagVisitor::visit ( RelAggregate const )
inlineprotectedvirtual

Definition at line 41 of file RelRexDagVisitor.h.

41 {}
void RelRexDagVisitor::visit ( RelCompound const rel_compound)
protectedvirtual

Reimplemented in QueryPlanDagChecker.

Definition at line 71 of file RelRexDagVisitor.cpp.

References RelCompound::getFilterExpr(), and visit().

71  {
72  if (rel_compound->getFilterExpr()) {
73  visit(rel_compound->getFilterExpr());
74  }
75 }
void visit(RelAlgNode const *)

+ Here is the call graph for this function:

void RelRexDagVisitor::visit ( RelFilter const rel_filter)
protectedvirtual

Definition at line 77 of file RelRexDagVisitor.cpp.

References RelFilter::getCondition(), and visit().

77  {
78  visit(rel_filter->getCondition());
79 }
void visit(RelAlgNode const *)

+ Here is the call graph for this function:

void RelRexDagVisitor::visit ( RelJoin const rel_join)
protectedvirtual

Definition at line 81 of file RelRexDagVisitor.cpp.

References RelJoin::getCondition(), and visit().

81  {
82  visit(rel_join->getCondition());
83 }
void visit(RelAlgNode const *)

+ Here is the call graph for this function:

void RelRexDagVisitor::visit ( RelLeftDeepInnerJoin const rel_left_deep_inner_join)
protectedvirtual

Definition at line 85 of file RelRexDagVisitor.cpp.

References RelLeftDeepInnerJoin::getInnerCondition(), RelLeftDeepInnerJoin::getOuterCondition(), RelAlgNode::inputCount(), and visit().

85  {
86  visit(rel_left_deep_inner_join->getInnerCondition());
87  for (size_t level = 1; level < rel_left_deep_inner_join->inputCount(); ++level) {
88  if (auto* outer_condition = rel_left_deep_inner_join->getOuterCondition(level)) {
89  visit(outer_condition);
90  }
91  }
92 }
void visit(RelAlgNode const *)

+ Here is the call graph for this function:

virtual void RelRexDagVisitor::visit ( RelLogicalUnion const )
inlineprotectedvirtual

Reimplemented in QueryPlanDagChecker.

Definition at line 46 of file RelRexDagVisitor.h.

46 {}
void RelRexDagVisitor::visit ( RelLogicalValues const rel_logical_values)
protectedvirtual

Reimplemented in QueryPlanDagChecker.

Definition at line 94 of file RelRexDagVisitor.cpp.

References RelLogicalValues::getNumRows(), RelLogicalValues::getRowsSize(), RelLogicalValues::getValueAt(), and visit().

94  {
95  for (size_t row_idx = 0; row_idx < rel_logical_values->getNumRows(); ++row_idx) {
96  for (size_t col_idx = 0; col_idx < rel_logical_values->getRowsSize(); ++col_idx) {
97  visit(rel_logical_values->getValueAt(row_idx, col_idx));
98  }
99  }
100 }
void visit(RelAlgNode const *)

+ Here is the call graph for this function:

virtual void RelRexDagVisitor::visit ( RelModify const )
inlineprotectedvirtual

Reimplemented in QueryPlanDagChecker.

Definition at line 48 of file RelRexDagVisitor.h.

48 {}
void RelRexDagVisitor::visit ( RelProject const rel_projection)
protectedvirtual

Reimplemented in QueryPlanDagChecker.

Definition at line 102 of file RelRexDagVisitor.cpp.

References RelProject::getProjectAt(), i, RelProject::size(), and visit().

102  {
103  for (size_t i = 0; i < rel_projection->size(); ++i) {
104  visit(rel_projection->getProjectAt(i));
105  }
106 }
void visit(RelAlgNode const *)

+ Here is the call graph for this function:

virtual void RelRexDagVisitor::visit ( RelScan const )
inlineprotectedvirtual

Reimplemented in QueryPlanDagChecker.

Definition at line 50 of file RelRexDagVisitor.h.

50 {}
virtual void RelRexDagVisitor::visit ( RelSort const )
inlineprotectedvirtual

Definition at line 51 of file RelRexDagVisitor.h.

51 {}
void RelRexDagVisitor::visit ( RelTableFunction const rel_table_function)
protectedvirtual

Reimplemented in QueryPlanDagChecker.

Definition at line 108 of file RelRexDagVisitor.cpp.

References RelTableFunction::getTableFuncInputAt(), RelTableFunction::getTableFuncInputsSize(), i, and visit().

108  {
109  for (size_t i = 0; i < rel_table_function->getTableFuncInputsSize(); ++i) {
110  visit(rel_table_function->getTableFuncInputAt(i));
111  }
112 }
void visit(RelAlgNode const *)

+ Here is the call graph for this function:

void RelRexDagVisitor::visit ( RelTranslatedJoin const rel_translated_join)
protectedvirtual

Definition at line 114 of file RelRexDagVisitor.cpp.

References RelTranslatedJoin::getLHS(), RelTranslatedJoin::getOuterJoinCond(), RelTranslatedJoin::getRHS(), and visit().

114  {
115  visit(rel_translated_join->getLHS());
116  visit(rel_translated_join->getRHS());
117  if (auto* outer_join_condition = rel_translated_join->getOuterJoinCond()) {
118  visit(outer_join_condition);
119  }
120 }
void visit(RelAlgNode const *)

+ Here is the call graph for this function:

virtual void RelRexDagVisitor::visit ( RexAbstractInput const )
inlineprotectedvirtual

Definition at line 55 of file RelRexDagVisitor.h.

55 {}
void RelRexDagVisitor::visit ( RexCase const rex_case)
protectedvirtual

Definition at line 157 of file RelRexDagVisitor.cpp.

References RexCase::branchCount(), RexCase::getElse(), RexCase::getThen(), RexCase::getWhen(), i, and visit().

157  {
158  for (size_t i = 0; i < rex_case->branchCount(); ++i) {
159  visit(rex_case->getWhen(i));
160  visit(rex_case->getThen(i));
161  }
162  if (rex_case->getElse()) {
163  visit(rex_case->getElse());
164  }
165 }
void visit(RelAlgNode const *)

+ Here is the call graph for this function:

void RelRexDagVisitor::visit ( RexFunctionOperator const rex_function_operator)
protectedvirtual

Reimplemented in QueryPlanDagChecker.

Definition at line 167 of file RelRexDagVisitor.cpp.

References RexOperator::getOperand(), i, RexOperator::size(), and visit().

167  {
168  for (size_t i = 0; i < rex_function_operator->size(); ++i) {
169  visit(rex_function_operator->getOperand(i));
170  }
171 }
void visit(RelAlgNode const *)

+ Here is the call graph for this function:

virtual void RelRexDagVisitor::visit ( RexInput const )
inlineprotectedvirtual

Definition at line 58 of file RelRexDagVisitor.h.

58 {} // Don't visit SourceNode
virtual void RelRexDagVisitor::visit ( RexLiteral const )
inlineprotectedvirtual

Definition at line 59 of file RelRexDagVisitor.h.

59 {}
void RelRexDagVisitor::visit ( RexOperator const rex_operator)
protectedvirtual

Reimplemented in QueryPlanDagChecker.

Definition at line 173 of file RelRexDagVisitor.cpp.

References RexOperator::getOperand(), i, RexOperator::size(), and visit().

173  {
174  for (size_t i = 0; i < rex_operator->size(); ++i) {
175  visit(rex_operator->getOperand(i));
176  }
177 }
void visit(RelAlgNode const *)

+ Here is the call graph for this function:

virtual void RelRexDagVisitor::visit ( RexRef const )
inlineprotectedvirtual

Definition at line 61 of file RelRexDagVisitor.h.

61 {}
void RelRexDagVisitor::visit ( RexSubQuery const rex_sub_query)
protectedvirtual

Reimplemented in RexSubQueryIdCollector.

Definition at line 179 of file RelRexDagVisitor.cpp.

References visit().

179  {
180  visit(rex_sub_query->getRelAlg());
181 }
void visit(RelAlgNode const *)

+ Here is the call graph for this function:

void RelRexDagVisitor::visit ( RexWindowFunctionOperator const rex_window_function_operator)
protectedvirtual

Definition at line 147 of file RelRexDagVisitor.cpp.

References RexWindowFunctionOperator::getOrderKeys(), RexWindowFunctionOperator::getPartitionKeys(), and visit().

148  {
149  for (const auto& partition_key : rex_window_function_operator->getPartitionKeys()) {
150  visit(partition_key.get());
151  }
152  for (const auto& order_key : rex_window_function_operator->getOrderKeys()) {
153  visit(order_key.get());
154  }
155 }
void visit(RelAlgNode const *)

+ Here is the call graph for this function:


The documentation for this class was generated from the following files: