OmniSciDB  b24e664e58
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
anonymous_namespace{RelAlgAbstractInterpreter.cpp}::WindowFunctionDetectionVisitor Class Reference
+ Inheritance diagram for anonymous_namespace{RelAlgAbstractInterpreter.cpp}::WindowFunctionDetectionVisitor:
+ Collaboration diagram for anonymous_namespace{RelAlgAbstractInterpreter.cpp}::WindowFunctionDetectionVisitor:

Protected Member Functions

const RexScalarvisitOperator (const RexOperator *rex_operator) const final
 
const RexScalarvisitCase (const RexCase *rex_case) const final
 
const RexScalaraggregateResult (const RexScalar *const &aggregate, const RexScalar *const &next_result) const final
 
const RexScalardefaultResult () const final
 
- Protected Member Functions inherited from RexVisitor< const RexScalar * >
const RexScalardefaultResult () const override
 

Additional Inherited Members

- Public Member Functions inherited from RexVisitor< const RexScalar * >
const RexScalarvisitInput (const RexInput *) const override
 
const RexScalarvisitLiteral (const RexLiteral *) const override
 
const RexScalarvisitSubQuery (const RexSubQuery *) const override
 
const RexScalarvisitRef (const RexRef *) const override
 
const RexScalarvisitOperator (const RexOperator *rex_operator) const override
 
const RexScalarvisitCase (const RexCase *rex_case) const override
 
- Public Member Functions inherited from RexVisitorBase< const RexScalar * >
virtual const RexScalarvisit (const RexScalar *rex_scalar) const
 

Detailed Description

WindowFunctionDetectionVisitor detects the presence of embedded Window Function Rex Operators and returns a pointer to the WindowFunctionOperator. Only the first detected operator will be returned (e.g. a binary operator that is WindowFunc1 & WindowFunc2 would return a pointer to WindowFunc1). Neither the window function operator nor its parent expression are modified.

Definition at line 1473 of file RelAlgAbstractInterpreter.cpp.

Member Function Documentation

const RexScalar* anonymous_namespace{RelAlgAbstractInterpreter.cpp}::WindowFunctionDetectionVisitor::aggregateResult ( const RexScalar *const &  aggregate,
const RexScalar *const &  next_result 
) const
inlinefinalprotectedvirtual

Reimplemented from RexVisitor< const RexScalar * >.

Definition at line 1527 of file RelAlgAbstractInterpreter.cpp.

References UNREACHABLE.

1528  {
1529  // all methods calling aggregate result should be overriden
1530  UNREACHABLE();
1531  return nullptr;
1532  }
#define UNREACHABLE()
Definition: Logger.h:234
const RexScalar* anonymous_namespace{RelAlgAbstractInterpreter.cpp}::WindowFunctionDetectionVisitor::defaultResult ( ) const
inlinefinalprotectedvirtual

Implements RexVisitorBase< const RexScalar * >.

Definition at line 1534 of file RelAlgAbstractInterpreter.cpp.

1534 { return nullptr; }
const RexScalar* anonymous_namespace{RelAlgAbstractInterpreter.cpp}::WindowFunctionDetectionVisitor::visitCase ( const RexCase rex_case) const
inlinefinalprotectedvirtual

Implements RexVisitorBase< const RexScalar * >.

Definition at line 1502 of file RelAlgAbstractInterpreter.cpp.

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

1502  {
1503  if (is_window_function_operator(rex_case)) {
1504  return rex_case;
1505  }
1506 
1507  auto result = defaultResult();
1508  for (size_t i = 0; i < rex_case->branchCount(); ++i) {
1509  const auto when = rex_case->getWhen(i);
1510  result = is_window_function_operator(when) ? when : visit(when);
1511  if (result) {
1512  return result;
1513  }
1514  const auto then = rex_case->getThen(i);
1515  result = is_window_function_operator(then) ? then : visit(then);
1516  if (result) {
1517  return result;
1518  }
1519  }
1520  if (rex_case->getElse()) {
1521  auto else_expr = rex_case->getElse();
1522  result = is_window_function_operator(else_expr) ? else_expr : visit(else_expr);
1523  }
1524  return result;
1525  }
const RexScalar * getThen(const size_t idx) const
const RexScalar * getElse() const
const RexScalar * getWhen(const size_t idx) const
virtual const RexScalar * visit(const RexScalar *rex_scalar) const
Definition: RexVisitor.h:27
size_t branchCount() const

+ Here is the call graph for this function:

const RexScalar* anonymous_namespace{RelAlgAbstractInterpreter.cpp}::WindowFunctionDetectionVisitor::visitOperator ( const RexOperator rex_operator) const
inlinefinalprotectedvirtual

Implements RexVisitorBase< const RexScalar * >.

Definition at line 1476 of file RelAlgAbstractInterpreter.cpp.

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

1476  {
1477  if (is_window_function_operator(rex_operator)) {
1478  return rex_operator;
1479  }
1480 
1481  const size_t operand_count = rex_operator->size();
1482  for (size_t i = 0; i < operand_count; ++i) {
1483  const auto operand = rex_operator->getOperand(i);
1484  if (is_window_function_operator(operand)) {
1485  // Handle both RexWindowFunctionOperators and window functions built up from
1486  // multiple RexScalar objects (e.g. AVG)
1487  return operand;
1488  }
1489  const auto operandResult = visit(operand);
1490  if (operandResult) {
1491  return operandResult;
1492  }
1493  }
1494 
1495  return defaultResult();
1496  }
size_t size() const
const RexScalar * getOperand(const size_t idx) const
virtual const RexScalar * visit(const RexScalar *rex_scalar) const
Definition: RexVisitor.h:27

+ Here is the call graph for this function:


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