OmniSciDB  04ee39c94c
RexDeepCopyVisitor Class Reference

#include <RexVisitor.h>

+ Inheritance diagram for RexDeepCopyVisitor:
+ Collaboration diagram for RexDeepCopyVisitor:

Protected Types

using RetType = std::unique_ptr< const RexScalar >
 

Protected Member Functions

RetType visitInput (const RexInput *input) const override
 
RetType visitLiteral (const RexLiteral *literal) const override
 
RetType visitSubQuery (const RexSubQuery *subquery) const override
 
RetType visitRef (const RexRef *ref) const override
 
RetType visitOperator (const RexOperator *rex_operator) const override
 
RetType visitCase (const RexCase *rex_case) const override
 

Private Member Functions

RetType defaultResult () const override
 

Additional Inherited Members

- Public Member Functions inherited from RexVisitorBase< std::unique_ptr< const RexScalar > >
virtual std::unique_ptr< const RexScalarvisit (const RexScalar *rex_scalar) const
 

Detailed Description

Definition at line 136 of file RexVisitor.h.

Member Typedef Documentation

◆ RetType

using RexDeepCopyVisitor::RetType = std::unique_ptr<const RexScalar>
protected

Definition at line 138 of file RexVisitor.h.

Member Function Documentation

◆ defaultResult()

RetType RexDeepCopyVisitor::defaultResult ( ) const
inlineoverrideprivatevirtual

Implements RexVisitorBase< std::unique_ptr< const RexScalar > >.

Definition at line 191 of file RexVisitor.h.

191 { return nullptr; }

◆ visitCase()

RetType RexDeepCopyVisitor::visitCase ( const RexCase rex_case) const
inlineoverrideprotectedvirtual

Implements RexVisitorBase< std::unique_ptr< const RexScalar > >.

Definition at line 180 of file RexVisitor.h.

References RexCase::branchCount(), RexCase::getElse(), RexCase::getThen(), RexCase::getWhen(), and RexVisitorBase< T >::visit().

180  {
181  std::vector<std::pair<RetType, RetType>> new_pair_list;
182  for (size_t i = 0; i < rex_case->branchCount(); ++i) {
183  new_pair_list.emplace_back(visit(rex_case->getWhen(i)),
184  visit(rex_case->getThen(i)));
185  }
186  auto new_else = visit(rex_case->getElse());
187  return boost::make_unique<RexCase>(new_pair_list, new_else);
188  }
size_t branchCount() const
const RexScalar * getWhen(const size_t idx) const
const RexScalar * getThen(const size_t idx) const
virtual std::unique_ptr< const RexScalar > visit(const RexScalar *rex_scalar) const
Definition: RexVisitor.h:27
const RexScalar * getElse() const
+ Here is the call graph for this function:

◆ visitInput()

RetType RexDeepCopyVisitor::visitInput ( const RexInput input) const
inlineoverrideprotectedvirtual

Implements RexVisitorBase< std::unique_ptr< const RexScalar > >.

Reimplemented in RexInputRenumber< bAllowMissing >.

Definition at line 140 of file RexVisitor.h.

References RexInput::deepCopy().

Referenced by anonymous_namespace{RelAlgOptimizer.cpp}::SubConditionReplacer::visitInput().

140 { return input->deepCopy(); }
std::unique_ptr< RexInput > deepCopy() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ visitLiteral()

RetType RexDeepCopyVisitor::visitLiteral ( const RexLiteral literal) const
inlineoverrideprotectedvirtual

Implements RexVisitorBase< std::unique_ptr< const RexScalar > >.

Definition at line 142 of file RexVisitor.h.

142  {
143  return literal->deepCopy();
144  }

◆ visitOperator()

RetType RexDeepCopyVisitor::visitOperator ( const RexOperator rex_operator) const
inlineoverrideprotectedvirtual

Implements RexVisitorBase< std::unique_ptr< const RexScalar > >.

Definition at line 152 of file RexVisitor.h.

References RexOperator::getDisambiguated(), RexOperator::getOperand(), RexWindowFunctionOperator::getPartitionKeys(), RexOperator::size(), and RexVisitorBase< T >::visit().

Referenced by SubConditionRemover::visitOperator().

152  {
153  const size_t operand_count = rex_operator->size();
154  std::vector<RetType> new_opnds;
155  for (size_t i = 0; i < operand_count; ++i) {
156  new_opnds.push_back(visit(rex_operator->getOperand(i)));
157  }
158  const auto rex_window_function_operator =
159  dynamic_cast<const RexWindowFunctionOperator*>(rex_operator);
160  if (rex_window_function_operator) {
161  const auto& partition_keys = rex_window_function_operator->getPartitionKeys();
162  std::vector<std::unique_ptr<const RexScalar>> disambiguated_partition_keys;
163  for (const auto& partition_key : partition_keys) {
164  disambiguated_partition_keys.emplace_back(visit(partition_key.get()));
165  }
166  std::vector<std::unique_ptr<const RexScalar>> disambiguated_order_keys;
167  const auto& order_keys = rex_window_function_operator->getOrderKeys();
168  for (const auto& order_key : order_keys) {
169  disambiguated_order_keys.emplace_back(visit(order_key.get()));
170  }
171  return rex_window_function_operator->disambiguatedOperands(
172  new_opnds,
173  disambiguated_partition_keys,
174  disambiguated_order_keys,
175  rex_window_function_operator->getCollation());
176  }
177  return rex_operator->getDisambiguated(new_opnds);
178  }
const ConstRexScalarPtrVector & getPartitionKeys() const
virtual std::unique_ptr< const RexOperator > getDisambiguated(std::vector< std::unique_ptr< const RexScalar >> &operands) const
const RexScalar * getOperand(const size_t idx) const
virtual std::unique_ptr< const RexScalar > visit(const RexScalar *rex_scalar) const
Definition: RexVisitor.h:27
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ visitRef()

RetType RexDeepCopyVisitor::visitRef ( const RexRef ref) const
inlineoverrideprotectedvirtual

Implements RexVisitorBase< std::unique_ptr< const RexScalar > >.

Definition at line 150 of file RexVisitor.h.

References RexRef::deepCopy().

150 { return ref->deepCopy(); }
std::unique_ptr< RexRef > deepCopy() const
+ Here is the call graph for this function:

◆ visitSubQuery()

RetType RexDeepCopyVisitor::visitSubQuery ( const RexSubQuery subquery) const
inlineoverrideprotectedvirtual

Implements RexVisitorBase< std::unique_ptr< const RexScalar > >.

Definition at line 146 of file RexVisitor.h.

146  {
147  return subquery->deepCopy();
148  }

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