OmniSciDB  72c90bc290
 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 2195 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 2197 of file RelAlgDag.cpp.

2200  : collected_window_func_(collected_window_func)
2201  , only_add_window_expr_(only_add_window_expr) {}
std::unordered_map< size_t, const RexScalar * > & collected_window_func_
Definition: RelAlgDag.cpp:2273

Member Function Documentation

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

Definition at line 2270 of file RelAlgDag.cpp.

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

Definition at line 2260 of file RelAlgDag.cpp.

References Rex::toHash().

2260  {
2261  if (!only_add_window_expr_) {
2262  collected_window_func_.emplace(expr->toHash(), expr);
2263  } else {
2264  if (auto window_expr = dynamic_cast<RexWindowFunctionOperator const*>(expr)) {
2265  collected_window_func_.emplace(window_expr->toHash(), window_expr);
2266  }
2267  }
2268  }
std::unordered_map< size_t, const RexScalar * > & collected_window_func_
Definition: RelAlgDag.cpp:2273

+ Here is the call graph for this function:

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

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

2227  {
2228  if (is_window_function_operator(rex_case)) {
2229  tryAddWindowExpr(rex_case);
2230  if (!only_add_window_expr_) {
2231  return nullptr;
2232  }
2233  }
2234 
2235  for (size_t i = 0; i < rex_case->branchCount(); ++i) {
2236  const auto when = rex_case->getWhen(i);
2237  if (is_window_function_operator(when)) {
2238  tryAddWindowExpr(when);
2239  } else {
2240  visit(when);
2241  }
2242  const auto then = rex_case->getThen(i);
2243  if (is_window_function_operator(then)) {
2244  tryAddWindowExpr(then);
2245  } else {
2246  visit(then);
2247  }
2248  }
2249  if (rex_case->getElse()) {
2250  auto else_expr = rex_case->getElse();
2251  if (is_window_function_operator(else_expr)) {
2252  tryAddWindowExpr(else_expr);
2253  } else {
2254  visit(else_expr);
2255  }
2256  }
2257  return defaultResult();
2258  }
const RexScalar * getThen(const size_t idx) const
Definition: RelAlgDag.h:440
const RexScalar * getElse() const
Definition: RelAlgDag.h:445
const RexScalar * getWhen(const size_t idx) const
Definition: RelAlgDag.h:435
size_t branchCount() const
Definition: RelAlgDag.h:433

+ Here is the call graph for this function:

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

Definition at line 2205 of file RelAlgDag.cpp.

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

2205  {
2206  if (is_window_function_operator(rex_operator)) {
2207  tryAddWindowExpr(rex_operator);
2208  }
2209  const size_t operand_count = rex_operator->size();
2210  for (size_t i = 0; i < operand_count; ++i) {
2211  const auto operand = rex_operator->getOperand(i);
2212  if (is_window_function_operator(operand)) {
2213  // Handle both RexWindowFunctionOperators and window functions built up from
2214  // multiple RexScalar objects (e.g. AVG)
2215  tryAddWindowExpr(operand);
2216  } else {
2217  visit(operand);
2218  }
2219  }
2220  return defaultResult();
2221  }
size_t size() const
Definition: RelAlgDag.h:364
const RexScalar * getOperand(const size_t idx) const
Definition: RelAlgDag.h:366

+ 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 2273 of file RelAlgDag.cpp.

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

Definition at line 2274 of file RelAlgDag.cpp.


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