OmniSciDB  6686921089
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CardinalityEstimator.cpp File Reference
#include "CardinalityEstimator.h"
#include "ErrorHandling.h"
#include "ExpressionRewrite.h"
#include "RelAlgExecutor.h"
+ Include dependency graph for CardinalityEstimator.cpp:

Go to the source code of this file.

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)
 

Variables

int64_t g_large_ndv_threshold = 10000000
 
size_t g_large_ndv_multiplier = 256
 

Function Documentation

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

Definition at line 117 of file CardinalityEstimator.cpp.

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

Referenced by RelAlgExecutor::getFilteredCountAll().

119  {
120  return {ra_exe_unit.input_descs,
121  ra_exe_unit.input_col_descs,
122  ra_exe_unit.simple_quals,
123  strip_join_covered_filter_quals(ra_exe_unit.quals, ra_exe_unit.join_quals),
124  ra_exe_unit.join_quals,
125  {},
126  {replacement_target.get()},
127  nullptr,
128  SortInfo{{}, SortAlgorithm::Default, 0, 0},
129  0,
130  ra_exe_unit.query_hint,
131  ra_exe_unit.query_plan_dag,
132  ra_exe_unit.hash_table_build_plan_dag,
133  ra_exe_unit.table_id_to_node_map,
134  false,
135  ra_exe_unit.union_all,
136  ra_exe_unit.query_state};
137 }
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
TableIdToNodeMap table_id_to_node_map
std::list< std::shared_ptr< Analyzer::Expr > > quals
RegisteredQueryHint query_hint
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
HashTableBuildDagMap hash_table_build_plan_dag

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RelAlgExecutionUnit create_ndv_execution_unit ( const RelAlgExecutionUnit ra_exe_unit,
const int64_t  range 
)

Definition at line 92 of file CardinalityEstimator.cpp.

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

Referenced by RelAlgExecutor::getNDVEstimation().

93  {
94  const bool use_large_estimator =
95  range > g_large_ndv_threshold || ra_exe_unit.groupby_exprs.size() > 1;
96  return {ra_exe_unit.input_descs,
97  ra_exe_unit.input_col_descs,
98  ra_exe_unit.simple_quals,
99  ra_exe_unit.quals,
100  ra_exe_unit.join_quals,
101  {},
102  {},
103  use_large_estimator
104  ? makeExpr<Analyzer::LargeNDVEstimator>(ra_exe_unit.groupby_exprs)
105  : makeExpr<Analyzer::NDVEstimator>(ra_exe_unit.groupby_exprs),
106  SortInfo{{}, SortAlgorithm::Default, 0, 0},
107  0,
108  ra_exe_unit.query_hint,
109  ra_exe_unit.query_plan_dag,
110  ra_exe_unit.hash_table_build_plan_dag,
111  ra_exe_unit.table_id_to_node_map,
112  false,
113  ra_exe_unit.union_all,
114  ra_exe_unit.query_state};
115 }
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
TableIdToNodeMap table_id_to_node_map
std::list< std::shared_ptr< Analyzer::Expr > > quals
RegisteredQueryHint query_hint
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
HashTableBuildDagMap hash_table_build_plan_dag

+ Here is the caller graph for this function:

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

Definition at line 139 of file CardinalityEstimator.cpp.

References CHECK, RelAlgExecutionUnit::estimator, and i.

Referenced by Executor::reduceMultiDeviceResults().

141  {
142  if (results_per_device.empty()) {
143  return nullptr;
144  }
145  CHECK(dynamic_cast<const Analyzer::NDVEstimator*>(ra_exe_unit.estimator.get()));
146  const auto& result_set = results_per_device.front().first;
147  CHECK(result_set);
148  auto estimator_buffer = result_set->getHostEstimatorBuffer();
149  CHECK(estimator_buffer);
150  for (size_t i = 1; i < results_per_device.size(); ++i) {
151  const auto& next_result_set = results_per_device[i].first;
152  const auto other_estimator_buffer = next_result_set->getHostEstimatorBuffer();
153  for (size_t off = 0; off < ra_exe_unit.estimator->getBufferSize(); ++off) {
154  estimator_buffer[off] |= other_estimator_buffer[off];
155  }
156  }
157  return std::move(result_set);
158 }
const std::shared_ptr< Analyzer::Estimator > estimator
#define CHECK(condition)
Definition: Logger.h:209

+ Here is the caller graph for this function:

Variable Documentation

size_t g_large_ndv_multiplier = 256
int64_t g_large_ndv_threshold = 10000000