OmniSciDB  addbbd5075
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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)
 
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)
 
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)
 
template<class T >
int64_t insert_one_dict_str (T *col_data, const std::string &columnName, const SQLTypeInfo &columnType, const Analyzer::Constant *col_cv, const Catalog_Namespace::Catalog &catalog)
 
template<class T >
int64_t insert_one_dict_str (T *col_data, const ColumnDescriptor *cd, const Analyzer::Constant *col_cv, const Catalog_Namespace::Catalog &catalog)
 
int64_t get_hpt_scaled_value (const int64_t &val, const int32_t &ldim, const int32_t &rdim)
 

Function Documentation

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

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

Referenced by Executor::collectAllDeviceResults().

1483  {
1484  std::vector<std::shared_ptr<Analyzer::Expr>> target_exprs_owned_copies;
1485  std::vector<Analyzer::Expr*> target_exprs;
1486  for (const auto target_expr : target_exprs_in) {
1487  const auto target_expr_copy =
1488  std::dynamic_pointer_cast<Analyzer::AggExpr>(target_expr->deep_copy());
1489  CHECK(target_expr_copy);
1490  auto ti = target_expr->get_type_info();
1491  ti.set_notnull(false);
1492  target_expr_copy->set_type_info(ti);
1493  if (target_expr_copy->get_arg()) {
1494  auto arg_ti = target_expr_copy->get_arg()->get_type_info();
1495  arg_ti.set_notnull(false);
1496  target_expr_copy->get_arg()->set_type_info(arg_ti);
1497  }
1498  target_exprs_owned_copies.push_back(target_expr_copy);
1499  target_exprs.push_back(target_expr_copy.get());
1500  }
1501  std::vector<TargetInfo> target_infos;
1502  std::vector<int64_t> entry;
1503  fill_entries_for_empty_input(target_infos, entry, target_exprs, query_mem_desc);
1504  const auto executor = query_mem_desc.getExecutor();
1505  CHECK(executor);
1506  auto row_set_mem_owner = executor->getRowSetMemoryOwner();
1507  CHECK(row_set_mem_owner);
1508  auto rs = std::make_shared<ResultSet>(
1509  target_infos, device_type, query_mem_desc, row_set_mem_owner, executor);
1510  rs->allocateStorage();
1511  rs->fillOneEntry(entry);
1512  return rs;
1513 }
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:1424
CHECK(cgen_state)
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 2410 of file Execute.cpp.

References CHECK().

Referenced by Executor::executePlanWithGroupBy().

2410  {
2411  CHECK(scan_limit);
2412  return results && results->rowCount() < scan_limit;
2413 }
CHECK(cgen_state)

+ Here is the call graph for this function:

+ 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 Catalog_Namespace::Catalog cat,
const ExecutorDeviceType  device_type,
const int  device_count 
)

Definition at line 1031 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::dispatchFragments().

1035  {
1036  for (const auto target_expr : ra_exe_unit.target_exprs) {
1037  if (dynamic_cast<const Analyzer::AggExpr*>(target_expr)) {
1038  return;
1039  }
1040  }
1041  if (!ra_exe_unit.scan_limit && table_infos.size() == 1 &&
1042  table_infos.front().info.getPhysicalNumTuples() < Executor::high_scan_limit) {
1043  // Allow a query with no scan limit to run on small tables
1044  return;
1045  }
1046  if (ra_exe_unit.use_bump_allocator) {
1047  // Bump allocator removes the scan limit (and any knowledge of the size of the output
1048  // relative to the size of the input), so we bypass this check for now
1049  return;
1050  }
1051  if (ra_exe_unit.sort_info.algorithm != SortAlgorithm::StreamingTopN &&
1052  ra_exe_unit.groupby_exprs.size() == 1 && !ra_exe_unit.groupby_exprs.front() &&
1053  (!ra_exe_unit.scan_limit ||
1054  ra_exe_unit.scan_limit > getDeviceBasedScanLimit(device_type, device_count))) {
1055  std::vector<std::string> table_names;
1056  const auto& input_descs = ra_exe_unit.input_descs;
1057  for (const auto& input_desc : input_descs) {
1058  table_names.push_back(get_table_name(input_desc, cat));
1059  }
1060  if (!ra_exe_unit.scan_limit) {
1061  throw WatchdogException(
1062  "Projection query would require a scan without a limit on table(s): " +
1063  boost::algorithm::join(table_names, ", "));
1064  } else {
1065  throw WatchdogException(
1066  "Projection query output result set on table(s): " +
1067  boost::algorithm::join(table_names, ", ") + " would contain " +
1068  std::to_string(ra_exe_unit.scan_limit) +
1069  " rows, which is more than the current system limit of " +
1070  std::to_string(getDeviceBasedScanLimit(device_type, device_count)));
1071  }
1072  }
1073 }
std::vector< Analyzer::Expr * > target_exprs
std::string get_table_name(const InputDescriptor &input_desc, const Catalog_Namespace::Catalog &cat)
Definition: Execute.cpp:1011
std::string join(T const &container, std::string const &delim)
const SortAlgorithm algorithm
const std::list< std::shared_ptr< Analyzer::Expr > > groupby_exprs
const std::vector< InputDescriptor > input_descs
std::string to_string(char const *&&v)
static const size_t high_scan_limit
Definition: Execute.h:409
const SortInfo sort_info
size_t getDeviceBasedScanLimit(const ExecutorDeviceType device_type, const int device_count)
Definition: Execute.cpp:1023

