OmniSciDB  04ee39c94c
CardinalityEstimator.h File Reference

Estimators to be used when precise cardinality isn't useful. More...

+ Include dependency graph for CardinalityEstimator.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  CardinalityEstimationRequired
 
class  Analyzer::Estimator
 
class  Analyzer::NDVEstimator
 

Namespaces

 Analyzer
 

Functions

RelAlgExecutionUnit create_ndv_execution_unit (const RelAlgExecutionUnit &ra_exe_unit)
 
RelAlgExecutionUnit create_count_all_execution_unit (const RelAlgExecutionUnit &ra_exe_unit, std::shared_ptr< Analyzer::Expr > replacement_target)
 
ResultSetPtr reduce_estimator_results (const RelAlgExecutionUnit &ra_exe_unit, std::vector< std::pair< ResultSetPtr, std::vector< size_t >>> &results_per_device)
 

Detailed Description

Estimators to be used when precise cardinality isn't useful.

Author
Alex Suhan alex@.nosp@m.mapd.nosp@m..com Copyright (c) 2016 MapD Technologies, Inc. All rights reserved.

Definition in file CardinalityEstimator.h.

Function Documentation

◆ create_count_all_execution_unit()

RelAlgExecutionUnit create_count_all_execution_unit ( const RelAlgExecutionUnit ra_exe_unit,
std::shared_ptr< Analyzer::Expr replacement_target 
)

Definition at line 87 of file CardinalityEstimator.cpp.

References Default, RelAlgExecutionUnit::input_col_descs, RelAlgExecutionUnit::input_descs, RelAlgExecutionUnit::join_quals, RelAlgExecutionUnit::quals, RelAlgExecutionUnit::simple_quals, and strip_join_covered_filter_quals().

Referenced by Executor::executeUpdate(), and RelAlgExecutor::getFilteredCountAll().

89  {
90  return {ra_exe_unit.input_descs,
91  ra_exe_unit.input_col_descs,
92  ra_exe_unit.simple_quals,
93  strip_join_covered_filter_quals(ra_exe_unit.quals, ra_exe_unit.join_quals),
94  ra_exe_unit.join_quals,
95  {},
96  {replacement_target.get()},
97  nullptr,
99  0};
100 }
const std::vector< InputDescriptor > input_descs
std::list< std::shared_ptr< Analyzer::Expr > > strip_join_covered_filter_quals(const std::list< std::shared_ptr< Analyzer::Expr >> &quals, const JoinQualsPerNestingLevel &join_quals)
const JoinQualsPerNestingLevel join_quals
std::list< std::shared_ptr< Analyzer::Expr > > quals
std::list< std::shared_ptr< const InputColDescriptor > > input_col_descs
std::list< std::shared_ptr< Analyzer::Expr > > simple_quals
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create_ndv_execution_unit()

RelAlgExecutionUnit create_ndv_execution_unit ( const RelAlgExecutionUnit ra_exe_unit)

Definition at line 74 of file CardinalityEstimator.cpp.

References Default, RelAlgExecutionUnit::groupby_exprs, RelAlgExecutionUnit::input_col_descs, RelAlgExecutionUnit::input_descs, RelAlgExecutionUnit::join_quals, RelAlgExecutionUnit::quals, and RelAlgExecutionUnit::simple_quals.

Referenced by RelAlgExecutor::getNDVEstimation().

74  {
75  return {ra_exe_unit.input_descs,
76  ra_exe_unit.input_col_descs,
77  ra_exe_unit.simple_quals,
78  ra_exe_unit.quals,
79  ra_exe_unit.join_quals,
80  {},
81  {},
82  makeExpr<Analyzer::NDVEstimator>(ra_exe_unit.groupby_exprs),
84  0};
85 }
const std::list< std::shared_ptr< Analyzer::Expr > > groupby_exprs
const std::vector< InputDescriptor > input_descs
const JoinQualsPerNestingLevel join_quals
std::list< std::shared_ptr< Analyzer::Expr > > quals
std::list< std::shared_ptr< const InputColDescriptor > > input_col_descs
std::list< std::shared_ptr< Analyzer::Expr > > simple_quals
+ Here is the caller graph for this function:

◆ reduce_estimator_results()

ResultSetPtr reduce_estimator_results ( const RelAlgExecutionUnit ra_exe_unit,
std::vector< std::pair< ResultSetPtr, std::vector< size_t >>> &  results_per_device 
)

Definition at line 102 of file CardinalityEstimator.cpp.

References CHECK, and RelAlgExecutionUnit::estimator.

Referenced by Executor::reduceMultiDeviceResults().

104  {
105  if (results_per_device.empty()) {
106  return nullptr;
107  }
108  CHECK(dynamic_cast<const Analyzer::NDVEstimator*>(ra_exe_unit.estimator.get()));
109  const auto& result_set = results_per_device.front().first;
110  CHECK(result_set);
111  auto estimator_buffer = result_set->getHostEstimatorBuffer();
112  CHECK(estimator_buffer);
113  for (size_t i = 1; i < results_per_device.size(); ++i) {
114  const auto& next_result_set = results_per_device[i].first;
115  const auto other_estimator_buffer = next_result_set->getHostEstimatorBuffer();
116  for (size_t off = 0; off < ra_exe_unit.estimator->getBufferSize(); ++off) {
117  estimator_buffer[off] |= other_estimator_buffer[off];
118  }
119  }
120  return std::move(result_set);
121 }
const std::shared_ptr< Analyzer::Estimator > estimator
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the caller graph for this function: