OmniSciDB  dfae7c3b14
anonymous_namespace{Execute.cpp} Namespace Reference

Classes

class  OutVecOwner
 

Functions

ResultSetPtr get_merged_result (std::vector< std::pair< ResultSetPtr, std::vector< size_t >>> &results_per_device)
 
ReductionCode get_reduction_code (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)
 
std::string get_table_name (const InputDescriptor &input_desc, const Catalog_Namespace::Catalog &cat)
 
size_t getDeviceBasedScanLimit (const ExecutorDeviceType device_type, const int device_count)
 
void checkWorkUnitWatchdog (const RelAlgExecutionUnit &ra_exe_unit, const std::vector< InputTableInfo > &table_infos, const Catalog_Namespace::Catalog &cat, 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 join_type_to_string (const JoinType type)
 
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, const Catalog_Namespace::Catalog &cat)
 
bool check_rows_less_than_needed (const ResultSetPtr &results, const size_t scan_limit)
 
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

◆ build_row_for_empty_input()

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 1713 of file Execute.cpp.

References CHECK, fill_entries_for_empty_input(), and QueryMemoryDescriptor::getExecutor().

Referenced by Executor::collectAllDeviceResults().

1716  {
1717  std::vector<std::shared_ptr<Analyzer::Expr>> target_exprs_owned_copies;
1718  std::vector<Analyzer::Expr*> target_exprs;
1719  for (const auto target_expr : target_exprs_in) {
1720  const auto target_expr_copy =
1721  std::dynamic_pointer_cast<Analyzer::AggExpr>(target_expr->deep_copy());
1722  CHECK(target_expr_copy);
1723  auto ti = target_expr->get_type_info();
1724  ti.set_notnull(false);
1725  target_expr_copy->set_type_info(ti);
1726  if (target_expr_copy->get_arg()) {
1727  auto arg_ti = target_expr_copy->get_arg()->get_type_info();
1728  arg_ti.set_notnull(false);
1729  target_expr_copy->get_arg()->set_type_info(arg_ti);
1730  }
1731  target_exprs_owned_copies.push_back(target_expr_copy);
1732  target_exprs.push_back(target_expr_copy.get());
1733  }
1734  std::vector<TargetInfo> target_infos;
1735  std::vector<int64_t> entry;
1736  fill_entries_for_empty_input(target_infos, entry, target_exprs, query_mem_desc);
1737  const auto executor = query_mem_desc.getExecutor();
1738  CHECK(executor);
1739  auto row_set_mem_owner = executor->getRowSetMemoryOwner();
1740  CHECK(row_set_mem_owner);
1741  auto rs = std::make_shared<ResultSet>(
1742  target_infos, device_type, query_mem_desc, row_set_mem_owner, executor);
1743  rs->allocateStorage();
1744  rs->fillOneEntry(entry);
1745  return rs;
1746 }
const Executor * getExecutor() const
#define CHECK(condition)
Definition: Logger.h:197
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:1659
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ check_rows_less_than_needed()

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

Definition at line 2841 of file Execute.cpp.

References CHECK.

Referenced by Executor::executePlanWithGroupBy().

2841  {
2842  CHECK(scan_limit);
2843  return results && results->rowCount() < scan_limit;
2844 }
#define CHECK(condition)
Definition: Logger.h:197
+ Here is the caller graph for this function:

◆ checkWorkUnitWatchdog()

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

Definition at line 1070 of file Execute.cpp.

References SortInfo::algorithm, get_table_name(), getDeviceBasedScanLimit(), RelAlgExecutionUnit::groupby_exprs, Executor::high_scan_limit, RelAlgExecutionUnit::input_descs, join(), RelAlgExecutionUnit::scan_limit, RelAlgExecutionUnit::sort_info, StreamingTopN, RelAlgExecutionUnit::target_exprs, to_string(), and RelAlgExecutionUnit::use_bump_allocator.

Referenced by Executor::createKernels().

