OmniSciDB  cde582ebc3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
anonymous_namespace{RelAlgDag.cpp}::anonymous_namespace{RelAlgDag.cpp} Namespace Reference

Classes

class  RexInputReplacementVisitor
 
class  CoalesceSecondaryProjectVisitor
 

Functions

std::vector< const Rex * > reproject_targets (const RelProject *simple_project, const std::vector< const Rex * > &target_exprs) noexcept
 
bool input_can_be_coalesced (const RelAlgNode *parent_node, const size_t index, const bool first_rex_is_input)
 
bool is_window_function_sum (const RexScalar *rex)
 
bool is_window_function_avg (const RexScalar *rex)
 
bool is_window_function_operator (const RexScalar *rex)
 

Function Documentation

bool anonymous_namespace{RelAlgDag.cpp}::anonymous_namespace{RelAlgDag.cpp}::input_can_be_coalesced ( const RelAlgNode parent_node,
const size_t  index,
const bool  first_rex_is_input 
)

Definition at line 1806 of file RelAlgDag.cpp.

Referenced by anonymous_namespace{RelAlgDag.cpp}::coalesce_nodes(), and anonymous_namespace{RelAlgDag.cpp}::anonymous_namespace{RelAlgDag.cpp}::CoalesceSecondaryProjectVisitor::visitInput().

1808  {
1809  if (auto agg_node = dynamic_cast<const RelAggregate*>(parent_node)) {
1810  if (index == 0 && agg_node->getGroupByCount() > 0) {
1811  return true;
1812  } else {
1813  // Is an aggregated target, only allow the project to be elided if the aggregate
1814  // target is simply passed through (i.e. if the top level expression attached to
1815  // the project node is a RexInput expression)
1816  return first_rex_is_input;
1817  }
1818  }
1819  return first_rex_is_input;
1820 }

+ Here is the caller graph for this function:

bool anonymous_namespace{RelAlgDag.cpp}::anonymous_namespace{RelAlgDag.cpp}::is_window_function_avg ( const RexScalar rex)

Definition at line 1865 of file RelAlgDag.cpp.

References CHECK_EQ, COUNT, RexOperator::getOperand(), RexOperator::getOperator(), is_window_function_sum(), kDIVIDE, and RexOperator::size().

Referenced by is_window_function_operator().

1865  {
1866  const RexOperator* divide_operator = dynamic_cast<const RexOperator*>(rex);
1867  if (divide_operator && divide_operator->getOperator() == kDIVIDE) {
1868  CHECK_EQ(divide_operator->size(), size_t(2));
1869  const auto case_operator =
1870  dynamic_cast<const RexCase*>(divide_operator->getOperand(0));
1871  const auto second_window =
1872  dynamic_cast<const RexWindowFunctionOperator*>(divide_operator->getOperand(1));
1873  if (case_operator && second_window &&
1874  second_window->getKind() == SqlWindowFunctionKind::COUNT) {
1875  if (is_window_function_sum(case_operator)) {
1876  return true;
1877  }
1878  }
1879  }
1880  return false;
1881 }
#define CHECK_EQ(x, y)
Definition: Logger.h:230
size_t size() const
Definition: RelAlgDag.h:245
const RexScalar * getOperand(const size_t idx) const
Definition: RelAlgDag.h:247
SQLOps getOperator() const
Definition: RelAlgDag.h:257

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool anonymous_namespace{RelAlgDag.cpp}::anonymous_namespace{RelAlgDag.cpp}::is_window_function_operator ( const RexScalar rex)

Definition at line 1885 of file RelAlgDag.cpp.

References CHECK_EQ, is_window_function_avg(), is_window_function_sum(), and kCAST.

Referenced by RelProject::hasWindowFunctionExpr(), anonymous_namespace{RelAlgDag.cpp}::separate_window_function_expressions(), anonymous_namespace{RelAlgDag.cpp}::WindowFunctionCollector::visitCase(), and anonymous_namespace{RelAlgDag.cpp}::WindowFunctionCollector::visitOperator().

1885  {
1886  if (dynamic_cast<const RexWindowFunctionOperator*>(rex)) {
1887  return true;
1888  }
1889 
1890  // unwrap from casts, if they exist
1891  const auto rex_cast = dynamic_cast<const RexOperator*>(rex);
1892  if (rex_cast && rex_cast->getOperator() == kCAST) {
1893  CHECK_EQ(rex_cast->size(), size_t(1));
1894  return is_window_function_operator(rex_cast->getOperand(0));
1895  }
1896 
1898  return true;
1899  }
1900 
1901  return false;
1902 }
#define CHECK_EQ(x, y)
Definition: Logger.h:230
Definition: sqldefs.h:48

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool anonymous_namespace{RelAlgDag.cpp}::anonymous_namespace{RelAlgDag.cpp}::is_window_function_sum ( const RexScalar rex)

Definition at line 1851 of file RelAlgDag.cpp.

References SUM_INTERNAL.

Referenced by is_window_function_avg(), and is_window_function_operator().

1851  {
1852  const auto case_operator = dynamic_cast<const RexCase*>(rex);
1853  if (case_operator && case_operator->branchCount() == 1) {
1854  const auto then_window =
1855  dynamic_cast<const RexWindowFunctionOperator*>(case_operator->getThen(0));
1856  if (then_window && then_window->getKind() == SqlWindowFunctionKind::SUM_INTERNAL) {
1857  return true;
1858  }
1859  }
1860  return false;
1861 }

+ Here is the caller graph for this function:

std::vector<const Rex*> anonymous_namespace{RelAlgDag.cpp}::anonymous_namespace{RelAlgDag.cpp}::reproject_targets ( const RelProject simple_project,
const std::vector< const Rex * > &  target_exprs 
)
noexcept

Definition at line 1524 of file RelAlgDag.cpp.

References CHECK, CHECK_LT, and run_benchmark_import::result.

Referenced by anonymous_namespace{RelAlgDag.cpp}::create_compound().

1526  {
1527  std::vector<const Rex*> result;
1528  for (size_t i = 0; i < simple_project->size(); ++i) {
1529  const auto input_rex = dynamic_cast<const RexInput*>(simple_project->getProjectAt(i));
1530  CHECK(input_rex);
1531  CHECK_LT(static_cast<size_t>(input_rex->getIndex()), target_exprs.size());
1532  result.push_back(target_exprs[input_rex->getIndex()]);
1533  }
1534  return result;
1535 }
size_t size() const override
Definition: RelAlgDag.h:1068
const RexScalar * getProjectAt(const size_t idx) const
Definition: RelAlgDag.h:1070
#define CHECK_LT(x, y)
Definition: Logger.h:232
#define CHECK(condition)
Definition: Logger.h:222

+ Here is the caller graph for this function: