OmniSciDB  6686921089
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
anonymous_namespace{RelAlgDagBuilder.cpp}::RexWindowFuncReplacementVisitor Class Reference
+ Inheritance diagram for anonymous_namespace{RelAlgDagBuilder.cpp}::RexWindowFuncReplacementVisitor:
+ Collaboration diagram for anonymous_namespace{RelAlgDagBuilder.cpp}::RexWindowFuncReplacementVisitor:

Public Member Functions

 RexWindowFuncReplacementVisitor (std::unique_ptr< const RexScalar > replacement_rex)
 
 ~RexWindowFuncReplacementVisitor ()
 
- Public Member Functions inherited from RexVisitorBase< std::unique_ptr< const RexScalar > >
virtual std::unique_ptr< const
RexScalar
visit (const RexScalar *rex_scalar) const
 

Protected Member Functions

RetType visitOperator (const RexOperator *rex_operator) const final
 
RetType visitCase (const RexCase *rex_case) const final
 
- Protected Member Functions inherited from RexDeepCopyVisitor
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

bool should_replace_operand (const RexScalar *rex) const
 

Private Attributes

std::unique_ptr< const RexScalarreplacement_rex_
 

Additional Inherited Members

- Public Types inherited from RexDeepCopyVisitor
using RowValues = std::vector< std::unique_ptr< const RexScalar >>
 
- Static Public Member Functions inherited from RexDeepCopyVisitor
static std::vector< RowValuescopy (std::vector< RowValues > const &rhs)
 
- Protected Types inherited from RexDeepCopyVisitor
using RetType = std::unique_ptr< const RexScalar >
 

Detailed Description

Replaces the first occurrence of a WindowFunctionOperator rex with the provided replacement_rex. Typically used for splitting a complex rex into two simpler rexes, and forwarding one of the rexes to a later node. The forwarded rex is then replaced with a RexInput using this visitor. Note that for window function replacement, the overloads in this visitor must match the overloads in the detection visitor above, to ensure a detected window function expression is properly replaced.

Definition at line 1833 of file RelAlgDagBuilder.cpp.

Constructor & Destructor Documentation

anonymous_namespace{RelAlgDagBuilder.cpp}::RexWindowFuncReplacementVisitor::RexWindowFuncReplacementVisitor ( std::unique_ptr< const RexScalar replacement_rex)
inline

Definition at line 1835 of file RelAlgDagBuilder.cpp.

1836  : replacement_rex_(std::move(replacement_rex)) {}
anonymous_namespace{RelAlgDagBuilder.cpp}::RexWindowFuncReplacementVisitor::~RexWindowFuncReplacementVisitor ( )
inline

Definition at line 1838 of file RelAlgDagBuilder.cpp.

References CHECK.

1838 { CHECK(replacement_rex_ == nullptr); }
#define CHECK(condition)
Definition: Logger.h:209

Member Function Documentation

bool anonymous_namespace{RelAlgDagBuilder.cpp}::RexWindowFuncReplacementVisitor::should_replace_operand ( const RexScalar rex) const
inlineprivate

Definition at line 1888 of file RelAlgDagBuilder.cpp.

References anonymous_namespace{RelAlgDagBuilder.cpp}::anonymous_namespace{RelAlgDagBuilder.cpp}::is_window_function_operator().

+ Here is the call graph for this function:

RetType anonymous_namespace{RelAlgDagBuilder.cpp}::RexWindowFuncReplacementVisitor::visitCase ( const RexCase rex_case) const
inlinefinalprotectedvirtual

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

Definition at line 1866 of file RelAlgDagBuilder.cpp.

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

1866  {
1867  if (should_replace_operand(rex_case)) {
1868  return std::move(replacement_rex_);
1869  }
1870 
1871  std::vector<std::pair<RetType, RetType>> new_pair_list;
1872  for (size_t i = 0; i < rex_case->branchCount(); ++i) {
1873  auto when_operand = rex_case->getWhen(i);
1874  auto then_operand = rex_case->getThen(i);
1875  new_pair_list.emplace_back(
1876  should_replace_operand(when_operand) ? std::move(replacement_rex_)
1877  : visit(when_operand),
1878  should_replace_operand(then_operand) ? std::move(replacement_rex_)
1879  : visit(then_operand));
1880  }
1881  auto new_else = should_replace_operand(rex_case->getElse())
1882  ? std::move(replacement_rex_)
1883  : visit(rex_case->getElse());
1884  return std::make_unique<RexCase>(new_pair_list, new_else);
1885  }
const RexScalar * getThen(const size_t idx) const
const RexScalar * getElse() const
const RexScalar * getWhen(const size_t idx) const
virtual std::unique_ptr< const RexScalar > visit(const RexScalar *rex_scalar) const
Definition: RexVisitor.h:27
size_t branchCount() const

+ Here is the call graph for this function:

RetType anonymous_namespace{RelAlgDagBuilder.cpp}::RexWindowFuncReplacementVisitor::visitOperator ( const RexOperator rex_operator) const
inlinefinalprotectedvirtual

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

Definition at line 1841 of file RelAlgDagBuilder.cpp.

References i.

1841  {
1842  if (should_replace_operand(rex_operator)) {
1843  return std::move(replacement_rex_);
1844  }
1845 
1846  const auto rex_window_function_operator =
1847  dynamic_cast<const RexWindowFunctionOperator*>(rex_operator);
1848  if (rex_window_function_operator) {
1849  // Deep copy the embedded window function operator
1850  return visitWindowFunctionOperator(rex_window_function_operator);
1851  }
1852 
1853  const size_t operand_count = rex_operator->size();
1854  std::vector<RetType> new_opnds;
1855  for (size_t i = 0; i < operand_count; ++i) {
1856  const auto operand = rex_operator->getOperand(i);
1857  if (should_replace_operand(operand)) {
1858  new_opnds.push_back(std::move(replacement_rex_));
1859  } else {
1860  new_opnds.emplace_back(visit(rex_operator->getOperand(i)));
1861  }
1862  }
1863  return rex_operator->getDisambiguated(new_opnds);
1864  }
size_t size() const
const RexScalar * getOperand(const size_t idx) const
RetType visitWindowFunctionOperator(const RexWindowFunctionOperator *rex_window_function_operator) const
Definition: RexVisitor.h:168
virtual std::unique_ptr< const RexOperator > getDisambiguated(std::vector< std::unique_ptr< const RexScalar >> &operands) const
virtual std::unique_ptr< const RexScalar > visit(const RexScalar *rex_scalar) const
Definition: RexVisitor.h:27

Member Data Documentation

std::unique_ptr<const RexScalar> anonymous_namespace{RelAlgDagBuilder.cpp}::RexWindowFuncReplacementVisitor::replacement_rex_
mutableprivate

Definition at line 1892 of file RelAlgDagBuilder.cpp.


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