+ 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)

Definition at line 981 of file Execute.cpp.

References CHECK().

Referenced by Executor::executeWorkUnitImpl().

981  {
983  // Check for overflows since we're multiplying potentially big table sizes.
984  using checked_size_t = boost::multiprecision::number<
985  boost::multiprecision::cpp_int_backend<64,
986  64,
987  boost::multiprecision::unsigned_magnitude,
988  boost::multiprecision::checked,
989  void>>;
990  checked_size_t max_groups_buffer_entry_guess = 1;
991  for (const auto& query_info : query_infos) {
992  CHECK(!query_info.info.fragments.empty());
993  auto it = std::max_element(query_info.info.fragments.begin(),
994  query_info.info.fragments.end(),
995  [](const FragmentInfo& f1, const FragmentInfo& f2) {
996  return f1.getNumTuples() < f2.getNumTuples();
997  });
998  max_groups_buffer_entry_guess *= it->getNumTuples();
999  }
1000  // Cap the rough approximation to 100M entries, it's unlikely we can do a great job for
1001  // baseline group layout with that many entries anyway.
1002  constexpr size_t max_groups_buffer_entry_guess_cap = 100000000;
1003  try {
1004  return std::min(static_cast<size_t>(max_groups_buffer_entry_guess),
1005  max_groups_buffer_entry_guess_cap);
1006  } catch (...) {
1007  return max_groups_buffer_entry_guess_cap;
1008  }
1009 }
CHECK(cgen_state)
Used by Fragmenter classes to store info about each fragment - the fragment id and number of tuples(r...
Definition: Fragmenter.h:79

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References Bitmap, CHECK(), checked_calloc(), 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().

1427  {
1428  for (size_t target_idx = 0; target_idx < target_exprs.size(); ++target_idx) {
1429  const auto target_expr = target_exprs[target_idx];
1430  const auto agg_info = get_target_info(target_expr, g_bigint_count);
1431  CHECK(agg_info.is_agg);
1432  target_infos.push_back(agg_info);
1433  if (g_cluster) {
1434  const auto executor = query_mem_desc.getExecutor();
1435  CHECK(executor);
1436  auto row_set_mem_owner = executor->getRowSetMemoryOwner();
1437  CHECK(row_set_mem_owner);
1438  const auto& count_distinct_desc =
1439  query_mem_desc.getCountDistinctDescriptor(target_idx);
1440  if (count_distinct_desc.impl_type_ == CountDistinctImplType::Bitmap) {
1441  auto count_distinct_buffer = static_cast<int8_t*>(
1442  checked_calloc(count_distinct_desc.bitmapPaddedSizeBytes(), 1));
1443  CHECK(row_set_mem_owner);
1444  row_set_mem_owner->addCountDistinctBuffer(
1445  count_distinct_buffer, count_distinct_desc.bitmapPaddedSizeBytes(), true);
1446  entry.push_back(reinterpret_cast<int64_t>(count_distinct_buffer));
1447  continue;
1448  }
1449  if (count_distinct_desc.impl_type_ == CountDistinctImplType::StdSet) {
1450  auto count_distinct_set = new std::set<int64_t>();
1451  CHECK(row_set_mem_owner);
1452  row_set_mem_owner->addCountDistinctSet(count_distinct_set);
1453  entry.push_back(reinterpret_cast<int64_t>(count_distinct_set));
1454  continue;
1455  }
1456  }
1457  const bool float_argument_input = takes_float_argument(agg_info);
1458  if (agg_info.agg_kind == kCOUNT || agg_info.agg_kind == kAPPROX_COUNT_DISTINCT) {
1459  entry.push_back(0);
1460  } else if (agg_info.agg_kind == kAVG) {
1461  entry.push_back(inline_null_val(agg_info.sql_type, float_argument_input));
1462  entry.push_back(0);
1463  } else if (agg_info.agg_kind == kSINGLE_VALUE || agg_info.agg_kind == kSAMPLE) {
1464  if (agg_info.sql_type.is_geometry()) {
1465  for (int i = 0; i < agg_info.sql_type.get_physical_coord_cols() * 2; i++) {
1466  entry.push_back(0);
1467  }
1468  } else if (agg_info.sql_type.is_varlen()) {
1469  entry.push_back(0);
1470  entry.push_back(0);
1471  } else {
1472  entry.push_back(inline_null_val(agg_info.sql_type, float_argument_input));
1473  }
1474  } else {
1475  entry.push_back(inline_null_val(agg_info.sql_type, float_argument_input));
1476  }
1477  }
1478 }
bool g_cluster
TargetInfo get_target_info(const PointerType target_expr, const bool bigint_count)
Definition: TargetInfo.h:66
bool takes_float_argument(const TargetInfo &target_info)
Definition: TargetInfo.h:121
CHECK(cgen_state)
int64_t inline_null_val(const SQLTypeInfo &ti, const bool float_argument_input)
Definition: Execute.cpp:1409
bool g_bigint_count
void * checked_calloc(const size_t nmemb, const size_t size)
Definition: checked_alloc.h:48
const CountDistinctDescriptor & getCountDistinctDescriptor(const size_t idx) const
Definition: sqldefs.h:76
Definition: sqldefs.h:72
const Executor * getExecutor() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int64_t anonymous_namespace{Execute.cpp}::get_hpt_scaled_value ( const int64_t &  val,
const int32_t &  ldim,
const int32_t &  rdim 
)

Definition at line 3085 of file Execute.cpp.

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

Referenced by Executor::skipFragment().

3087  {
3088  CHECK(ldim != rdim);
3089  return ldim > rdim ? val / DateTimeUtils::get_timestamp_precision_scale(ldim - rdim)
3090  : val * DateTimeUtils::get_timestamp_precision_scale(rdim - ldim);
3091 }
CHECK(cgen_state)
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)