1074  {
1075  for (const auto target_expr : ra_exe_unit.target_exprs) {
1076  if (dynamic_cast<const Analyzer::AggExpr*>(target_expr)) {
1077  return;
1078  }
1079  }
1080  if (!ra_exe_unit.scan_limit && table_infos.size() == 1 &&
1081  table_infos.front().info.getPhysicalNumTuples() < Executor::high_scan_limit) {
1082  // Allow a query with no scan limit to run on small tables
1083  return;
1084  }
1085  if (ra_exe_unit.use_bump_allocator) {
1086  // Bump allocator removes the scan limit (and any knowledge of the size of the output
1087  // relative to the size of the input), so we bypass this check for now
1088  return;
1089  }
1090  if (ra_exe_unit.sort_info.algorithm != SortAlgorithm::StreamingTopN &&
1091  ra_exe_unit.groupby_exprs.size() == 1 && !ra_exe_unit.groupby_exprs.front() &&
1092  (!ra_exe_unit.scan_limit ||
1093  ra_exe_unit.scan_limit > getDeviceBasedScanLimit(device_type, device_count))) {
1094  std::vector<std::string> table_names;
1095  const auto& input_descs = ra_exe_unit.input_descs;
1096  for (const auto& input_desc : input_descs) {
1097  table_names.push_back(get_table_name(input_desc, cat));
1098  }
1099  if (!ra_exe_unit.scan_limit) {
1100  throw WatchdogException(
1101  "Projection query would require a scan without a limit on table(s): " +
1102  boost::algorithm::join(table_names, ", "));
1103  } else {
1104  throw WatchdogException(
1105  "Projection query output result set on table(s): " +
1106  boost::algorithm::join(table_names, ", ") + " would contain " +
1107  std::to_string(ra_exe_unit.scan_limit) +
1108  " rows, which is more than the current system limit of " +
1109  std::to_string(getDeviceBasedScanLimit(device_type, device_count)));
1110  }
1111  }
1112 }
std::vector< Analyzer::Expr * > target_exprs
std::string get_table_name(const InputDescriptor &input_desc, const Catalog_Namespace::Catalog &cat)
Definition: Execute.cpp:1050
std::string join(T const &container, std::string const &delim)
std::vector< InputDescriptor > input_descs
const SortAlgorithm algorithm
const std::list< std::shared_ptr< Analyzer::Expr > > groupby_exprs
std::string to_string(char const *&&v)
static const size_t high_scan_limit
Definition: Execute.h:408
const SortInfo sort_info
size_t getDeviceBasedScanLimit(const ExecutorDeviceType device_type, const int device_count)
Definition: Execute.cpp:1062
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compute_buffer_entry_guess()

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

Definition at line 1020 of file Execute.cpp.

References CHECK.

Referenced by Executor::executeWorkUnitImpl().

1020  {
1022  // Check for overflows since we're multiplying potentially big table sizes.
1023  using checked_size_t = boost::multiprecision::number<
1024  boost::multiprecision::cpp_int_backend<64,
1025  64,
1026  boost::multiprecision::unsigned_magnitude,
1027  boost::multiprecision::checked,
1028  void>>;
1029  checked_size_t max_groups_buffer_entry_guess = 1;
1030  for (const auto& query_info : query_infos) {
1031  CHECK(!query_info.info.fragments.empty());
1032  auto it = std::max_element(query_info.info.fragments.begin(),
1033  query_info.info.fragments.end(),
1034  [](const FragmentInfo& f1, const FragmentInfo& f2) {
1035  return f1.getNumTuples() < f2.getNumTuples();
1036  });
1037  max_groups_buffer_entry_guess *= it->getNumTuples();
1038  }
1039  // Cap the rough approximation to 100M entries, it's unlikely we can do a great job for
1040  // baseline group layout with that many entries anyway.
1041  constexpr size_t max_groups_buffer_entry_guess_cap = 100000000;
1042  try {
1043  return std::min(static_cast<size_t>(max_groups_buffer_entry_guess),
1044  max_groups_buffer_entry_guess_cap);
1045  } catch (...) {
1046  return max_groups_buffer_entry_guess_cap;
1047  }
1048 }
Used by Fragmenter classes to store info about each fragment - the fragment id and number of tuples(r...
Definition: Fragmenter.h:78
#define CHECK(condition)
Definition: Logger.h:197
+ Here is the caller graph for this function:

◆ expr_container_to_string() [1/2]

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

Definition at line 1141 of file Execute.cpp.

1141  {
1142  std::vector<std::string> expr_strs;
1143  for (const auto& expr : expr_container) {
1144  if (!expr) {
1145  expr_strs.emplace_back("NULL");
1146  } else {
1147  expr_strs.emplace_back(expr->toString());
1148  }
1149  }
1150  return expr_strs;
1151 }

◆ expr_container_to_string() [2/2]

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

Definition at line 1154 of file Execute.cpp.

Referenced by operator<<().

1155  {
1156  std::vector<std::string> expr_strs;
1157  for (const auto& expr : expr_container) {
1158  expr_strs.emplace_back(expr.toString());
1159  }
1160  return expr_strs;
1161 }
+ Here is the caller graph for this function:

◆ fill_entries_for_empty_input()

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 1659 of file Execute.cpp.

References Bitmap, CHECK, g_bigint_count, g_cluster, get_target_info(), QueryMemoryDescriptor::getCountDistinctDescriptor(), QueryMemoryDescriptor::getExecutor(), inline_null_val(), kAPPROX_COUNT_DISTINCT, kAVG, kCOUNT, kSAMPLE, kSINGLE_VALUE, StdSet, and takes_float_argument().

Referenced by build_row_for_empty_input().

1662  {
1663  for (size_t target_idx = 0; target_idx < target_exprs.size(); ++target_idx) {
1664  const auto target_expr = target_exprs[target_idx];
1665  const auto agg_info = get_target_info(target_expr, g_bigint_count);
1666  CHECK(agg_info.is_agg);
1667  target_infos.push_back(agg_info);
1668  if (g_cluster) {
1669  const auto executor = query_mem_desc.getExecutor();
1670  CHECK(executor);
1671  auto row_set_mem_owner = executor->getRowSetMemoryOwner();
1672  CHECK(row_set_mem_owner);
1673  const auto& count_distinct_desc =
1674  query_mem_desc.getCountDistinctDescriptor(target_idx);
1675  if (count_distinct_desc.impl_type_ == CountDistinctImplType::Bitmap) {
1676  CHECK(row_set_mem_owner);
1677  auto count_distinct_buffer = row_set_mem_owner->allocateCountDistinctBuffer(
1678  count_distinct_desc.bitmapPaddedSizeBytes());
1679  entry.push_back(reinterpret_cast<int64_t>(count_distinct_buffer));
1680  continue;
1681  }
1682  if (count_distinct_desc.impl_type_ == CountDistinctImplType::StdSet) {
1683  auto count_distinct_set = new std::set<int64_t>();
1684  CHECK(row_set_mem_owner);
1685  row_set_mem_owner->addCountDistinctSet(count_distinct_set);
1686  entry.push_back(reinterpret_cast<int64_t>(count_distinct_set));
1687  continue;
1688  }
1689  }
1690  const bool float_argument_input = takes_float_argument(agg_info);
1691  if (agg_info.agg_kind == kCOUNT || agg_info.agg_kind == kAPPROX_COUNT_DISTINCT) {
1692  entry.push_back(0);
1693  } else if (agg_info.agg_kind == kAVG) {
1694  entry.push_back(inline_null_val(agg_info.sql_type, float_argument_input));
1695  entry.push_back(0);
1696  } else if (agg_info.agg_kind == kSINGLE_VALUE || agg_info.agg_kind == kSAMPLE) {
1697  if (agg_info.sql_type.is_geometry()) {
1698  for (int i = 0; i < agg_info.sql_type.get_physical_coord_cols() * 2; i++) {
1699  entry.push_back(0);
1700  }
1701  } else if (agg_info.sql_type.is_varlen()) {
1702  entry.push_back(0);
1703  entry.push_back(0);
1704  } else {
1705  entry.push_back(inline_null_val(agg_info.sql_type, float_argument_input));
1706  }
1707  } else {
1708  entry.push_back(inline_null_val(agg_info.sql_type, float_argument_input));
1709  }
1710  }
1711 }
TargetInfo get_target_info(const PointerType target_expr, const bool bigint_count)
Definition: TargetInfo.h:78
bool takes_float_argument(const TargetInfo &target_info)
Definition: TargetInfo.h:133
const Executor * getExecutor() const
int64_t inline_null_val(const SQLTypeInfo &ti, const bool float_argument_input)
Definition: Execute.cpp:1644
bool g_bigint_count
Definition: sqldefs.h:76
#define CHECK(condition)
Definition: Logger.h:197
bool g_cluster
const CountDistinctDescriptor & getCountDistinctDescriptor(const size_t idx) const
Definition: sqldefs.h:72
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_hpt_overflow_underflow_safe_scaled_values()

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 3243 of file Execute.cpp.

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

Referenced by Executor::skipFragment().

3247  {
3248  const int32_t ldim = lhs_type.get_dimension();
3249  const int32_t rdim = rhs_type.get_dimension();
3250  CHECK(ldim != rdim);
3251  const auto scale = DateTimeUtils::get_timestamp_precision_scale(abs(rdim - ldim));
3252  if (ldim > rdim) {
3253  // LHS type precision is more than RHS col type. No chance of overflow/underflow.
3254  return {true, chunk_min / scale, chunk_max / scale};
3255  }
3256 
3257  using checked_int64_t = boost::multiprecision::number<
3258  boost::multiprecision::cpp_int_backend<64,
3259  64,
3260  boost::multiprecision::signed_magnitude,
3261  boost::multiprecision::checked,
3262  void>>;
3263 
3264  try {
3265  auto ret =
3266  std::make_tuple(true,
3267  int64_t(checked_int64_t(chunk_min) * checked_int64_t(scale)),
3268  int64_t(checked_int64_t(chunk_max) * checked_int64_t(scale)));
3269  return ret;
3270  } catch (const std::overflow_error& e) {
3271  // noop
3272  }
3273  return std::make_tuple(false, chunk_min, chunk_max);
3274 }
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:261
#define CHECK(condition)
Definition: Logger.h:197
constexpr int64_t get_timestamp_precision_scale(const int32_t dimen)
Definition: DateTimeUtils.h:51
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 64, 64, boost::multiprecision::signed_magnitude, boost::multiprecision::checked, void > > checked_int64_t
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_merged_result()

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

Definition at line 829 of file Execute.cpp.

References CHECK.

Referenced by Executor::resultsUnion().

830  {
831  auto& first = results_per_device.front().first;
832  CHECK(first);
833  for (size_t dev_idx = 1; dev_idx < results_per_device.size(); ++dev_idx) {
834  const auto& next = results_per_device[dev_idx].first;
835  CHECK(next);
836  first->append(*next);
837  }
838  return std::move(first);
839 }
#define CHECK(condition)
Definition: Logger.h:197
+ Here is the caller graph for this function:

◆ get_reduction_code()

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

Definition at line 896 of file Execute.cpp.

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

Referenced by Executor::reduceMultiDeviceResultSets().

898  {
899  auto clock_begin = timer_start();
900  std::lock_guard<std::mutex> compilation_lock(Executor::compilation_mutex_);
901  *compilation_queue_time = timer_stop(clock_begin);
902  const auto& this_result_set = results_per_device[0].first;
903  ResultSetReductionJIT reduction_jit(this_result_set->getQueryMemDesc(),
904  this_result_set->getTargetInfos(),
905  this_result_set->getTargetInitVals());
906  return reduction_jit.codegen();
907 };
TypeR::rep timer_stop(Type clock_begin)
Definition: measure.h:48
virtual ReductionCode codegen() const
static std::mutex compilation_mutex_
Definition: Execute.h:997
Type timer_start()
Definition: measure.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_table_name()

std::string anonymous_namespace{Execute.cpp}::get_table_name ( const InputDescriptor input_desc,
const Catalog_Namespace::Catalog cat 
)

Definition at line 1050 of file Execute.cpp.

References CHECK, Catalog_Namespace::Catalog::getMetadataForTable(), InputDescriptor::getSourceType(), InputDescriptor::getTableId(), TABLE, and to_string().

Referenced by checkWorkUnitWatchdog().

1051  {
1052  const auto source_type = input_desc.getSourceType();
1053  if (source_type == InputSourceType::TABLE) {
1054  const auto td = cat.getMetadataForTable(input_desc.getTableId());
1055  CHECK(td);
1056  return td->tableName;
1057  } else {
1058  return "$TEMPORARY_TABLE" + std::to_string(-input_desc.getTableId());
1059  }
1060 }
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.
InputSourceType getSourceType() const
int getTableId() const
std::string to_string(char const *&&v)
#define CHECK(condition)
Definition: Logger.h:197
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDeviceBasedScanLimit()

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

Definition at line 1062 of file Execute.cpp.

References GPU, and Executor::high_scan_limit.

Referenced by checkWorkUnitWatchdog().

1063  {
1064  if (device_type == ExecutorDeviceType::GPU) {
1065  return device_count * Executor::high_scan_limit;
1066  }
1068 }
static const size_t high_scan_limit
Definition: Execute.h:408
+ Here is the caller graph for this function:

◆ has_lazy_fetched_columns()

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

Definition at line 1928 of file Execute.cpp.

Referenced by Executor::createKernels().

1928  {
1929  for (const auto& col : fetched_cols) {
1930  if (col.is_lazily_fetched) {
1931  return true;
1932  }
1933  }
1934  return false;
1935 }
+ Here is the caller graph for this function:

◆ inline_null_val()

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

Definition at line 1644 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().

1644  {
1645  CHECK(ti.is_number() || ti.is_time() || ti.is_boolean() || ti.is_string());
1646  if (ti.is_fp()) {
1647  if (float_argument_input && ti.get_type() == kFLOAT) {
1648  int64_t float_null_val = 0;
1649  *reinterpret_cast<float*>(may_alias_ptr(&float_null_val)) =
1650  static_cast<float>(inline_fp_null_val(ti));
1651  return float_null_val;
1652  }
1653  const auto double_null_val = inline_fp_null_val(ti);
1654  return *reinterpret_cast<const int64_t*>(may_alias_ptr(&double_null_val));
1655  }
1656  return inline_int_null_val(ti);
1657 }
bool is_time() const
Definition: sqltypes.h:423
bool is_string() const
Definition: sqltypes.h:417
bool is_boolean() const
Definition: sqltypes.h:424
double inline_fp_null_val(const SQL_TYPE_INFO &ti)
#define CHECK(condition)
Definition: Logger.h:197
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:259
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
bool is_number() const
Definition: sqltypes.h:422
bool is_fp() const
Definition: sqltypes.h:421
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ join_type_to_string()

std::string anonymous_namespace{Execute.cpp}::join_type_to_string ( const JoinType  type)

Definition at line 1163 of file Execute.cpp.

References INNER, INVALID, LEFT, and UNREACHABLE.

Referenced by operator<<(), and ra_exec_unit_desc_for_caching().

1163  {
1164  switch (type) {
1165  case JoinType::INNER:
1166  return "INNER";
1167  case JoinType::LEFT:
1168  return "LEFT";
1169  case JoinType::INVALID:
1170  return "INVALID";
1171  }
1172  UNREACHABLE();
1173  return "";
1174 }
#define UNREACHABLE()
Definition: Logger.h:241
+ Here is the caller graph for this function:

◆ permute_storage_columnar()

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 1794 of file Execute.cpp.

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

Referenced by Executor::collectAllDeviceShardedTopResults().

1799  {
1800  const auto output_buffer = output_storage->getUnderlyingBuffer();
1801  const auto input_buffer = input_storage->getUnderlyingBuffer();
1802  for (const auto sorted_idx : top_permutation) {
1803  // permuting all group-columns in this result set into the final buffer:
1804  for (size_t group_idx = 0; group_idx < input_query_mem_desc.getKeyCount();
1805  group_idx++) {
1806  const auto input_column_ptr =
1807  input_buffer + input_query_mem_desc.getPrependedGroupColOffInBytes(group_idx) +
1808  sorted_idx * input_query_mem_desc.groupColWidth(group_idx);
1809  const auto output_column_ptr =
1810  output_buffer +
1811  output_query_mem_desc.getPrependedGroupColOffInBytes(group_idx) +
1812  output_row_index * output_query_mem_desc.groupColWidth(group_idx);
1813  memcpy(output_column_ptr,
1814  input_column_ptr,
1815  output_query_mem_desc.groupColWidth(group_idx));
1816  }
1817  // permuting all agg-columns in this result set into the final buffer:
1818  for (size_t slot_idx = 0; slot_idx < input_query_mem_desc.getSlotCount();
1819  slot_idx++) {
1820  const auto input_column_ptr =
1821  input_buffer + input_query_mem_desc.getColOffInBytes(slot_idx) +
1822  sorted_idx * input_query_mem_desc.getPaddedSlotWidthBytes(slot_idx);
1823  const auto output_column_ptr =
1824  output_buffer + output_query_mem_desc.getColOffInBytes(slot_idx) +
1825  output_row_index * output_query_mem_desc.getPaddedSlotWidthBytes(slot_idx);
1826  memcpy(output_column_ptr,
1827  input_column_ptr,
1828  output_query_mem_desc.getPaddedSlotWidthBytes(slot_idx));
1829  }
1830  ++output_row_index;
1831  }
1832  return output_row_index;
1833 }
const int8_t getPaddedSlotWidthBytes(const size_t slot_idx) const
int8_t groupColWidth(const size_t key_idx) const
size_t getColOffInBytes(const size_t col_idx) const
int8_t * getUnderlyingBuffer() const
Definition: ResultSet.cpp:90
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:

◆ permute_storage_row_wise()

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 1844 of file Execute.cpp.

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

Referenced by Executor::collectAllDeviceShardedTopResults().

1848  {
1849  const auto output_buffer = output_storage->getUnderlyingBuffer();
1850  const auto input_buffer = input_storage->getUnderlyingBuffer();
1851  for (const auto sorted_idx : top_permutation) {
1852  const auto row_ptr = input_buffer + sorted_idx * output_query_mem_desc.getRowSize();
1853  memcpy(output_buffer + output_row_index * output_query_mem_desc.getRowSize(),
1854  row_ptr,
1855  output_query_mem_desc.getRowSize());
1856  ++output_row_index;
1857  }
1858  return output_row_index;
1859 }
int8_t * getUnderlyingBuffer() const
Definition: ResultSet.cpp:90
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ replace_scan_limit()

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

Definition at line 1292 of file Execute.cpp.

References RelAlgExecutionUnit::estimator, RelAlgExecutionUnit::groupby_exprs, RelAlgExecutionUnit::input_col_descs, RelAlgExecutionUnit::input_descs, RelAlgExecutionUnit::join_quals, RelAlgExecutionUnit::quals, RelAlgExecutionUnit::query_state, RelAlgExecutionUnit::simple_quals, RelAlgExecutionUnit::sort_info, RelAlgExecutionUnit::target_exprs, RelAlgExecutionUnit::union_all, and RelAlgExecutionUnit::use_bump_allocator.

Referenced by Executor::executeWorkUnit().

1293  {
1294  return {ra_exe_unit_in.input_descs,
1295  ra_exe_unit_in.input_col_descs,
1296  ra_exe_unit_in.simple_quals,
1297  ra_exe_unit_in.quals,
1298  ra_exe_unit_in.join_quals,
1299  ra_exe_unit_in.groupby_exprs,
1300  ra_exe_unit_in.target_exprs,
1301  ra_exe_unit_in.estimator,
1302  ra_exe_unit_in.sort_info,
1303  new_scan_limit,
1304  ra_exe_unit_in.use_bump_allocator,
1305  ra_exe_unit_in.union_all,
1306  ra_exe_unit_in.query_state};
1307 }
std::vector< Analyzer::Expr * > target_exprs
const std::optional< bool > union_all
std::vector< InputDescriptor > input_descs
const std::list< std::shared_ptr< Analyzer::Expr > > groupby_exprs
const SortInfo sort_info
const JoinQualsPerNestingLevel join_quals
const std::shared_ptr< Analyzer::Estimator > estimator
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:

◆ sort_algorithm_to_string()

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

Definition at line 1176 of file Execute.cpp.

References Default, SpeculativeTopN, StreamingTopN, and UNREACHABLE.

Referenced by operator<<().

1176  {
1177  switch (algorithm) {
1179  return "ResultSet";
1181  return "Speculative Top N";
1183  return "Streaming Top N";
1184  }
1185  UNREACHABLE();
1186  return "";
1187 }
#define UNREACHABLE()
Definition: Logger.h:241
+ Here is the caller graph for this function:

◆ try_get_column_descriptor()

const ColumnDescriptor* anonymous_namespace{Execute.cpp}::try_get_column_descriptor ( const InputColDescriptor col_desc,
const Catalog_Namespace::Catalog cat 
)

Definition at line 2199 of file Execute.cpp.

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

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

2200  {
2201  const int table_id = col_desc->getScanDesc().getTableId();
2202  const int col_id = col_desc->getColId();
2203  return get_column_descriptor_maybe(col_id, table_id, cat);
2204 }
int getTableId() const
const InputDescriptor & getScanDesc() const
const ColumnDescriptor * get_column_descriptor_maybe(const int col_id, const int table_id, const Catalog_Namespace::Catalog &cat)
Definition: Execute.h:183
+ Here is the call graph for this function:
+ Here is the caller graph for this function: