OmniSciDB  a5dc49c757
 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 2198 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 2200 of file RelAlgDag.cpp.

2203  : collected_window_func_(collected_window_func)
2204  , only_add_window_expr_(only_add_window_expr) {}
std::unordered_map< size_t, const RexScalar * > & collected_window_func_
Definition: RelAlgDag.cpp:2276

Member Function Documentation

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

Definition at line 2273 of file RelAlgDag.cpp.

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

Definition at line 2263 of file RelAlgDag.cpp.

References Rex::toHash().

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

+ Here is the call graph for this function:

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

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

2230  {
2231  if (is_window_function_operator(rex_case)) {
2232  tryAddWindowExpr(rex_case);
2233  if (!only_add_window_expr_) {
2234  return nullptr;
2235  }
2236  }
2237 
2238  for (size_t i = 0; i < rex_case->branchCount(); ++i) {
2239  const auto when = rex_case->getWhen(i);
2240  if (is_window_function_operator(when)) {
2241  tryAddWindowExpr(when);
2242  } else {
2243  visit(when);
2244  }
2245  const auto then = rex_case->getThen(i);
2246  if (is_window_function_operator(then)) {
2247  tryAddWindowExpr(then);
2248  } else {
2249  visit(then);
2250  }
2251  }
2252  if (rex_case->getElse()) {
2253  auto else_expr = rex_case->getElse();
2254  if (is_window_function_operator(else_expr)) {
2255  tryAddWindowExpr(else_expr);
2256  } else {
2257  visit(else_expr);
2258  }
2259  }
2260  return defaultResult();
2261  }
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 2208 of file RelAlgDag.cpp.

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

2208  {
2209  if (is_window_function_operator(rex_operator)) {
2210  tryAddWindowExpr(rex_operator);
2211  }
2212  const size_t operand_count = rex_operator->size();
2213  for (size_t i = 0; i < operand_count; ++i) {
2214  const auto operand = rex_operator->getOperand(i);
2215  if (is_window_function_operator(operand)) {
2216  // Handle both RexWindowFunctionOperators and window functions built up from
2217  // multiple RexScalar objects (e.g. AVG)
2218  tryAddWindowExpr(operand);
2219  } else {
2220  visit(operand);
2221  }
2222  }
2223  return defaultResult();
2224  }
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 2276 of file RelAlgDag.cpp.

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

Definition at line 2277 of file RelAlgDag.cpp.


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