Definition at line 807 of file Execute.cpp.

References CHECK().

Referenced by Executor::resultsUnion().

808  {
809  auto& first = results_per_device.front().first;
810  CHECK(first);
811  for (size_t dev_idx = 1; dev_idx < results_per_device.size(); ++dev_idx) {
812  const auto& next = results_per_device[dev_idx].first;
813  CHECK(next);
814  first->append(*next);
815  }
816  return std::move(first);
817 }
CHECK(cgen_state)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1011 of file Execute.cpp.

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

Referenced by checkWorkUnitWatchdog().

1012  {
1013  const auto source_type = input_desc.getSourceType();
1014  if (source_type == InputSourceType::TABLE) {
1015  const auto td = cat.getMetadataForTable(input_desc.getTableId());
1016  CHECK(td);
1017  return td->tableName;
1018  } else {
1019  return "$TEMPORARY_TABLE" + std::to_string(-input_desc.getTableId());
1020  }
1021 }
std::string to_string(char const *&&v)
CHECK(cgen_state)
int getTableId() const
InputSourceType getSourceType() const
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1023 of file Execute.cpp.

References GPU, and Executor::high_scan_limit.

Referenced by checkWorkUnitWatchdog().

1024  {
1025  if (device_type == ExecutorDeviceType::GPU) {
1026  return device_count * Executor::high_scan_limit;
1027  }
1029 }
static const size_t high_scan_limit
Definition: Execute.h:409

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

Referenced by Executor::dispatchFragments().

1691  {
1692  for (const auto& col : fetched_cols) {
1693  if (col.is_lazily_fetched) {
1694  return true;
1695  }
1696  }
1697  return false;
1698 }

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

