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

Public Member Functions

 WindowFunctionCollector (std::unordered_map< size_t, const RexScalar * > &collected_window_func, bool only_add_window_expr)
 

Protected Member Functions

void * visitOperator (const RexOperator *rex_operator) const final
 
void * visitCase (const RexCase *rex_case) const final
 
void tryAddWindowExpr (RexScalar const *expr) const
 
void * defaultResult () const final
 

Private Attributes

std::unordered_map< size_t,
const RexScalar * > & 
collected_window_func_
 
bool only_add_window_expr_
 

Detailed Description

Definition at line 2100 of file RelAlgDag.cpp.

Constructor & Destructor Documentation

anonymous_namespace{RelAlgDag.cpp}::WindowFunctionCollector::WindowFunctionCollector ( std::unordered_map< size_t, const RexScalar * > &  collected_window_func,
bool  only_add_window_expr 
)
inline

Definition at line 2102 of file RelAlgDag.cpp.

2105  : collected_window_func_(collected_window_func)
2106  , only_add_window_expr_(only_add_window_expr) {}
std::unordered_map< size_t, const RexScalar * > & collected_window_func_
Definition: RelAlgDag.cpp:2178

Member Function Documentation

void* anonymous_namespace{RelAlgDag.cpp}::WindowFunctionCollector::defaultResult ( ) const
inlinefinalprotected

Definition at line 2175 of file RelAlgDag.cpp.

2175 { return nullptr; }
void anonymous_namespace{RelAlgDag.cpp}::WindowFunctionCollector::tryAddWindowExpr ( RexScalar const *  expr) const
inlineprotected

Definition at line 2165 of file RelAlgDag.cpp.

References Rex::toHash().

2165  {
2166  if (!only_add_window_expr_) {
2167  collected_window_func_.emplace(expr->toHash(), expr);
2168  } else {
2169  if (auto window_expr = dynamic_cast<RexWindowFunctionOperator const*>(expr)) {
2170  collected_window_func_.emplace(window_expr->toHash(), window_expr);
2171  }
2172  }
2173  }
std::unordered_map< size_t, const RexScalar * > & collected_window_func_
Definition: RelAlgDag.cpp:2178

+ Here is the call graph for this function:

void* anonymous_namespace{RelAlgDag.cpp}::WindowFunctionCollector::visitCase ( const RexCase rex_case) const
inlinefinalprotected

Definition at line 2132 of file RelAlgDag.cpp.

References RexCase::branchCount(), RexCase::getElse(), RexCase::getThen(), RexCase::getWhen(), and anonymous_namespace{RelAlgDag.cpp}::anonymous_namespace{RelAlgDag.cpp}::is_window_function_operator().

2132  {
2133  if (is_window_function_operator(rex_case)) {
2134  tryAddWindowExpr(rex_case);
2135  if (!only_add_window_expr_) {
2136  return nullptr;
2137  }
2138  }
2139 
2140  for (size_t i = 0; i < rex_case->branchCount(); ++i) {
2141  const auto when = rex_case->getWhen(i);
2142  if (is_window_function_operator(when)) {
2143  tryAddWindowExpr(when);
2144  } else {
2145  visit(when);
2146  }
2147  const auto then = rex_case->getThen(i);
2148  if (is_window_function_operator(then)) {
2149  tryAddWindowExpr(then);
2150  } else {
2151  visit(then);
2152  }
2153  }
2154  if (rex_case->getElse()) {
2155  auto else_expr = rex_case->getElse();
2156  if (is_window_function_operator(else_expr)) {
2157  tryAddWindowExpr(else_expr);
2158  } else {
2159  visit(else_expr);
2160  }
2161  }
2162  return defaultResult();
2163  }
const RexScalar * getThen(const size_t idx) const
Definition: RelAlgDag.h:443
const RexScalar * getElse() const
Definition: RelAlgDag.h:448
const RexScalar * getWhen(const size_t idx) const
Definition: RelAlgDag.h:438
size_t branchCount() const
Definition: RelAlgDag.h:436

+ Here is the call graph for this function:

void* anonymous_namespace{RelAlgDag.cpp}::WindowFunctionCollector::visitOperator ( const RexOperator rex_operator) const
inlinefinalprotected

Definition at line 2110 of file RelAlgDag.cpp.

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

2110  {
2111  if (is_window_function_operator(rex_operator)) {
2112  tryAddWindowExpr(rex_operator);
2113  }
2114  const size_t operand_count = rex_operator->size();
2115  for (size_t i = 0; i < operand_count; ++i) {
2116  const auto operand = rex_operator->getOperand(i);
2117  if (is_window_function_operator(operand)) {
2118  // Handle both RexWindowFunctionOperators and window functions built up from
2119  // multiple RexScalar objects (e.g. AVG)
2120  tryAddWindowExpr(operand);
2121  } else {
2122  visit(operand);
2123  }
2124  }
2125  return defaultResult();
2126  }
size_t size() const
Definition: RelAlgDag.h:270
const RexScalar * getOperand(const size_t idx) const
Definition: RelAlgDag.h:272

+ Here is the call graph for this function:

Member Data Documentation

std::unordered_map<size_t, const RexScalar*>& anonymous_namespace{RelAlgDag.cpp}::WindowFunctionCollector::collected_window_func_
private

Definition at line 2178 of file RelAlgDag.cpp.

bool anonymous_namespace{RelAlgDag.cpp}::WindowFunctionCollector::only_add_window_expr_
private

Definition at line 2179 of file RelAlgDag.cpp.


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