OmniSciDB  ca0c39ec8f
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RexDeepCopyVisitor Class Reference

#include <RexVisitor.h>

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

Public Types

using RowValues = std::vector< std::unique_ptr< const RexScalar >>
 

Static Public Member Functions

static std::vector< RowValuescopy (std::vector< RowValues > const &rhs)
 

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 visitWindowFunctionOperator (const RexWindowFunctionOperator *rex_window_function_operator) const
 
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
RexScalar
visit (const RexScalar *rex_scalar) const
 

Detailed Description

Definition at line 138 of file RexVisitor.h.

Member Typedef Documentation

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

Definition at line 140 of file RexVisitor.h.

using RexDeepCopyVisitor::RowValues = std::vector<std::unique_ptr<const RexScalar>>

Definition at line 208 of file RexVisitor.h.

Member Function Documentation

static std::vector<RowValues> RexDeepCopyVisitor::copy ( std::vector< RowValues > const &  rhs)
inlinestatic

Definition at line 210 of file RexVisitor.h.

References RexVisitorBase< T >::visit().

210  {
211  RexDeepCopyVisitor copier;
212  std::vector<RowValues> retval;
213  retval.reserve(rhs.size());
214  for (auto const& row : rhs) {
215  retval.push_back({});
216  retval.back().reserve(row.size());
217  for (auto const& value : row) {
218  retval.back().push_back(copier.visit(value.get()));
219  }
220  }
221  return retval;
222  }
virtual T visit(const RexScalar *rex_scalar) const
Definition: RexVisitor.h:27

+ Here is the call graph for this function:

RetType RexDeepCopyVisitor::defaultResult ( ) const
inlineoverrideprivatevirtual

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

Definition at line 205 of file RexVisitor.h.

205 { return nullptr; }
RetType RexDeepCopyVisitor::visitCase ( const RexCase rex_case) const
inlineoverrideprotectedvirtual

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

Definition at line 194 of file RexVisitor.h.

References RexCase::branchCount(), RexCase::getElse(), RexCase::getThen(), RexCase::getWhen(), and RexVisitorBase< std::unique_ptr< const RexScalar > >::visit().

194  {
195  std::vector<std::pair<RetType, RetType>> new_pair_list;
196  for (size_t i = 0; i < rex_case->branchCount(); ++i) {
197  new_pair_list.emplace_back(visit(rex_case->getWhen(i)),
198  visit(rex_case->getThen(i)));
199  }
200  auto new_else = visit(rex_case->getElse());
201  return std::make_unique<RexCase>(new_pair_list, new_else);
202  }
const RexScalar * getThen(const size_t idx) const
Definition: RelAlgDag.h:400
const RexScalar * getElse() const
Definition: RelAlgDag.h:405
const RexScalar * getWhen(const size_t idx) const
Definition: RelAlgDag.h:395
virtual std::unique_ptr< const RexScalar > visit(const RexScalar *rex_scalar) const
Definition: RexVisitor.h:27
size_t branchCount() const
Definition: RelAlgDag.h:393

+ Here is the call graph for this function:

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

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

Reimplemented in RexInputRenumber< bAllowMissing >.

Definition at line 142 of file RexVisitor.h.

References RexInput::deepCopy().

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

142 { return input->deepCopy(); }
std::unique_ptr< RexInput > deepCopy() const
Definition: RelAlgDag.h:367

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

Definition at line 144 of file RexVisitor.h.

144  {
145  return literal->deepCopy();
146  }
RetType RexDeepCopyVisitor::visitOperator ( const RexOperator rex_operator) const
inlineoverrideprotectedvirtual

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

Definition at line 154 of file RexVisitor.h.

References RexOperator::getDisambiguated(), RexOperator::getOperand(), RexOperator::size(), RexVisitorBase< std::unique_ptr< const RexScalar > >::visit(), and visitWindowFunctionOperator().

Referenced by SubConditionRemover::visitOperator().

154  {
155  const auto rex_window_function_operator =
156  dynamic_cast<const RexWindowFunctionOperator*>(rex_operator);
157  if (rex_window_function_operator) {
158  return visitWindowFunctionOperator(rex_window_function_operator);
159  }
160 
161  const size_t operand_count = rex_operator->size();
162  std::vector<RetType> new_opnds;
163  for (size_t i = 0; i < operand_count; ++i) {
164  new_opnds.push_back(visit(rex_operator->getOperand(i)));
165  }
166  return rex_operator->getDisambiguated(new_opnds);
167  }
size_t size() const
Definition: RelAlgDag.h:245
const RexScalar * getOperand(const size_t idx) const
Definition: RelAlgDag.h:247
RetType visitWindowFunctionOperator(const RexWindowFunctionOperator *rex_window_function_operator) const
Definition: RexVisitor.h:169
virtual std::unique_ptr< const RexOperator > getDisambiguated(std::vector< std::unique_ptr< const RexScalar >> &operands) const
Definition: RelAlgDag.h:240
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:

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

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

Definition at line 152 of file RexVisitor.h.

References RexRef::deepCopy().

152 { return ref->deepCopy(); }
std::unique_ptr< RexRef > deepCopy() const
Definition: RelAlgDag.h:708

+ Here is the call graph for this function:

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

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

Definition at line 148 of file RexVisitor.h.

148  {
149  return subquery->deepCopy();
150  }
RetType RexDeepCopyVisitor::visitWindowFunctionOperator ( const RexWindowFunctionOperator rex_window_function_operator) const
inlineprotected

Definition at line 169 of file RexVisitor.h.

References RexWindowFunctionOperator::disambiguatedOperands(), RexWindowFunctionOperator::getCollation(), RexOperator::getOperand(), RexWindowFunctionOperator::getOrderKeys(), RexWindowFunctionOperator::getPartitionKeys(), RexOperator::size(), and RexVisitorBase< std::unique_ptr< const RexScalar > >::visit().

Referenced by visitOperator().

170  {
171  const size_t operand_count = rex_window_function_operator->size();
172  std::vector<RetType> new_opnds;
173  for (size_t i = 0; i < operand_count; ++i) {
174  new_opnds.push_back(visit(rex_window_function_operator->getOperand(i)));
175  }
176 
177  const auto& partition_keys = rex_window_function_operator->getPartitionKeys();
178  std::vector<std::unique_ptr<const RexScalar>> disambiguated_partition_keys;
179  for (const auto& partition_key : partition_keys) {
180  disambiguated_partition_keys.emplace_back(visit(partition_key.get()));
181  }
182  std::vector<std::unique_ptr<const RexScalar>> disambiguated_order_keys;
183  const auto& order_keys = rex_window_function_operator->getOrderKeys();
184  for (const auto& order_key : order_keys) {
185  disambiguated_order_keys.emplace_back(visit(order_key.get()));
186  }
187  return rex_window_function_operator->disambiguatedOperands(
188  new_opnds,
189  disambiguated_partition_keys,
190  disambiguated_order_keys,
191  rex_window_function_operator->getCollation());
192  }
size_t size() const
Definition: RelAlgDag.h:245
const RexScalar * getOperand(const size_t idx) const
Definition: RelAlgDag.h:247
const std::vector< SortField > & getCollation() const
Definition: RelAlgDag.h:600
virtual std::unique_ptr< const RexScalar > visit(const RexScalar *rex_scalar) const
Definition: RexVisitor.h:27
std::unique_ptr< const RexOperator > disambiguatedOperands(ConstRexScalarPtrVector &operands, ConstRexScalarPtrVector &partition_keys, ConstRexScalarPtrVector &order_keys, const std::vector< SortField > &collation) const
Definition: RelAlgDag.h:608
const ConstRexScalarPtrVector & getPartitionKeys() const
Definition: RelAlgDag.h:573
const ConstRexScalarPtrVector & getOrderKeys() const
Definition: RelAlgDag.h:583

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


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