OmniSciDB  a987f07e93
 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 2108 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 2110 of file RelAlgDag.cpp.

2113  : collected_window_func_(collected_window_func)
2114  , only_add_window_expr_(only_add_window_expr) {}
std::unordered_map< size_t, const RexScalar * > & collected_window_func_
Definition: RelAlgDag.cpp:2186

Member Function Documentation

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

Definition at line 2183 of file RelAlgDag.cpp.

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

Definition at line 2173 of file RelAlgDag.cpp.

References Rex::toHash().

2173  {
2174  if (!only_add_window_expr_) {
2175  collected_window_func_.emplace(expr->toHash(), expr);
2176  } else {
2177  if (auto window_expr = dynamic_cast<RexWindowFunctionOperator const*>(expr)) {
2178  collected_window_func_.emplace(window_expr->toHash(), window_expr);
2179  }
2180  }
2181  }
std::unordered_map< size_t, const RexScalar * > & collected_window_func_
Definition: RelAlgDag.cpp:2186

+ Here is the call graph for this function:

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

Definition at line 2140 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().

2140  {
2141  if (is_window_function_operator(rex_case)) {
2142  tryAddWindowExpr(rex_case);
2143  if (!only_add_window_expr_) {
2144  return nullptr;
2145  }
2146  }
2147 
2148  for (size_t i = 0; i < rex_case->branchCount(); ++i) {
2149  const auto when = rex_case->getWhen(i);
2150  if (is_window_function_operator(when)) {
2151  tryAddWindowExpr(when);
2152  } else {
2153  visit(when);
2154  }
2155  const auto then = rex_case->getThen(i);
2156  if (is_window_function_operator(then)) {
2157  tryAddWindowExpr(then);
2158  } else {
2159  visit(then);
2160  }
2161  }
2162  if (rex_case->getElse()) {
2163  auto else_expr = rex_case->getElse();
2164  if (is_window_function_operator(else_expr)) {
2165  tryAddWindowExpr(else_expr);
2166  } else {
2167  visit(else_expr);
2168  }
2169  }
2170  return defaultResult();
2171  }
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 2118 of file RelAlgDag.cpp.

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

2118  {
2119  if (is_window_function_operator(rex_operator)) {
2120  tryAddWindowExpr(rex_operator);
2121  }
2122  const size_t operand_count = rex_operator->size();
2123  for (size_t i = 0; i < operand_count; ++i) {
2124  const auto operand = rex_operator->getOperand(i);
2125  if (is_window_function_operator(operand)) {
2126  // Handle both RexWindowFunctionOperators and window functions built up from
2127  // multiple RexScalar objects (e.g. AVG)
2128  tryAddWindowExpr(operand);
2129  } else {
2130  visit(operand);
2131  }
2132  }
2133  return defaultResult();
2134  }
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 2186 of file RelAlgDag.cpp.

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

Definition at line 2187 of file RelAlgDag.cpp.


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