OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
anonymous_namespace{Execute.cpp} Namespace Reference

Classes

struct  GetTargetInfo
 
class  OutVecOwner
 

Functions

void prepare_string_dictionaries (const std::unordered_set< PhysicalInput > &phys_inputs)
 
bool is_empty_table (Fragmenter_Namespace::AbstractFragmenter *fragmenter)
 
void log_system_memory_info_impl (std::string const &mem_log, size_t executor_id, size_t log_time_ms, std::string const &log_tag, size_t const thread_idx)
 
size_t get_col_byte_width (const shared::ColumnKey &column_key)
 
ResultSetPtr get_merged_result (std::vector< std::pair< ResultSetPtr, std::vector< size_t >>> &results_per_device, std::vector< TargetInfo > const &targets)
 
ReductionCode get_reduction_code (const size_t executor_id, std::vector< std::pair< ResultSetPtr, std::vector< size_t >>> &results_per_device, int64_t *compilation_queue_time)
 
size_t compute_buffer_entry_guess (const std::vector< InputTableInfo > &query_infos, const RelAlgExecutionUnit &ra_exe_unit)
 
std::string get_table_name (const InputDescriptor &input_desc)
 
size_t getDeviceBasedWatchdogScanLimit (size_t watchdog_max_projected_rows_per_device, const ExecutorDeviceType device_type, const int device_count)
 
void checkWorkUnitWatchdog (const RelAlgExecutionUnit &ra_exe_unit, const std::vector< InputTableInfo > &table_infos, const ExecutorDeviceType device_type, const int device_count)
 
template<typename T >
std::vector< std::string > expr_container_to_string (const T &expr_container)
 
template<>
std::vector< std::string > expr_container_to_string (const std::list< Analyzer::OrderEntry > &expr_container)
 
std::string sort_algorithm_to_string (const SortAlgorithm algorithm)
 
RelAlgExecutionUnit replace_scan_limit (const RelAlgExecutionUnit &ra_exe_unit_in, const size_t new_scan_limit)
 
int64_t inline_null_val (const SQLTypeInfo &ti, const bool float_argument_input)
 
void fill_entries_for_empty_input (std::vector< TargetInfo > &target_infos, std::vector< int64_t > &entry, const std::vector< Analyzer::Expr * > &target_exprs, const QueryMemoryDescriptor &query_mem_desc)
 
ResultSetPtr build_row_for_empty_input (const std::vector< Analyzer::Expr * > &target_exprs_in, const QueryMemoryDescriptor &query_mem_desc, const ExecutorDeviceType device_type)
 
size_t permute_storage_columnar (const ResultSetStorage *input_storage, const QueryMemoryDescriptor &input_query_mem_desc, const ResultSetStorage *output_storage, size_t output_row_index, const QueryMemoryDescriptor &output_query_mem_desc, const std::vector< uint32_t > &top_permutation)
 
size_t permute_storage_row_wise (const ResultSetStorage *input_storage, const ResultSetStorage *output_storage, size_t output_row_index, const QueryMemoryDescriptor &output_query_mem_desc, const std::vector< uint32_t > &top_permutation)
 
bool has_lazy_fetched_columns (const std::vector< ColumnLazyFetchInfo > &fetched_cols)
 
const ColumnDescriptortry_get_column_descriptor (const InputColDescriptor *col_desc)
 
size_t get_selected_input_descs_index (const shared::TableKey &table_key, std::vector< InputDescriptor > const &input_descs)
 
size_t get_selected_input_col_descs_index (const shared::TableKey &table_key, std::list< std::shared_ptr< InputColDescriptor const >> const &input_col_descs)
 
std::list< std::shared_ptr
< const InputColDescriptor > > 
get_selected_input_col_descs (const shared::TableKey &table_key, std::list< std::shared_ptr< InputColDescriptor const >> const &input_col_descs)
 
void set_mod_range (std::vector< int8_t const * > &frag_col_buffers, int8_t const *const ptr, size_t const local_col_id, size_t const N)
 
bool check_rows_less_than_needed (const ResultSetPtr &results, const size_t scan_limit)
 
void add_deleted_col_to_map (PlanState::DeletedColumnsMap &deleted_cols_map, const ColumnDescriptor *deleted_cd, const shared::TableKey &table_key)
 
std::tuple< bool, int64_t,
int64_t > 
get_hpt_overflow_underflow_safe_scaled_values (const int64_t chunk_min, const int64_t chunk_max, const SQLTypeInfo &lhs_type, const SQLTypeInfo &rhs_type)
 

Function Documentation

void anonymous_namespace{Execute.cpp}::add_deleted_col_to_map ( PlanState::DeletedColumnsMap deleted_cols_map,
const ColumnDescriptor deleted_cd,
const shared::TableKey table_key 
)

Definition at line 4429 of file Execute.cpp.

References CHECK, and CHECK_EQ.

Referenced by Executor::addDeletedColumn().