References CHECK(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_type(), inline_fp_null_val(), inline_int_null_val(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_boolean(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_fp(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_number(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_string(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_time(), and kFLOAT.

Referenced by fill_entries_for_empty_input().

1409  {
1410  CHECK(ti.is_number() || ti.is_time() || ti.is_boolean() || ti.is_string());
1411  if (ti.is_fp()) {
1412  if (float_argument_input && ti.get_type() == kFLOAT) {
1413  int64_t float_null_val = 0;
1414  *reinterpret_cast<float*>(may_alias_ptr(&float_null_val)) =
1415  static_cast<float>(inline_fp_null_val(ti));
1416  return float_null_val;
1417  }
1418  const auto double_null_val = inline_fp_null_val(ti);
1419  return *reinterpret_cast<const int64_t*>(may_alias_ptr(&double_null_val));
1420  }
1421  return inline_int_null_val(ti);
1422 }
bool is_fp() const
Definition: sqltypes.h:481
bool is_boolean() const
Definition: sqltypes.h:484
double inline_fp_null_val(const SQL_TYPE_INFO &ti)
bool is_number() const
Definition: sqltypes.h:482
CHECK(cgen_state)
bool is_time() const
Definition: sqltypes.h:483
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:326
bool is_string() const
Definition: sqltypes.h:477
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class T >
int64_t anonymous_namespace{Execute.cpp}::insert_one_dict_str ( T *  col_data,
const std::string &  columnName,
const SQLTypeInfo columnType,
const Analyzer::Constant col_cv,
const Catalog_Namespace::Catalog catalog 
)

Definition at line 2549 of file Execute.cpp.

References CHECK(), logger::ERROR, SQLTypeInfoCore< TYPE_FACET_PACK >::get_comp_param(), Analyzer::Constant::get_constval(), Analyzer::Constant::get_is_null(), Catalog_Namespace::Catalog::getMetadataForDict(), inline_fixed_encoding_null_val(), LOG, and Datum::stringval.

Referenced by Executor::executeSimpleInsert(), and insert_one_dict_str().

2553  {
2554  if (col_cv->get_is_null()) {
2555  *col_data = inline_fixed_encoding_null_val(columnType);
2556  } else {
2557  const int dict_id = columnType.get_comp_param();
2558  const auto col_datum = col_cv->get_constval();
2559  const auto& str = *col_datum.stringval;
2560  const auto dd = catalog.getMetadataForDict(dict_id);
2561  CHECK(dd && dd->stringDict);
2562  int32_t str_id = dd->stringDict->getOrAdd(str);
2563  if (!dd->dictIsTemp) {
2564  const auto checkpoint_ok = dd->stringDict->checkpoint();
2565  if (!checkpoint_ok) {
2566  throw std::runtime_error("Failed to checkpoint dictionary for column " +
2567  columnName);
2568  }
2569  }
2570  const bool invalid = str_id > max_valid_int_value<T>();
2571  if (invalid || str_id == inline_int_null_value<int32_t>()) {
2572  if (invalid) {
2573  LOG(ERROR) << "Could not encode string: " << str
2574  << ", the encoded value doesn't fit in " << sizeof(T) * 8
2575  << " bits. Will store NULL instead.";
2576  }
2577  str_id = inline_fixed_encoding_null_val(columnType);
2578  }
2579  *col_data = str_id;
2580  }
2581  return *col_data;
2582 }
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:335
#define LOG(tag)
Definition: Logger.h:188
bool get_is_null() const
Definition: Analyzer.h:328
CHECK(cgen_state)
const DictDescriptor * getMetadataForDict(int dict_ref, bool loadDict=true) const
Definition: Catalog.cpp:1377
std::string * stringval
Definition: sqltypes.h:134
Datum get_constval() const
Definition: Analyzer.h:329
int64_t inline_fixed_encoding_null_val(const SQL_TYPE_INFO &ti)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class T >
int64_t anonymous_namespace{Execute.cpp}::insert_one_dict_str ( T *  col_data,
const ColumnDescriptor cd,
const Analyzer::Constant col_cv,
const Catalog_Namespace::Catalog catalog 
)

Definition at line 2585 of file Execute.cpp.

References ColumnDescriptor::columnName, ColumnDescriptor::columnType, and insert_one_dict_str().

2588  {
2589  return insert_one_dict_str(col_data, cd->columnName, cd->columnType, col_cv, catalog);
2590 }
int64_t insert_one_dict_str(T *col_data, const std::string &columnName, const SQLTypeInfo &columnType, const Analyzer::Constant *col_cv, const Catalog_Namespace::Catalog &catalog)
Definition: Execute.cpp:2549
SQLTypeInfo columnType
std::string columnName

+ Here is the call 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 1557 of file Execute.cpp.

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

Referenced by Executor::collectAllDeviceShardedTopResults().

1562  {
1563  const auto output_buffer = output_storage->getUnderlyingBuffer();
1564  const auto input_buffer = input_storage->getUnderlyingBuffer();
1565  for (const auto sorted_idx : top_permutation) {
1566  // permuting all group-columns in this result set into the final buffer:
1567  for (size_t group_idx = 0; group_idx < input_query_mem_desc.getKeyCount();
1568  group_idx++) {
1569  const auto input_column_ptr =
1570  input_buffer + input_query_mem_desc.getPrependedGroupColOffInBytes(group_idx) +
1571  sorted_idx * input_query_mem_desc.groupColWidth(group_idx);
1572  const auto output_column_ptr =
1573  output_buffer +
1574  output_query_mem_desc.getPrependedGroupColOffInBytes(group_idx) +
1575  output_row_index * output_query_mem_desc.groupColWidth(group_idx);
1576  memcpy(output_column_ptr,
1577  input_column_ptr,
1578  output_query_mem_desc.groupColWidth(group_idx));
1579  }
1580  // permuting all agg-columns in this result set into the final buffer:
1581  for (size_t slot_idx = 0; slot_idx < input_query_mem_desc.getSlotCount();
1582  slot_idx++) {
1583  const auto input_column_ptr =
1584  input_buffer + input_query_mem_desc.getColOffInBytes(slot_idx) +
1585  sorted_idx * input_query_mem_desc.getPaddedSlotWidthBytes(slot_idx);
1586  const auto output_column_ptr =
1587  output_buffer + output_query_mem_desc.getColOffInBytes(slot_idx) +
1588  output_row_index * output_query_mem_desc.getPaddedSlotWidthBytes(slot_idx);
1589  memcpy(output_column_ptr,
1590  input_column_ptr,
1591  output_query_mem_desc.getPaddedSlotWidthBytes(slot_idx));
1592  }
1593  ++output_row_index;
1594  }
1595  return output_row_index;
1596 }
int8_t * getUnderlyingBuffer() const
Definition: ResultSet.cpp:77
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 1607 of file Execute.cpp.

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

Referenced by Executor::collectAllDeviceShardedTopResults().

1611  {
1612  const auto output_buffer = output_storage->getUnderlyingBuffer();
1613  const auto input_buffer = input_storage->getUnderlyingBuffer();
1614  for (const auto sorted_idx : top_permutation) {
1615  const auto row_ptr = input_buffer + sorted_idx * output_query_mem_desc.getRowSize();
1616  memcpy(output_buffer + output_row_index * output_query_mem_desc.getRowSize(),
1617  row_ptr,
1618  output_query_mem_desc.getRowSize());
1619  ++output_row_index;
1620  }
1621  return output_row_index;
1622 }
int8_t * getUnderlyingBuffer() const
Definition: ResultSet.cpp:77

+ Here is the call graph for this function:

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

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

Referenced by Executor::executeWorkUnit().

1102  {
1103  return {ra_exe_unit_in.input_descs,
1104  ra_exe_unit_in.input_col_descs,
1105  ra_exe_unit_in.simple_quals,
1106  ra_exe_unit_in.quals,
1107  ra_exe_unit_in.join_quals,
1108  ra_exe_unit_in.groupby_exprs,
1109  ra_exe_unit_in.target_exprs,
1110  ra_exe_unit_in.estimator,
1111  ra_exe_unit_in.sort_info,
1112  new_scan_limit,
1113  ra_exe_unit_in.query_features,
1114  ra_exe_unit_in.use_bump_allocator};
1115 }
std::vector< Analyzer::Expr * > target_exprs
const std::list< std::shared_ptr< Analyzer::Expr > > groupby_exprs
const std::vector< InputDescriptor > input_descs
QueryFeatureDescriptor query_features
const SortInfo sort_info
const JoinQualsPerNestingLevel join_quals
const std::shared_ptr< Analyzer::Estimator > estimator
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:

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

Definition at line 1930 of file Execute.cpp.

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

Referenced by Executor::fetchChunks().

1931  {
1932  const int table_id = col_desc->getScanDesc().getTableId();
1933  const int col_id = col_desc->getColId();
1934  return get_column_descriptor_maybe(col_id, table_id, cat);
1935 }
const ColumnDescriptor * get_column_descriptor_maybe(const int col_id, const int table_id, const Catalog_Namespace::Catalog &cat)
Definition: Execute.h:170
int getColId() const
int getTableId() const
const InputDescriptor & getScanDesc() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function: