OmniSciDB  ca0c39ec8f
 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
 
virtual 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 *)
 
void castAndVisit (RelAlgNode 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 35 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 75 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 70 of file RelRexDagVisitor.h.

References visit().

70  {
71  visit(dynamic_cast<U const*>(node));
72  }
virtual void visit(RelAlgNode const *)

+ Here is the call graph for this function:

void RelRexDagVisitor::castAndVisit ( RelAlgNode const *  rel_alg_node)
protected

Definition at line 40 of file RelRexDagVisitor.cpp.

References RelRexToStringConfig::defaults(), logger::FATAL, LOG, gpu_enabled::lower_bound(), make_handlers(), and RelAlgNode::toString().

Referenced by visit().

40  {
41  // Array that pairs std::type_index(typeid(*rel_alg_node)) -> method pointer.
42  static auto const handlers = make_handlers<RelAlgNode,
45  RelFilter,
46  RelJoin,
50  RelModify,
51  RelProject,
52  RelScan,
53  RelSort,
56  static_assert(std::is_trivially_destructible_v<decltype(handlers)>);
57  // Will throw std::bad_typeid if rel_alg_node == nullptr.
58  auto const& type_index = std::type_index(typeid(*rel_alg_node));
59  auto const itr = std::lower_bound(handlers.cbegin(), handlers.cend(), type_index);
60  if (itr != handlers.cend() && itr->type_index == type_index) {
61  (this->*itr->handler)(rel_alg_node);
62  } else {
63  LOG(FATAL) << "Unhandled RelAlgNode type: "
64  << rel_alg_node->toString(RelRexToStringConfig::defaults());
65  }
66 }
#define LOG(tag)
Definition: Logger.h:216
static Handlers< T, sizeof...(Ts)> make_handlers()
DEVICE auto lower_bound(ARGS &&...args)
Definition: gpu_enabled.h:78
static RelRexToStringConfig defaults()
Definition: RelAlgDag.h:49

+ Here is the call graph for this function:

+ Here is the caller 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 heavydb.dtypes::T.

Referenced by castAndVisit(), and 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)
virtual

Definition at line 68 of file RelRexDagVisitor.cpp.

References castAndVisit(), RelAlgNode::getInput(), and RelAlgNode::inputCount().

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

68  {
69  castAndVisit(rel_alg_node);
70  for (size_t i = 0; i < rel_alg_node->inputCount(); ++i) {
71  visit(rel_alg_node->getInput(i));
72  }
73 }
virtual void visit(RelAlgNode const *)
void castAndVisit(RelAlgNode const *)

+ 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 130 of file RelRexDagVisitor.cpp.

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

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

+ Here is the call graph for this function:

virtual void RelRexDagVisitor::visit ( RelAggregate const *  )
inlineprotectedvirtual

Definition at line 42 of file RelRexDagVisitor.h.

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

Reimplemented in QueryPlanDagChecker.

Definition at line 75 of file RelRexDagVisitor.cpp.

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

75  {
76  if (rel_compound->getFilterExpr()) {
77  visit(rel_compound->getFilterExpr());
78  }
79  for (size_t i = 0; i < rel_compound->getScalarSourcesSize(); ++i) {
80  visit(rel_compound->getScalarSource(i));
81  }
82 }
virtual void visit(RelAlgNode const *)

+ Here is the call graph for this function:

void RelRexDagVisitor::visit ( RelFilter const *  rel_filter)
protectedvirtual

Definition at line 84 of file RelRexDagVisitor.cpp.

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

84  {
85  visit(rel_filter->getCondition());
86 }
virtual void visit(RelAlgNode const *)

+ Here is the call graph for this function:

void RelRexDagVisitor::visit ( RelJoin const *  rel_join)
protectedvirtual

Definition at line 88 of file RelRexDagVisitor.cpp.

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

88  {
89  visit(rel_join->getCondition());
90 }
virtual 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 92 of file RelRexDagVisitor.cpp.

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

92  {
93  visit(rel_left_deep_inner_join->getInnerCondition());
94  for (size_t level = 1; level < rel_left_deep_inner_join->inputCount(); ++level) {
95  if (auto* outer_condition = rel_left_deep_inner_join->getOuterCondition(level)) {
96  visit(outer_condition);
97  }
98  }
99 }
virtual 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 47 of file RelRexDagVisitor.h.

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

Reimplemented in QueryPlanDagChecker.

Definition at line 101 of file RelRexDagVisitor.cpp.

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

101  {
102  for (size_t row_idx = 0; row_idx < rel_logical_values->getNumRows(); ++row_idx) {
103  for (size_t col_idx = 0; col_idx < rel_logical_values->getRowsSize(); ++col_idx) {
104  visit(rel_logical_values->getValueAt(row_idx, col_idx));
105  }
106  }
107 }
virtual 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 49 of file RelRexDagVisitor.h.

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

Reimplemented in QueryPlanDagChecker.

Definition at line 109 of file RelRexDagVisitor.cpp.

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

109  {
110  for (size_t i = 0; i < rel_projection->size(); ++i) {
111  visit(rel_projection->getProjectAt(i));
112  }
113 }
virtual void visit(RelAlgNode const *)

+ Here is the call graph for this function:

virtual void RelRexDagVisitor::visit ( RelScan const *  )
inlineprotectedvirtual
virtual void RelRexDagVisitor::visit ( RelSort const *  )
inlineprotectedvirtual

Definition at line 52 of file RelRexDagVisitor.h.

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

Definition at line 115 of file RelRexDagVisitor.cpp.

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

115  {
116  for (size_t i = 0; i < rel_table_function->getTableFuncInputsSize(); ++i) {
117  visit(rel_table_function->getTableFuncInputAt(i));
118  }
119 }
virtual void visit(RelAlgNode const *)

+ Here is the call graph for this function:

void RelRexDagVisitor::visit ( RelTranslatedJoin const *  rel_translated_join)
protectedvirtual

Definition at line 121 of file RelRexDagVisitor.cpp.

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

121  {
122  visit(rel_translated_join->getLHS());
123  visit(rel_translated_join->getRHS());
124  if (auto* outer_join_condition = rel_translated_join->getOuterJoinCond()) {
125  visit(outer_join_condition);
126  }
127 }
virtual void visit(RelAlgNode const *)

+ Here is the call graph for this function:

virtual void RelRexDagVisitor::visit ( RexAbstractInput const *  )
inlineprotectedvirtual

Definition at line 56 of file RelRexDagVisitor.h.

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

Definition at line 164 of file RelRexDagVisitor.cpp.

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

164  {
165  for (size_t i = 0; i < rex_case->branchCount(); ++i) {
166  visit(rex_case->getWhen(i));
167  visit(rex_case->getThen(i));
168  }
169  if (rex_case->getElse()) {
170  visit(rex_case->getElse());
171  }
172 }
virtual 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 174 of file RelRexDagVisitor.cpp.

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

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

+ Here is the call graph for this function:

void RelRexDagVisitor::visit ( RexInput const *  rex_input)
protectedvirtual

Definition at line 190 of file RelRexDagVisitor.cpp.

References RexInput::getSourceNode(), and visit().

190  {
191  visit(rex_input->getSourceNode());
192 }
virtual void visit(RelAlgNode const *)

+ Here is the call graph for this function:

virtual void RelRexDagVisitor::visit ( RexLiteral const *  )
inlineprotectedvirtual

Definition at line 60 of file RelRexDagVisitor.h.

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

Reimplemented in QueryPlanDagChecker, and SQLOperatorDetector.

Definition at line 180 of file RelRexDagVisitor.cpp.

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

180  {
181  for (size_t i = 0; i < rex_operator->size(); ++i) {
182  visit(rex_operator->getOperand(i));
183  }
184 }
virtual void visit(RelAlgNode const *)

+ Here is the call graph for this function:

virtual void RelRexDagVisitor::visit ( RexRef const *  )
inlineprotectedvirtual

Definition at line 62 of file RelRexDagVisitor.h.

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

Reimplemented in RexSubQueryIdCollector.

Definition at line 186 of file RelRexDagVisitor.cpp.

References visit().

186  {
187  visit(rex_sub_query->getRelAlg());
188 }
virtual 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 154 of file RelRexDagVisitor.cpp.

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

155  {
156  for (const auto& partition_key : rex_window_function_operator->getPartitionKeys()) {
157  visit(partition_key.get());
158  }
159  for (const auto& order_key : rex_window_function_operator->getOrderKeys()) {
160  visit(order_key.get());
161  }
162 }
virtual void visit(RelAlgNode const *)

+ Here is the call graph for this function:


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