OmniSciDB  c07336695a
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 73 of file RexVisitor.h.

Member Function Documentation

◆ aggregateResult()

template<class T>
virtual T RexVisitor< T >::aggregateResult ( const T &  aggregate,
const T &  next_result 
) const
inlineprotectedvirtual

◆ defaultResult()

template<class T>
T RexVisitor< T >::defaultResult ( ) const
inlineoverrideprotectedvirtual

Implements RexVisitorBase< T >.

Definition at line 118 of file RexVisitor.h.

118 { return T{}; }

◆ visitCase()

template<class T>
T RexVisitor< T >::visitCase ( const RexCase rex_case) const
inlineoverridevirtual

Implements RexVisitorBase< T >.

Definition at line 99 of file RexVisitor.h.

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

◆ visitInput()

template<class T>
T RexVisitor< T >::visitInput ( const RexInput ) const
inlineoverridevirtual

Implements RexVisitorBase< T >.

Definition at line 75 of file RexVisitor.h.

75 { return defaultResult(); }
T defaultResult() const override
Definition: RexVisitor.h:118

◆ visitLiteral()

template<class T>
T RexVisitor< T >::visitLiteral ( const RexLiteral ) const
inlineoverridevirtual

Implements RexVisitorBase< T >.

Definition at line 77 of file RexVisitor.h.

77 { return defaultResult(); }
T defaultResult() const override
Definition: RexVisitor.h:118

◆ visitOperator()

template<class T>
T RexVisitor< T >::visitOperator ( const RexOperator rex_operator) const
inlineoverridevirtual

Implements RexVisitorBase< T >.

Definition at line 83 of file RexVisitor.h.

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

◆ visitRef()

template<class T>
T RexVisitor< T >::visitRef ( const RexRef ) const
inlineoverridevirtual

Implements RexVisitorBase< T >.

Definition at line 81 of file RexVisitor.h.

81 { return defaultResult(); }
T defaultResult() const override
Definition: RexVisitor.h:118

◆ visitSubQuery()

template<class T>
T RexVisitor< T >::visitSubQuery ( const RexSubQuery ) const
inlineoverridevirtual

Implements RexVisitorBase< T >.

Definition at line 79 of file RexVisitor.h.

79 { return defaultResult(); }
T defaultResult() const override
Definition: RexVisitor.h:118

◆ visitWindowFunctionOperator()

template<class T>
T RexVisitor< T >::visitWindowFunctionOperator ( const RexWindowFunctionOperator rex_window_func_operator,
const T  operands_visit_result 
) const
inlineprivate

Definition at line 121 of file RexVisitor.h.

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

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