OmniSciDB  dfae7c3b14
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
 
class  Analyzer::LargeNDVEstimator
 

Namespaces

 Analyzer
 

Functions

RelAlgExecutionUnit create_ndv_execution_unit (const RelAlgExecutionUnit &ra_exe_unit, const int64_t range)
 
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 104 of file CardinalityEstimator.cpp.

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

Referenced by RelAlgExecutor::getFilteredCountAll(), and Analyzer::LargeNDVEstimator::LargeNDVEstimator().

106  {
107  return {ra_exe_unit.input_descs,
108  ra_exe_unit.input_col_descs,
109  ra_exe_unit.simple_quals,
110  strip_join_covered_filter_quals(ra_exe_unit.quals, ra_exe_unit.join_quals),
111  ra_exe_unit.join_quals,
112  {},
113  {replacement_target.get()},
114  nullptr,
115  SortInfo{{}, SortAlgorithm::Default, 0, 0},
116  0,
117  false,
118  ra_exe_unit.union_all,
119  ra_exe_unit.query_state};
120 }
const std::optional< bool > union_all
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::shared_ptr< const query_state::QueryState > query_state
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,
const int64_t  range 
)

Definition at line 85 of file CardinalityEstimator.cpp.

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

Referenced by RelAlgExecutor::getNDVEstimation(), and Analyzer::LargeNDVEstimator::LargeNDVEstimator().

86  {
87  return {ra_exe_unit.input_descs,
88  ra_exe_unit.input_col_descs,
89  ra_exe_unit.simple_quals,
90  ra_exe_unit.quals,
91  ra_exe_unit.join_quals,
92  {},
93  {},
94  range > g_large_ndv_threshold
95  ? makeExpr<Analyzer::LargeNDVEstimator>(ra_exe_unit.groupby_exprs)
96  : makeExpr<Analyzer::NDVEstimator>(ra_exe_unit.groupby_exprs),
98  0,
99  false,
100  ra_exe_unit.union_all,
101  ra_exe_unit.query_state};
102 }
int64_t g_large_ndv_threshold
const std::optional< bool > union_all
std::vector< InputDescriptor > input_descs
const std::list< std::shared_ptr< Analyzer::Expr > > groupby_exprs
const JoinQualsPerNestingLevel join_quals
std::list< std::shared_ptr< Analyzer::Expr > > quals
std::shared_ptr< const query_state::QueryState > query_state
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 122 of file CardinalityEstimator.cpp.

References CHECK, and RelAlgExecutionUnit::estimator.

Referenced by Analyzer::LargeNDVEstimator::LargeNDVEstimator(), and Executor::reduceMultiDeviceResults().

124  {
125  if (results_per_device.empty()) {
126  return nullptr;
127  }
128  CHECK(dynamic_cast<const Analyzer::NDVEstimator*>(ra_exe_unit.estimator.get()));
129  const auto& result_set = results_per_device.front().first;
130  CHECK(result_set);
131  auto estimator_buffer = result_set->getHostEstimatorBuffer();
132  CHECK(estimator_buffer);
133  for (size_t i = 1; i < results_per_device.size(); ++i) {
134  const auto& next_result_set = results_per_device[i].first;
135  const auto other_estimator_buffer = next_result_set->getHostEstimatorBuffer();
136  for (size_t off = 0; off < ra_exe_unit.estimator->getBufferSize(); ++off) {
137  estimator_buffer[off] |= other_estimator_buffer[off];
138  }
139  }
140  return std::move(result_set);
141 }
const std::shared_ptr< Analyzer::Estimator > estimator
#define CHECK(condition)
Definition: Logger.h:197
+ Here is the caller graph for this function: