OmniSciDB  ba1bac9284
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 (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 71 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 66 of file RelRexDagVisitor.h.

References visit().

66  {
67  visit(dynamic_cast<U const*>(node));
68  }
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(), RexSubQueryIdCollector::visit(), and 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,
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: " << rel_alg_node->toString();
64  }
65  for (size_t i = 0; i < rel_alg_node->inputCount(); ++i) {
66  visit(rel_alg_node->getInput(i));
67  }
68 }
void visit(RelAlgNode const *)
#define LOG(tag)
Definition: Logger.h:200
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 115 of file RelRexDagVisitor.cpp.

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

115  {
116  // Array that pairs std::type_index(typeid(*rex_scalar)) -> method pointer.
117  static auto const handlers = make_handlers<RexScalar,
119  RexCase,
121  RexInput,
122  RexLiteral,
123  RexOperator,
124  RexRef,
125  RexSubQuery,
127  static_assert(std::is_trivially_destructible_v<decltype(handlers)>);
128  // Will throw std::bad_typeid if rex_scalar == nullptr.
129  auto const& type_index = std::type_index(typeid(*rex_scalar));
130  auto const itr = std::lower_bound(handlers.cbegin(), handlers.cend(), type_index);
131  if (itr != handlers.cend() && itr->type_index == type_index) {
132  (this->*itr->handler)(rex_scalar);
133  } else {
134  LOG(FATAL) << "Unhandled RexScalar type: " << rex_scalar->toString();
135  }
136 }
#define LOG(tag)
Definition: Logger.h:200
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

Definition at line 70 of file RelRexDagVisitor.cpp.

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

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

+ Here is the call graph for this function:

void RelRexDagVisitor::visit ( RelFilter const rel_filter)
protectedvirtual

Definition at line 76 of file RelRexDagVisitor.cpp.

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

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

+ Here is the call graph for this function:

void RelRexDagVisitor::visit ( RelJoin const rel_join)
protectedvirtual

Definition at line 80 of file RelRexDagVisitor.cpp.

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

80  {
81  visit(rel_join->getCondition());
82 }
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 84 of file RelRexDagVisitor.cpp.

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

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

+ Here is the call graph for this function:

virtual void RelRexDagVisitor::visit ( RelLogicalUnion const )
inlineprotectedvirtual

Definition at line 46 of file RelRexDagVisitor.h.

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

Definition at line 93 of file RelRexDagVisitor.cpp.

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

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

+ Here is the call graph for this function:

virtual void RelRexDagVisitor::visit ( RelModify const )
inlineprotectedvirtual

Definition at line 48 of file RelRexDagVisitor.h.

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

Definition at line 101 of file RelRexDagVisitor.cpp.

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

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

+ Here is the call graph for this function:

virtual void RelRexDagVisitor::visit ( RelScan const )
inlineprotectedvirtual

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

Definition at line 107 of file RelRexDagVisitor.cpp.

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

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

+ Here is the call graph for this function:

virtual void RelRexDagVisitor::visit ( RexAbstractInput const )
inlineprotectedvirtual

Definition at line 54 of file RelRexDagVisitor.h.

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

Definition at line 148 of file RelRexDagVisitor.cpp.

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

148  {
149  for (size_t i = 0; i < rex_case->branchCount(); ++i) {
150  visit(rex_case->getWhen(i));
151  visit(rex_case->getThen(i));
152  }
153  if (rex_case->getElse()) {
154  visit(rex_case->getElse());
155  }
156 }
void visit(RelAlgNode const *)

+ Here is the call graph for this function:

void RelRexDagVisitor::visit ( RexFunctionOperator const rex_function_operator)
protectedvirtual

Definition at line 158 of file RelRexDagVisitor.cpp.

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

158  {
159  for (size_t i = 0; i < rex_function_operator->size(); ++i) {
160  visit(rex_function_operator->getOperand(i));
161  }
162 }
void visit(RelAlgNode const *)

+ Here is the call graph for this function:

virtual void RelRexDagVisitor::visit ( RexInput const )
inlineprotectedvirtual

Definition at line 57 of file RelRexDagVisitor.h.

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

Definition at line 58 of file RelRexDagVisitor.h.

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

Definition at line 164 of file RelRexDagVisitor.cpp.

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

164  {
165  for (size_t i = 0; i < rex_operator->size(); ++i) {
166  visit(rex_operator->getOperand(i));
167  }
168 }
void visit(RelAlgNode const *)

+ Here is the call graph for this function:

virtual void RelRexDagVisitor::visit ( RexRef const )
inlineprotectedvirtual

Definition at line 60 of file RelRexDagVisitor.h.

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

Reimplemented in RexSubQueryIdCollector.

Definition at line 170 of file RelRexDagVisitor.cpp.

References visit().

170  {
171  visit(rex_sub_query->getRelAlg());
172 }
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 138 of file RelRexDagVisitor.cpp.

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

139  {
140  for (const auto& partition_key : rex_window_function_operator->getPartitionKeys()) {
141  visit(partition_key.get());
142  }
143  for (const auto& order_key : rex_window_function_operator->getOrderKeys()) {
144  visit(order_key.get());
145  }
146 }
void visit(RelAlgNode const *)

+ Here is the call graph for this function:


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