4431  {
4432  auto deleted_cols_it = deleted_cols_map.find(table_key);
4433  if (deleted_cols_it == deleted_cols_map.end()) {
4434  CHECK(deleted_cols_map.insert(std::make_pair(table_key, deleted_cd)).second);
4435  } else {
4436  CHECK_EQ(deleted_cd, deleted_cols_it->second);
4437  }
4438 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function:

ResultSetPtr anonymous_namespace{Execute.cpp}::build_row_for_empty_input ( const std::vector< Analyzer::Expr * > &  target_exprs_in,
const QueryMemoryDescriptor query_mem_desc,
const ExecutorDeviceType  device_type 
)

Definition at line 2641 of file Execute.cpp.

References CHECK, fill_entries_for_empty_input(), QueryMemoryDescriptor::getExecutor(), query_mem_desc, and SQLTypeInfo::set_notnull().

Referenced by Executor::collectAllDeviceResults().

2644  {
2645  std::vector<std::shared_ptr<Analyzer::Expr>> target_exprs_owned_copies;
2646  std::vector<Analyzer::Expr*> target_exprs;
2647  for (const auto target_expr : target_exprs_in) {
2648  const auto target_expr_copy =
2649  std::dynamic_pointer_cast<Analyzer::AggExpr>(target_expr->deep_copy());
2650  CHECK(target_expr_copy);
2651  auto ti = target_expr->get_type_info();
2652  ti.set_notnull(false);
2653  target_expr_copy->set_type_info(ti);
2654  if (target_expr_copy->get_arg()) {
2655  auto arg_ti = target_expr_copy->get_arg()->get_type_info();
2656  arg_ti.set_notnull(false);
2657  target_expr_copy->get_arg()->set_type_info(arg_ti);
2658  }
2659  target_exprs_owned_copies.push_back(target_expr_copy);
2660  target_exprs.push_back(target_expr_copy.get());
2661  }
2662  std::vector<TargetInfo> target_infos;
2663  std::vector<int64_t> entry;
2664  fill_entries_for_empty_input(target_infos, entry, target_exprs, query_mem_desc);
2665  const auto executor = query_mem_desc.getExecutor();
2666  CHECK(executor);
2667  auto row_set_mem_owner = executor->getRowSetMemoryOwner();
2668  CHECK(row_set_mem_owner);
2669  auto rs = std::make_shared<ResultSet>(target_infos,
2670  device_type,
2672  row_set_mem_owner,
2673  executor->blockSize(),
2674  executor->gridSize());
2675  rs->allocateStorage();
2676  rs->fillOneEntry(entry);
2677  return rs;
2678 }
void fill_entries_for_empty_input(std::vector< TargetInfo > &target_infos, std::vector< int64_t > &entry, const std::vector< Analyzer::Expr * > &target_exprs, const QueryMemoryDescriptor &query_mem_desc)
Definition: Execute.cpp:2586
#define CHECK(condition)
Definition: Logger.h:291
const Executor * getExecutor() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool anonymous_namespace{Execute.cpp}::check_rows_less_than_needed ( const ResultSetPtr results,
const size_t  scan_limit 
)

Definition at line 4021 of file Execute.cpp.

References CHECK.

Referenced by Executor::executePlanWithGroupBy().

4021  {
4022  CHECK(scan_limit);
4023  return results && results->rowCount() < scan_limit;
4024 }
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function:

void anonymous_namespace{Execute.cpp}::checkWorkUnitWatchdog ( const RelAlgExecutionUnit ra_exe_unit,
const std::vector< InputTableInfo > &  table_infos,
const ExecutorDeviceType  device_type,
const int  device_count 
)

Definition at line 1822 of file Execute.cpp.

References SortInfo::algorithm, g_watchdog_max_projected_rows_per_device, foreign_storage::get_table_name(), getDeviceBasedWatchdogScanLimit(), RelAlgExecutionUnit::groupby_exprs, RelAlgExecutionUnit::input_descs, RegisteredQueryHint::isHintRegistered(), join(), kWatchdogMaxProjectedRowsPerDevice, RelAlgExecutionUnit::query_hint, RelAlgExecutionUnit::scan_limit, RelAlgExecutionUnit::sort_info, StreamingTopN, RelAlgExecutionUnit::target_exprs, to_string(), RelAlgExecutionUnit::use_bump_allocator, VLOG, and RegisteredQueryHint::watchdog_max_projected_rows_per_device.

Referenced by Executor::createKernels().

1825  {
1826  for (const auto target_expr : ra_exe_unit.target_exprs) {
1827  if (dynamic_cast<const Analyzer::AggExpr*>(target_expr)) {
1828  return;
1829  }
1830  }
1831  size_t watchdog_max_projected_rows_per_device =
1833  if (ra_exe_unit.query_hint.isHintRegistered(
1835  watchdog_max_projected_rows_per_device =
1837  VLOG(1) << "Set the watchdog per device maximum projection limit: "
1838  << watchdog_max_projected_rows_per_device << " by a query hint";
1839  }
1840  if (!ra_exe_unit.scan_limit && table_infos.size() == 1 &&
1841  table_infos.front().info.getPhysicalNumTuples() <
1842  watchdog_max_projected_rows_per_device) {
1843  // Allow a query with no scan limit to run on small tables
1844  return;
1845  }
1846  if (ra_exe_unit.use_bump_allocator) {
1847  // Bump allocator removes the scan limit (and any knowledge of the size of the output
1848  // relative to the size of the input), so we bypass this check for now
1849  return;
1850  }
1851  if (ra_exe_unit.sort_info.algorithm != SortAlgorithm::StreamingTopN &&
1852  ra_exe_unit.groupby_exprs.size() == 1 && !ra_exe_unit.groupby_exprs.front() &&
1853  (!ra_exe_unit.scan_limit ||
1854  ra_exe_unit.scan_limit >
1856  watchdog_max_projected_rows_per_device, device_type, device_count))) {
1857  std::vector<std::string> table_names;
1858  const auto& input_descs = ra_exe_unit.input_descs;
1859  for (const auto& input_desc : input_descs) {
1860  table_names.push_back(get_table_name(input_desc));
1861  }
1862  if (!ra_exe_unit.scan_limit) {
1863  throw WatchdogException(
1864  "Projection query would require a scan without a limit on table(s): " +
1865  boost::algorithm::join(table_names, ", "));
1866  } else {
1867  throw WatchdogException(
1868  "Projection query output result set on table(s): " +
1869  boost::algorithm::join(table_names, ", ") + " would contain " +
1870  std::to_string(ra_exe_unit.scan_limit) +
1871  " rows, which is more than the current system limit of " +
1873  watchdog_max_projected_rows_per_device, device_type, device_count)));
1874  }
1875  }
1876 }
std::vector< Analyzer::Expr * > target_exprs
size_t getDeviceBasedWatchdogScanLimit(size_t watchdog_max_projected_rows_per_device, const ExecutorDeviceType device_type, const int device_count)
Definition: Execute.cpp:1812
std::string join(T const &container, std::string const &delim)
std::vector< InputDescriptor > input_descs
const std::list< std::shared_ptr< Analyzer::Expr > > groupby_exprs
SortAlgorithm algorithm
std::string to_string(char const *&&v)
size_t g_watchdog_max_projected_rows_per_device
Definition: Execute.cpp:83
size_t watchdog_max_projected_rows_per_device
Definition: QueryHint.h:336
bool isHintRegistered(const QueryHint hint) const
Definition: QueryHint.h:383
RegisteredQueryHint query_hint
#define VLOG(n)
Definition: Logger.h:388
std::string get_table_name(int32_t db_id, int32_t table_id)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t anonymous_namespace{Execute.cpp}::compute_buffer_entry_guess ( const std::vector< InputTableInfo > &  query_infos,
const RelAlgExecutionUnit ra_exe_unit 
)

Definition at line 1753 of file Execute.cpp.

References CHECK, RelAlgExecutionUnit::scan_limit, and VLOG.

Referenced by Executor::executeWorkUnitImpl().

1754  {
1755  // we can use filtered_count_all's result if available
1756  if (ra_exe_unit.scan_limit) {
1757  VLOG(1)
1758  << "Exploiting a result of filtered count query as output buffer entry count: "
1759  << ra_exe_unit.scan_limit;
1760  return ra_exe_unit.scan_limit;
1761  }
1763  using checked_size_t = boost::multiprecision::number<
1764  boost::multiprecision::cpp_int_backend<64,
1765  64,
1766  boost::multiprecision::unsigned_magnitude,
1767  boost::multiprecision::checked,
1768  void>>;
1769  checked_size_t checked_max_groups_buffer_entry_guess = 1;
1770  // Cap the rough approximation to 100M entries, it's unlikely we can do a great job for
1771  // baseline group layout with that many entries anyway.
1772  constexpr size_t max_groups_buffer_entry_guess_cap = 100000000;
1773  // Check for overflows since we're multiplying potentially big table sizes.
1774  try {
1775  for (const auto& table_info : query_infos) {
1776  CHECK(!table_info.info.fragments.empty());
1777  checked_size_t table_cardinality = 0;
1778  std::for_each(table_info.info.fragments.begin(),
1779  table_info.info.fragments.end(),
1780  [&table_cardinality](const FragmentInfo& frag_info) {
1781  table_cardinality += frag_info.getNumTuples();
1782  });
1783  checked_max_groups_buffer_entry_guess *= table_cardinality;
1784  }
1785  } catch (...) {
1786  checked_max_groups_buffer_entry_guess = max_groups_buffer_entry_guess_cap;
1787  VLOG(1) << "Detect overflow when approximating output buffer entry count, "
1788  "resetting it as "
1789  << max_groups_buffer_entry_guess_cap;
1790  }
1791  size_t max_groups_buffer_entry_guess =
1792  std::min(static_cast<size_t>(checked_max_groups_buffer_entry_guess),
1793  max_groups_buffer_entry_guess_cap);
1794  VLOG(1) << "Set an approximated output entry count as: "
1795  << max_groups_buffer_entry_guess;
1796  return max_groups_buffer_entry_guess;
1797 }
Used by Fragmenter classes to store info about each fragment - the fragment id and number of tuples(r...
Definition: Fragmenter.h:86
#define CHECK(condition)
Definition: Logger.h:291
#define VLOG(n)
Definition: Logger.h:388

+ Here is the caller graph for this function:

template<typename T >
std::vector<std::string> anonymous_namespace{Execute.cpp}::expr_container_to_string ( const T &  expr_container)

Definition at line 1898 of file Execute.cpp.

Referenced by operator<<().

1898  {
1899  std::vector<std::string> expr_strs;
1900  for (const auto& expr : expr_container) {
1901  if (!expr) {
1902  expr_strs.emplace_back("NULL");
1903  } else {
1904  expr_strs.emplace_back(expr->toString());
1905  }
1906  }
1907  return expr_strs;
1908 }

+ Here is the caller graph for this function:

template<>
std::vector<std::string> anonymous_namespace{Execute.cpp}::expr_container_to_string ( const std::list< Analyzer::OrderEntry > &  expr_container)

Definition at line 1911 of file Execute.cpp.

1912  {
1913  std::vector<std::string> expr_strs;
1914  for (const auto& expr : expr_container) {
1915  expr_strs.emplace_back(expr.toString());
1916  }
1917  return expr_strs;
1918 }
void anonymous_namespace{Execute.cpp}::fill_entries_for_empty_input ( std::vector< TargetInfo > &  target_infos,
std::vector< int64_t > &  entry,
const std::vector< Analyzer::Expr * > &  target_exprs,
const QueryMemoryDescriptor query_mem_desc 
)

Definition at line 2586 of file Execute.cpp.

References Bitmap, CHECK, g_bigint_count, g_cluster, get_target_info(), QueryMemoryDescriptor::getCountDistinctDescriptor(), QueryMemoryDescriptor::getExecutor(), inline_null_val(), takes_float_argument(), and UnorderedSet.

Referenced by build_row_for_empty_input().

2589  {
2590  for (size_t target_idx = 0; target_idx < target_exprs.size(); ++target_idx) {
2591  const auto target_expr = target_exprs[target_idx];
2592  const auto agg_info = get_target_info(target_expr, g_bigint_count);
2593  CHECK(agg_info.is_agg);
2594  target_infos.push_back(agg_info);
2595  if (g_cluster) {
2596  const auto executor = query_mem_desc.getExecutor();
2597  CHECK(executor);
2598  auto row_set_mem_owner = executor->getRowSetMemoryOwner();
2599  CHECK(row_set_mem_owner);
2600  const auto& count_distinct_desc =
2601  query_mem_desc.getCountDistinctDescriptor(target_idx);
2602  if (count_distinct_desc.impl_type_ == CountDistinctImplType::Bitmap) {
2603  CHECK(row_set_mem_owner);
2604  auto count_distinct_buffer = row_set_mem_owner->allocateCountDistinctBuffer(
2605  count_distinct_desc.bitmapPaddedSizeBytes(),
2606  /*thread_idx=*/0); // TODO: can we detect thread idx here?
2607  entry.push_back(reinterpret_cast<int64_t>(count_distinct_buffer));
2608  continue;
2609  }
2610  if (count_distinct_desc.impl_type_ == CountDistinctImplType::UnorderedSet) {
2611  auto count_distinct_set = new CountDistinctSet();
2612  CHECK(row_set_mem_owner);
2613  row_set_mem_owner->addCountDistinctSet(count_distinct_set);
2614  entry.push_back(reinterpret_cast<int64_t>(count_distinct_set));
2615  continue;
2616  }
2617  }
2618  const bool float_argument_input = takes_float_argument(agg_info);
2619  if (shared::is_any<kCOUNT, kCOUNT_IF, kAPPROX_COUNT_DISTINCT>(agg_info.agg_kind)) {
2620  entry.push_back(0);
2621  } else if (shared::is_any<kAVG>(agg_info.agg_kind)) {
2622  entry.push_back(0);
2623  entry.push_back(0);
2624  } else if (shared::is_any<kSINGLE_VALUE, kSAMPLE>(agg_info.agg_kind)) {
2625  if (agg_info.sql_type.is_geometry() && !agg_info.is_varlen_projection) {
2626  for (int i = 0; i < agg_info.sql_type.get_physical_coord_cols() * 2; i++) {
2627  entry.push_back(0);
2628  }
2629  } else if (agg_info.sql_type.is_varlen()) {
2630  entry.push_back(0);
2631  entry.push_back(0);
2632  } else {
2633  entry.push_back(inline_null_val(agg_info.sql_type, float_argument_input));
2634  }
2635  } else {
2636  entry.push_back(inline_null_val(agg_info.sql_type, float_argument_input));
2637  }
2638  }
2639 }
robin_hood::unordered_set< int64_t > CountDistinctSet
Definition: CountDistinct.h:35
bool takes_float_argument(const TargetInfo &target_info)
Definition: TargetInfo.h:106
TargetInfo get_target_info(const Analyzer::Expr *target_expr, const bool bigint_count)
Definition: TargetInfo.h:92
int64_t inline_null_val(const SQLTypeInfo &ti, const bool float_argument_input)
Definition: Execute.cpp:2571
bool g_bigint_count
const CountDistinctDescriptor & getCountDistinctDescriptor(const size_t idx) const
#define CHECK(condition)
Definition: Logger.h:291
bool g_cluster
const Executor * getExecutor() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t anonymous_namespace{Execute.cpp}::get_col_byte_width ( const shared::ColumnKey column_key)

Definition at line 766 of file Execute.cpp.

References Catalog_Namespace::get_metadata_for_column(), and shared::ColumnKey::table_id.

Referenced by Executor::getColumnByteWidthMap().

766  {
767  if (column_key.table_id < 0) {
768  // We have an intermediate results table
769 
770  // Todo(todd): Get more accurate representation of column width
771  // for intermediate tables
772  return size_t(8);
773  } else {
774  const auto cd = Catalog_Namespace::get_metadata_for_column(column_key);
775  const auto& ti = cd->columnType;
776  const auto sz = ti.get_size();
777  if (sz < 0) {
778  // for varlen types, only account for the pointer/size for each row, for now
779  if (ti.is_logical_geo_type()) {
780  // Don't count size for logical geo types, as they are
781  // backed by physical columns
782  return size_t(0);
783  } else {
784  return size_t(16);
785  }
786  } else {
787  return sz;
788  }
789  }
790 }
const ColumnDescriptor * get_metadata_for_column(const ::shared::ColumnKey &column_key)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::tuple<bool, int64_t, int64_t> anonymous_namespace{Execute.cpp}::get_hpt_overflow_underflow_safe_scaled_values ( const int64_t  chunk_min,
const int64_t  chunk_max,
const SQLTypeInfo lhs_type,
const SQLTypeInfo rhs_type 
)

Definition at line 4492 of file Execute.cpp.

References CHECK, SQLTypeInfo::get_dimension(), and DateTimeUtils::get_timestamp_precision_scale().

Referenced by Executor::skipFragment().

4496  {
4497  const int32_t ldim = lhs_type.get_dimension();
4498  const int32_t rdim = rhs_type.get_dimension();
4499  CHECK(ldim != rdim);
4500  const auto scale = DateTimeUtils::get_timestamp_precision_scale(abs(rdim - ldim));
4501  if (ldim > rdim) {
4502  // LHS type precision is more than RHS col type. No chance of overflow/underflow.
4503  return {true, chunk_min / scale, chunk_max / scale};
4504  }
4505 
4506  using checked_int64_t = boost::multiprecision::number<
4507  boost::multiprecision::cpp_int_backend<64,
4508  64,
4509  boost::multiprecision::signed_magnitude,
4510  boost::multiprecision::checked,
4511  void>>;
4512 
4513  try {
4514  auto ret =
4515  std::make_tuple(true,
4516  int64_t(checked_int64_t(chunk_min) * checked_int64_t(scale)),
4517  int64_t(checked_int64_t(chunk_max) * checked_int64_t(scale)));
4518  return ret;
4519  } catch (const std::overflow_error& e) {
4520  // noop
4521  }
4522  return std::make_tuple(false, chunk_min, chunk_max);
4523 }
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 64, 64, boost::multiprecision::signed_magnitude, boost::multiprecision::checked, void >> checked_int64_t
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:393
#define CHECK(condition)
Definition: Logger.h:291
constexpr int64_t get_timestamp_precision_scale(const int32_t dimen)
Definition: DateTimeUtils.h:51

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ResultSetPtr anonymous_namespace{Execute.cpp}::get_merged_result ( std::vector< std::pair< ResultSetPtr, std::vector< size_t >>> &  results_per_device,
std::vector< TargetInfo > const &  targets 
)

Definition at line 1510 of file Execute.cpp.

References CHECK, and result_set::first_dict_encoded_idx().

Referenced by Executor::resultsUnion().

1512  {
1513  auto& first = results_per_device.front().first;
1514  CHECK(first);
1515  auto const first_target_idx = result_set::first_dict_encoded_idx(targets);
1516  if (first_target_idx) {
1517  first->translateDictEncodedColumns(targets, *first_target_idx);
1518  }
1519  for (size_t dev_idx = 1; dev_idx < results_per_device.size(); ++dev_idx) {
1520  const auto& next = results_per_device[dev_idx].first;
1521  CHECK(next);
1522  if (first_target_idx) {
1523  next->translateDictEncodedColumns(targets, *first_target_idx);
1524  }
1525  first->append(*next);
1526  }
1527  return std::move(first);
1528 }
std::optional< size_t > first_dict_encoded_idx(std::vector< TargetInfo > const &)
Definition: ResultSet.cpp:1593
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ReductionCode anonymous_namespace{Execute.cpp}::get_reduction_code ( const size_t  executor_id,
std::vector< std::pair< ResultSetPtr, std::vector< size_t >>> &  results_per_device,
int64_t *  compilation_queue_time 
)

Definition at line 1622 of file Execute.cpp.

References ResultSetReductionJIT::codegen(), timer_start(), and timer_stop().

Referenced by Executor::reduceMultiDeviceResultSets().

1625  {
1626  auto clock_begin = timer_start();
1627  // ResultSetReductionJIT::codegen compilation-locks if new code will be generated
1628  *compilation_queue_time = timer_stop(clock_begin);
1629  const auto& this_result_set = results_per_device[0].first;
1630  ResultSetReductionJIT reduction_jit(this_result_set->getQueryMemDesc(),
1631  this_result_set->getTargetInfos(),
1632  this_result_set->getTargetInitVals(),
1633  executor_id);
1634  return reduction_jit.codegen();
1635 };
TypeR::rep timer_stop(Type clock_begin)
Definition: measure.h:48
virtual ReductionCode codegen() const
Type timer_start()
Definition: measure.h:42

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::list<std::shared_ptr<const InputColDescriptor> > anonymous_namespace{Execute.cpp}::get_selected_input_col_descs ( const shared::TableKey table_key,
std::list< std::shared_ptr< InputColDescriptor const >> const &  input_col_descs 
)

Definition at line 3582 of file Execute.cpp.

Referenced by Executor::fetchUnionChunks().

3584  {
3585  std::list<std::shared_ptr<const InputColDescriptor>> selected;
3586  for (auto const& input_col_desc : input_col_descs) {
3587  if (table_key == input_col_desc->getScanDesc().getTableKey()) {
3588  selected.push_back(input_col_desc);
3589  }
3590  }
3591  return selected;
3592 }

+ Here is the caller graph for this function:

size_t anonymous_namespace{Execute.cpp}::get_selected_input_col_descs_index ( const shared::TableKey table_key,
std::list< std::shared_ptr< InputColDescriptor const >> const &  input_col_descs 
)

Definition at line 3571 of file Execute.cpp.

Referenced by Executor::fetchUnionChunks().

3573  {
3574  auto const has_table_key = [&table_key](auto const& input_desc) {
3575  return table_key == input_desc->getScanDesc().getTableKey();
3576  };
3577  return std::distance(
3578  input_col_descs.begin(),
3579  std::find_if(input_col_descs.begin(), input_col_descs.end(), has_table_key));
3580 }

+ Here is the caller graph for this function:

size_t anonymous_namespace{Execute.cpp}::get_selected_input_descs_index ( const shared::TableKey table_key,
std::vector< InputDescriptor > const &  input_descs 
)

Definition at line 3562 of file Execute.cpp.

Referenced by Executor::fetchUnionChunks().

3563  {
3564  auto const has_table_key = [&table_key](InputDescriptor const& input_desc) {
3565  return table_key == input_desc.getTableKey();
3566  };
3567  return std::find_if(input_descs.begin(), input_descs.end(), has_table_key) -
3568  input_descs.begin();
3569 }

+ Here is the caller graph for this function:

std::string anonymous_namespace{Execute.cpp}::get_table_name ( const InputDescriptor input_desc)

Definition at line 1799 of file Execute.cpp.

References CHECK, CHECK_GT, Catalog_Namespace::get_metadata_for_table(), InputDescriptor::getSourceType(), InputDescriptor::getTableKey(), TABLE, shared::TableKey::table_id, and to_string().

1799  {
1800  const auto source_type = input_desc.getSourceType();
1801  if (source_type == InputSourceType::TABLE) {
1802  const auto& table_key = input_desc.getTableKey();
1803  CHECK_GT(table_key.table_id, 0);
1804  const auto td = Catalog_Namespace::get_metadata_for_table(table_key);
1805  CHECK(td);
1806  return td->tableName;
1807  } else {
1808  return "$TEMPORARY_TABLE" + std::to_string(-input_desc.getTableKey().table_id);
1809  }
1810 }
const TableDescriptor * get_metadata_for_table(const ::shared::TableKey &table_key, bool populate_fragmenter)
#define CHECK_GT(x, y)
Definition: Logger.h:305
std::string to_string(char const *&&v)
const shared::TableKey & getTableKey() const
InputSourceType getSourceType() const
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

size_t anonymous_namespace{Execute.cpp}::getDeviceBasedWatchdogScanLimit ( size_t  watchdog_max_projected_rows_per_device,
const ExecutorDeviceType  device_type,
const int  device_count 
)
inline

Definition at line 1812 of file Execute.cpp.

References GPU.

Referenced by checkWorkUnitWatchdog().

1815  {
1816  if (device_type == ExecutorDeviceType::GPU) {
1817  return device_count * watchdog_max_projected_rows_per_device;
1818  }
1819  return watchdog_max_projected_rows_per_device;
1820 }

+ Here is the caller graph for this function:

bool anonymous_namespace{Execute.cpp}::has_lazy_fetched_columns ( const std::vector< ColumnLazyFetchInfo > &  fetched_cols)

Definition at line 2863 of file Execute.cpp.

Referenced by Executor::createKernels().

2863  {
2864  for (const auto& col : fetched_cols) {
2865  if (col.is_lazily_fetched) {
2866  return true;
2867  }
2868  }
2869  return false;
2870 }

+ Here is the caller graph for this function:

int64_t anonymous_namespace{Execute.cpp}::inline_null_val ( const SQLTypeInfo ti,
const bool  float_argument_input 
)

Definition at line 2571 of file Execute.cpp.

References CHECK, SQLTypeInfo::get_type(), inline_fp_null_val(), inline_int_null_val(), SQLTypeInfo::is_boolean(), SQLTypeInfo::is_fp(), SQLTypeInfo::is_number(), SQLTypeInfo::is_string(), SQLTypeInfo::is_time(), and kFLOAT.

Referenced by fill_entries_for_empty_input().

2571  {
2572  CHECK(ti.is_number() || ti.is_time() || ti.is_boolean() || ti.is_string());
2573  if (ti.is_fp()) {
2574  if (float_argument_input && ti.get_type() == kFLOAT) {
2575  int64_t float_null_val = 0;
2576  *reinterpret_cast<float*>(may_alias_ptr(&float_null_val)) =
2577  static_cast<float>(inline_fp_null_val(ti));
2578  return float_null_val;
2579  }
2580  const auto double_null_val = inline_fp_null_val(ti);
2581  return *reinterpret_cast<const int64_t*>(may_alias_ptr(&double_null_val));
2582  }
2583  return inline_int_null_val(ti);
2584 }
bool is_fp() const
Definition: sqltypes.h:571
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:391
bool is_number() const
Definition: sqltypes.h:574
double inline_fp_null_val(const SQL_TYPE_INFO &ti)
bool is_time() const
Definition: sqltypes.h:577
bool is_boolean() const
Definition: sqltypes.h:580
#define CHECK(condition)
Definition: Logger.h:291
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
bool is_string() const
Definition: sqltypes.h:559

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool anonymous_namespace{Execute.cpp}::is_empty_table ( Fragmenter_Namespace::AbstractFragmenter fragmenter)

Definition at line 223 of file Execute.cpp.

Referenced by foreign_storage::populate_string_dictionary().

223  {
224  const auto& fragments = fragmenter->getFragmentsForQuery().fragments;
225  // The fragmenter always returns at least one fragment, even when the table is empty.
226  return (fragments.size() == 1 && fragments[0].getChunkMetadataMap().empty());
227 }
std::vector< FragmentInfo > fragments
Definition: Fragmenter.h:171
virtual TableInfo getFragmentsForQuery()=0
Get all fragments for the current table.

+ Here is the caller graph for this function:

void anonymous_namespace{Execute.cpp}::log_system_memory_info_impl ( std::string const &  mem_log,
size_t  executor_id,
size_t  log_time_ms,
std::string const &  log_tag,
size_t const  thread_idx 
)

Definition at line 727 of file Execute.cpp.

References VLOG.

Referenced by Executor::logSystemCPUMemoryStatus(), and Executor::logSystemGPUMemoryStatus().

731  {
732  std::ostringstream oss;
733  oss << mem_log;
734  oss << " (" << log_tag << ", EXECUTOR-" << executor_id << ", THREAD-" << thread_idx
735  << ", TOOK: " << log_time_ms << " ms)";
736  VLOG(1) << oss.str();
737 }
#define VLOG(n)
Definition: Logger.h:388

+ Here is the caller graph for this function:

size_t anonymous_namespace{Execute.cpp}::permute_storage_columnar ( const ResultSetStorage input_storage,
const QueryMemoryDescriptor input_query_mem_desc,
const ResultSetStorage output_storage,
size_t  output_row_index,
const QueryMemoryDescriptor output_query_mem_desc,
const std::vector< uint32_t > &  top_permutation 
)

This functions uses the permutation indices in "top_permutation", and permutes all group columns (if any) and aggregate columns into the output storage. In columnar layout, since different columns are not consecutive in the memory, different columns are copied back into the output storage separetely and through different memcpy operations.

output_row_index contains the current index of the output storage (input storage will be appended to it), and the final output row index is returned.

Definition at line 2726 of file Execute.cpp.

References QueryMemoryDescriptor::getColOffInBytes(), QueryMemoryDescriptor::getKeyCount(), QueryMemoryDescriptor::getPaddedSlotWidthBytes(), QueryMemoryDescriptor::getPrependedGroupColOffInBytes(), QueryMemoryDescriptor::getSlotCount(), ResultSetStorage::getUnderlyingBuffer(), and QueryMemoryDescriptor::groupColWidth().

Referenced by Executor::collectAllDeviceShardedTopResults().

2731  {
2732  const auto output_buffer = output_storage->getUnderlyingBuffer();
2733  const auto input_buffer = input_storage->getUnderlyingBuffer();
2734  for (const auto sorted_idx : top_permutation) {
2735  // permuting all group-columns in this result set into the final buffer:
2736  for (size_t group_idx = 0; group_idx < input_query_mem_desc.getKeyCount();
2737  group_idx++) {
2738  const auto input_column_ptr =
2739  input_buffer + input_query_mem_desc.getPrependedGroupColOffInBytes(group_idx) +
2740  sorted_idx * input_query_mem_desc.groupColWidth(group_idx);
2741  const auto output_column_ptr =
2742  output_buffer +
2743  output_query_mem_desc.getPrependedGroupColOffInBytes(group_idx) +
2744  output_row_index * output_query_mem_desc.groupColWidth(group_idx);
2745  memcpy(output_column_ptr,
2746  input_column_ptr,
2747  output_query_mem_desc.groupColWidth(group_idx));
2748  }
2749  // permuting all agg-columns in this result set into the final buffer:
2750  for (size_t slot_idx = 0; slot_idx < input_query_mem_desc.getSlotCount();
2751  slot_idx++) {
2752  const auto input_column_ptr =
2753  input_buffer + input_query_mem_desc.getColOffInBytes(slot_idx) +
2754  sorted_idx * input_query_mem_desc.getPaddedSlotWidthBytes(slot_idx);
2755  const auto output_column_ptr =
2756  output_buffer + output_query_mem_desc.getColOffInBytes(slot_idx) +
2757  output_row_index * output_query_mem_desc.getPaddedSlotWidthBytes(slot_idx);
2758  memcpy(output_column_ptr,
2759  input_column_ptr,
2760  output_query_mem_desc.getPaddedSlotWidthBytes(slot_idx));
2761  }
2762  ++output_row_index;
2763  }
2764  return output_row_index;
2765 }
int8_t * getUnderlyingBuffer() const
int8_t groupColWidth(const size_t key_idx) const
const int8_t getPaddedSlotWidthBytes(const size_t slot_idx) const
size_t getColOffInBytes(const size_t col_idx) const
size_t getPrependedGroupColOffInBytes(const size_t group_idx) const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t anonymous_namespace{Execute.cpp}::permute_storage_row_wise ( const ResultSetStorage input_storage,
const ResultSetStorage output_storage,
size_t  output_row_index,
const QueryMemoryDescriptor output_query_mem_desc,
const std::vector< uint32_t > &  top_permutation 
)

This functions uses the permutation indices in "top_permutation", and permutes all group columns (if any) and aggregate columns into the output storage. In row-wise, since different columns are consecutive within the memory, it suffices to perform a single memcpy operation and copy the whole row.

output_row_index contains the current index of the output storage (input storage will be appended to it), and the final output row index is returned.

Definition at line 2776 of file Execute.cpp.

References QueryMemoryDescriptor::getRowSize(), and ResultSetStorage::getUnderlyingBuffer().

Referenced by Executor::collectAllDeviceShardedTopResults().

2780  {
2781  const auto output_buffer = output_storage->getUnderlyingBuffer();
2782  const auto input_buffer = input_storage->getUnderlyingBuffer();
2783  for (const auto sorted_idx : top_permutation) {
2784  const auto row_ptr = input_buffer + sorted_idx * output_query_mem_desc.getRowSize();
2785  memcpy(output_buffer + output_row_index * output_query_mem_desc.getRowSize(),
2786  row_ptr,
2787  output_query_mem_desc.getRowSize());
2788  ++output_row_index;
2789  }
2790  return output_row_index;
2791 }
int8_t * getUnderlyingBuffer() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void anonymous_namespace{Execute.cpp}::prepare_string_dictionaries ( const std::unordered_set< PhysicalInput > &  phys_inputs)

Definition at line 217 of file Execute.cpp.

Referenced by Executor::computeStringDictionaryGenerations(), and anonymous_namespace{RelAlgExecutor.cpp}::prepare_foreign_table_for_execution().

217  {
218  for (const auto [col_id, table_id, db_id] : phys_inputs) {
219  foreign_storage::populate_string_dictionary(table_id, col_id, db_id);
220  }
221 }
void populate_string_dictionary(int32_t table_id, int32_t col_id, int32_t db_id)
Definition: Execute.cpp:233

+ Here is the caller graph for this function:

RelAlgExecutionUnit anonymous_namespace{Execute.cpp}::replace_scan_limit ( const RelAlgExecutionUnit ra_exe_unit_in,
const size_t  new_scan_limit 
)

Definition at line 2050 of file Execute.cpp.

References RelAlgExecutionUnit::estimator, 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_hash, RelAlgExecutionUnit::query_state, RelAlgExecutionUnit::simple_quals, RelAlgExecutionUnit::sort_info, RelAlgExecutionUnit::table_id_to_node_map, RelAlgExecutionUnit::target_exprs, RelAlgExecutionUnit::target_exprs_original_type_infos, RelAlgExecutionUnit::union_all, and RelAlgExecutionUnit::use_bump_allocator.

Referenced by Executor::executeWorkUnit().

2051  {
2052  return {ra_exe_unit_in.input_descs,
2053  ra_exe_unit_in.input_col_descs,
2054  ra_exe_unit_in.simple_quals,
2055  ra_exe_unit_in.quals,
2056  ra_exe_unit_in.join_quals,
2057  ra_exe_unit_in.groupby_exprs,
2058  ra_exe_unit_in.target_exprs,
2059  ra_exe_unit_in.target_exprs_original_type_infos,
2060  ra_exe_unit_in.estimator,
2061  ra_exe_unit_in.sort_info,
2062  new_scan_limit,
2063  ra_exe_unit_in.query_hint,
2064  ra_exe_unit_in.query_plan_dag_hash,
2065  ra_exe_unit_in.hash_table_build_plan_dag,
2066  ra_exe_unit_in.table_id_to_node_map,
2067  ra_exe_unit_in.use_bump_allocator,
2068  ra_exe_unit_in.union_all,
2069  ra_exe_unit_in.query_state};
2070 }
std::vector< Analyzer::Expr * > target_exprs
QueryPlanHash query_plan_dag_hash
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
const std::shared_ptr< Analyzer::Estimator > estimator
std::unordered_map< size_t, SQLTypeInfo > target_exprs_original_type_infos
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:

void anonymous_namespace{Execute.cpp}::set_mod_range ( std::vector< int8_t const * > &  frag_col_buffers,
int8_t const *const  ptr,
size_t const  local_col_id,
size_t const  N 
)

Definition at line 3595 of file Execute.cpp.

References CHECK_LE, and anonymous_namespace{Utm.h}::N.

Referenced by Executor::fetchUnionChunks().

3598  {
3599  size_t const begin = local_col_id - local_col_id % N; // N divides begin
3600  size_t const end = begin + N;
3601  CHECK_LE(end, frag_col_buffers.size()) << (void*)ptr << ' ' << local_col_id << ' ' << N;
3602  for (size_t i = begin; i < end; ++i) {
3603  frag_col_buffers[i] = ptr;
3604  }
3605 }
#define CHECK_LE(x, y)
Definition: Logger.h:304
constexpr unsigned N
Definition: Utm.h:110

+ Here is the caller graph for this function:

std::string anonymous_namespace{Execute.cpp}::sort_algorithm_to_string ( const SortAlgorithm  algorithm)

Definition at line 1920 of file Execute.cpp.

References Default, SpeculativeTopN, StreamingTopN, and UNREACHABLE.

Referenced by operator<<().

1920  {
1921  switch (algorithm) {
1923  return "ResultSet";
1925  return "Speculative Top N";
1927  return "Streaming Top N";
1928  }
1929  UNREACHABLE();
1930  return "";
1931 }
#define UNREACHABLE()
Definition: Logger.h:338

+ Here is the caller graph for this function:

const ColumnDescriptor* anonymous_namespace{Execute.cpp}::try_get_column_descriptor ( const InputColDescriptor col_desc)

Definition at line 3308 of file Execute.cpp.

References get_column_descriptor_maybe(), InputColDescriptor::getColId(), InputColDescriptor::getScanDesc(), and InputDescriptor::getTableKey().

Referenced by Executor::fetchChunks(), and Executor::fetchUnionChunks().

3308  {
3309  const auto& table_key = col_desc->getScanDesc().getTableKey();
3310  const auto col_id = col_desc->getColId();
3311  return get_column_descriptor_maybe({table_key, col_id});
3312 }
const ColumnDescriptor * get_column_descriptor_maybe(const shared::ColumnKey &column_key)
Definition: Execute.h:241
int getColId() const
const shared::TableKey & getTableKey() const
const InputDescriptor & getScanDesc() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function: