OmniSciDB  b24e664e58
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RexVisitor< T > Class Template Reference

#include <RexVisitor.h>

+ Inheritance diagram for RexVisitor< T >:
+ Collaboration diagram for RexVisitor< T >:

Public Member Functions

visitInput (const RexInput *) const override
 
visitLiteral (const RexLiteral *) const override
 
visitSubQuery (const RexSubQuery *) const override
 
visitRef (const RexRef *) const override
 
visitOperator (const RexOperator *rex_operator) const override
 
visitCase (const RexCase *rex_case) const override
 
- Public Member Functions inherited from RexVisitorBase< T >
virtual T visit (const RexScalar *rex_scalar) const
 

Protected Member Functions

virtual T aggregateResult (const T &aggregate, const T &next_result) const
 
defaultResult () const override
 

Private Member Functions

visitWindowFunctionOperator (const RexWindowFunctionOperator *rex_window_func_operator, const T operands_visit_result) const
 

Detailed Description

template<class T>
class RexVisitor< T >

Definition at line 74 of file RexVisitor.h.

Member Function Documentation

template<class T>
virtual T RexVisitor< T >::aggregateResult ( const T &  aggregate,
const T &  next_result 
) const
inlineprotectedvirtual
template<class T>
T RexVisitor< T >::defaultResult ( ) const
inlineoverrideprotectedvirtual
template<class T>
T RexVisitor< T >::visitCase ( const RexCase rex_case) const
inlineoverridevirtual

Implements RexVisitorBase< T >.

Definition at line 100 of file RexVisitor.h.

100  {
101  T result = defaultResult();
102  for (size_t i = 0; i < rex_case->branchCount(); ++i) {
103  const auto when = rex_case->getWhen(i);
104  result = aggregateResult(result, RexVisitorBase<T>::visit(when));
105  const auto then = rex_case->getThen(i);
106  result = aggregateResult(result, RexVisitorBase<T>::visit(then));
107  }
108  if (rex_case->getElse()) {
109  result = aggregateResult(result, RexVisitorBase<T>::visit(rex_case->getElse()));
110  }
111  return result;
112  }
const RexScalar * getThen(const size_t idx) const
T defaultResult() const override
Definition: RexVisitor.h:119
const RexScalar * getElse() const
const RexScalar * getWhen(const size_t idx) const
virtual T aggregateResult(const T &aggregate, const T &next_result) const
Definition: RexVisitor.h:115
size_t branchCount() const
template<class T>
T RexVisitor< T >::visitInput ( const RexInput ) const
inlineoverridevirtual

Implements RexVisitorBase< T >.

Definition at line 76 of file RexVisitor.h.

76 { return defaultResult(); }
T defaultResult() const override
Definition: RexVisitor.h:119
template<class T>
T RexVisitor< T >::visitLiteral ( const RexLiteral ) const
inlineoverridevirtual

Implements RexVisitorBase< T >.

Definition at line 78 of file RexVisitor.h.

78 { return defaultResult(); }
T defaultResult() const override
Definition: RexVisitor.h:119
template<class T>
T RexVisitor< T >::visitOperator ( const RexOperator rex_operator) const
inlineoverridevirtual

Implements RexVisitorBase< T >.

Definition at line 84 of file RexVisitor.h.

84  {
85  const size_t operand_count = rex_operator->size();
86  T result = defaultResult();
87  for (size_t i = 0; i < operand_count; ++i) {
88  const auto operand = rex_operator->getOperand(i);
89  T operandResult = RexVisitorBase<T>::visit(operand);
90  result = aggregateResult(result, operandResult);
91  }
92  const auto rex_window_func_operator =
93  dynamic_cast<const RexWindowFunctionOperator*>(rex_operator);
94  if (rex_window_func_operator) {
95  return visitWindowFunctionOperator(rex_window_func_operator, result);
96  }
97  return result;
98  }
T defaultResult() const override
Definition: RexVisitor.h:119
size_t size() const
const RexScalar * getOperand(const size_t idx) const
virtual T aggregateResult(const T &aggregate, const T &next_result) const
Definition: RexVisitor.h:115
virtual T visit(const RexScalar *rex_scalar) const
Definition: RexVisitor.h:27
T visitWindowFunctionOperator(const RexWindowFunctionOperator *rex_window_func_operator, const T operands_visit_result) const
Definition: RexVisitor.h:122
template<class T>
T RexVisitor< T >::visitRef ( const RexRef ) const
inlineoverridevirtual

Implements RexVisitorBase< T >.

Definition at line 82 of file RexVisitor.h.

82 { return defaultResult(); }
T defaultResult() const override
Definition: RexVisitor.h:119
template<class T>
T RexVisitor< T >::visitSubQuery ( const RexSubQuery ) const
inlineoverridevirtual

Implements RexVisitorBase< T >.

Definition at line 80 of file RexVisitor.h.

80 { return defaultResult(); }
T defaultResult() const override
Definition: RexVisitor.h:119
template<class T>
T RexVisitor< T >::visitWindowFunctionOperator ( const RexWindowFunctionOperator rex_window_func_operator,
const T  operands_visit_result 
) const
inlineprivate

Definition at line 122 of file RexVisitor.h.

Referenced by RexVisitor< std::unordered_set< const RexInput * > >::visitOperator().

123  {
124  T result = operands_visit_result;
125  for (const auto& key : rex_window_func_operator->getPartitionKeys()) {
126  T partial_result = RexVisitorBase<T>::visit(key.get());
127  result = aggregateResult(result, partial_result);
128  }
129  for (const auto& key : rex_window_func_operator->getOrderKeys()) {
130  T partial_result = RexVisitorBase<T>::visit(key.get());
131  result = aggregateResult(result, partial_result);
132  }
133  return result;
134  }
virtual T aggregateResult(const T &aggregate, const T &next_result) const
Definition: RexVisitor.h:115
virtual T visit(const RexScalar *rex_scalar) const
Definition: RexVisitor.h:27
const ConstRexScalarPtrVector & getPartitionKeys() const
const ConstRexScalarPtrVector & getOrderKeys() const

+ Here is the caller graph for this function:


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