OmniSciDB  343343d194
 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 1435 of file Execute.cpp.

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

Referenced by Executor::collectAllDeviceResults().

1438  {
1439  std::vector<std::shared_ptr<Analyzer::Expr>> target_exprs_owned_copies;
1440  std::vector<Analyzer::Expr*> target_exprs;
1441  for (const auto target_expr : target_exprs_in) {
1442  const auto target_expr_copy =
1443  std::dynamic_pointer_cast<Analyzer::AggExpr>(target_expr->deep_copy());
1444  CHECK(target_expr_copy);
1445  auto ti = target_expr->get_type_info();
1446  ti.set_notnull(false);
1447  target_expr_copy->set_type_info(ti);
1448  if (target_expr_copy->get_arg()) {
1449  auto arg_ti = target_expr_copy->get_arg()->get_type_info();
1450  arg_ti.set_notnull(false);
1451  target_expr_copy->get_arg()->set_type_info(arg_ti);
1452  }
1453  target_exprs_owned_copies.push_back(target_expr_copy);
1454  target_exprs.push_back(target_expr_copy.get());
1455  }
1456  std::vector<TargetInfo> target_infos;
1457  std::vector<int64_t> entry;
1458  fill_entries_for_empty_input(target_infos, entry, target_exprs, query_mem_desc);
1459  const auto executor = query_mem_desc.getExecutor();
1460  CHECK(executor);
1461  auto row_set_mem_owner = executor->getRowSetMemoryOwner();
1462  CHECK(row_set_mem_owner);
1463  auto rs = std::make_shared<ResultSet>(
1464  target_infos, device_type, query_mem_desc, row_set_mem_owner, executor);
1465  rs->allocateStorage();
1466  rs->fillOneEntry(entry);
1467  return rs;
1468 }
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:1379
#define CHECK(condition)
Definition: Logger.h:187
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 2357 of file Execute.cpp.

References CHECK.

Referenced by Executor::executePlanWithGroupBy().

2357  {
2358  CHECK(scan_limit);
2359  return results && results->rowCount() < scan_limit;
2360 }
#define CHECK(condition)
Definition: Logger.h:187

+ 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 1016 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().

1020  {
1021  for (const auto target_expr : ra_exe_unit.target_exprs) {
1022  if (dynamic_cast<const Analyzer::AggExpr*>(target_expr)) {
1023  return;
1024  }
1025  }
1026  if (!ra_exe_unit.scan_limit && table_infos.size() == 1 &&
1027  table_infos.front().info.getPhysicalNumTuples() < Executor::high_scan_limit) {
1028  // Allow a query with no scan limit to run on small tables
1029  return;
1030  }
1031  if (ra_exe_unit.use_bump_allocator) {
1032  // Bump allocator removes the scan limit (and any knowledge of the size of the output
1033  // relative to the size of the input), so we bypass this check for now
1034  return;
1035  }
1036  if (ra_exe_unit.sort_info.algorithm != SortAlgorithm::StreamingTopN &&
1037  ra_exe_unit.groupby_exprs.size() == 1 && !ra_exe_unit.groupby_exprs.front() &&
1038  (!ra_exe_unit.scan_limit ||
1039  ra_exe_unit.scan_limit > getDeviceBasedScanLimit(device_type, device_count))) {
1040  std::vector<std::string> table_names;
1041  const auto& input_descs = ra_exe_unit.input_descs;
1042  for (const auto& input_desc : input_descs) {
1043  table_names.push_back(get_table_name(input_desc, cat));
1044  }
1045  if (!ra_exe_unit.scan_limit) {
1046  throw WatchdogException(
1047  "Projection query would require a scan without a limit on table(s): " +
1048  boost::algorithm::join(table_names, ", "));
1049  } else {
1050  throw WatchdogException(
1051  "Projection query output result set on table(s): " +
1052  boost::algorithm::join(table_names, ", ") + " would contain " +
1053  std::to_string(ra_exe_unit.scan_limit) +
1054  " rows, which is more than the current system limit of " +
1055  std::to_string(getDeviceBasedScanLimit(device_type, device_count)));
1056  }
1057  }
1058 }
std::vector< Analyzer::Expr * > target_exprs
std::string get_table_name(const InputDescriptor &input_desc, const Catalog_Namespace::Catalog &cat)
Definition: Execute.cpp:996
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:467
const SortInfo sort_info
size_t getDeviceBasedScanLimit(const ExecutorDeviceType device_type, const int device_count)
Definition: Execute.cpp:1008

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

References CHECK.

Referenced by Executor::executeWorkUnitImpl().

966  {
968  // Check for overflows since we're multiplying potentially big table sizes.
969  using checked_size_t = boost::multiprecision::number<
970  boost::multiprecision::cpp_int_backend<64,
971  64,
972  boost::multiprecision::unsigned_magnitude,
973  boost::multiprecision::checked,
974  void>>;
975  checked_size_t max_groups_buffer_entry_guess = 1;
976  for (const auto& query_info : query_infos) {
977  CHECK(!query_info.info.fragments.empty());
978  auto it = std::max_element(query_info.info.fragments.begin(),
979  query_info.info.fragments.end(),
980  [](const FragmentInfo& f1, const FragmentInfo& f2) {
981  return f1.getNumTuples() < f2.getNumTuples();
982  });
983  max_groups_buffer_entry_guess *= it->getNumTuples();
984  }
985  // Cap the rough approximation to 100M entries, it's unlikely we can do a great job for
986  // baseline group layout with that many entries anyway.
987  constexpr size_t max_groups_buffer_entry_guess_cap = 100000000;
988  try {
989  return std::min(static_cast<size_t>(max_groups_buffer_entry_guess),
990  max_groups_buffer_entry_guess_cap);
991  } catch (...) {
992  return max_groups_buffer_entry_guess_cap;
993  }
994 }
Used by Fragmenter classes to store info about each fragment - the fragment id and number of tuples(r...
Definition: Fragmenter.h:79
#define CHECK(condition)
Definition: Logger.h:187

+ 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 1379 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, StdSet, and takes_float_argument().

Referenced by build_row_for_empty_input().

1382  {
1383  for (size_t target_idx = 0; target_idx < target_exprs.size(); ++target_idx) {
1384  const auto target_expr = target_exprs[target_idx];
1385  const auto agg_info = get_target_info(target_expr, g_bigint_count);
1386  CHECK(agg_info.is_agg);
1387  target_infos.push_back(agg_info);
1388  if (g_cluster) {
1389  const auto executor = query_mem_desc.getExecutor();
1390  CHECK(executor);
1391  auto row_set_mem_owner = executor->getRowSetMemoryOwner();
1392  CHECK(row_set_mem_owner);
1393  const auto& count_distinct_desc =
1394  query_mem_desc.getCountDistinctDescriptor(target_idx);
1395  if (count_distinct_desc.impl_type_ == CountDistinctImplType::Bitmap) {
1396  auto count_distinct_buffer = static_cast<int8_t*>(
1397  checked_calloc(count_distinct_desc.bitmapPaddedSizeBytes(), 1));
1398  CHECK(row_set_mem_owner);
1399  row_set_mem_owner->addCountDistinctBuffer(
1400  count_distinct_buffer, count_distinct_desc.bitmapPaddedSizeBytes(), true);
1401  entry.push_back(reinterpret_cast<int64_t>(count_distinct_buffer));
1402  continue;
1403  }
1404  if (count_distinct_desc.impl_type_ == CountDistinctImplType::StdSet) {
1405  auto count_distinct_set = new std::set<int64_t>();
1406  CHECK(row_set_mem_owner);
1407  row_set_mem_owner->addCountDistinctSet(count_distinct_set);
1408  entry.push_back(reinterpret_cast<int64_t>(count_distinct_set));
1409  continue;
1410  }
1411  }
1412  const bool float_argument_input = takes_float_argument(agg_info);
1413  if (agg_info.agg_kind == kCOUNT || agg_info.agg_kind == kAPPROX_COUNT_DISTINCT) {
1414  entry.push_back(0);
1415  } else if (agg_info.agg_kind == kAVG) {
1416  entry.push_back(inline_null_val(agg_info.sql_type, float_argument_input));
1417  entry.push_back(0);
1418  } else if (agg_info.agg_kind == kSAMPLE) {
1419  if (agg_info.sql_type.is_geometry()) {
1420  for (int i = 0; i < agg_info.sql_type.get_physical_coord_cols() * 2; i++) {
1421  entry.push_back(0);
1422  }
1423  } else if (agg_info.sql_type.is_varlen()) {
1424  entry.push_back(0);
1425  entry.push_back(0);
1426  } else {
1427  entry.push_back(inline_null_val(agg_info.sql_type, float_argument_input));
1428  }
1429  } else {
1430  entry.push_back(inline_null_val(agg_info.sql_type, float_argument_input));
1431  }
1432  }
1433 }
TargetInfo get_target_info(const PointerType target_expr, const bool bigint_count)
Definition: TargetInfo.h:65
bool takes_float_argument(const TargetInfo &target_info)
Definition: TargetInfo.h:120
int64_t inline_null_val(const SQLTypeInfo &ti, const bool float_argument_input)
Definition: Execute.cpp:1364
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:71
#define CHECK(condition)
Definition: Logger.h:187
bool g_cluster
Definition: sqldefs.h:71
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 3028 of file Execute.cpp.

References CHECK, and DateTimeUtils::get_timestamp_precision_scale().

Referenced by Executor::skipFragment().

3030  {
3031  CHECK(ldim != rdim);
3032  return ldim > rdim ? val / DateTimeUtils::get_timestamp_precision_scale(ldim - rdim)
3033  : val * DateTimeUtils::get_timestamp_precision_scale(rdim - ldim);
3034 }
#define CHECK(condition)
Definition: Logger.h:187
constexpr int64_t get_timestamp_precision_scale(const int32_t dimen)
Definition: DateTimeUtils.h:48

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

References CHECK.

Referenced by Executor::resultsUnion().

790  {
791  auto& first = results_per_device.front().first;
792  CHECK(first);
793  for (size_t dev_idx = 1; dev_idx < results_per_device.size(); ++dev_idx) {
794  const auto& next = results_per_device[dev_idx].first;
795  CHECK(next);
796  first->append(*next);
797  }
798  return std::move(first);
799 }
#define CHECK(condition)
Definition: Logger.h:187

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

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

Referenced by checkWorkUnitWatchdog().

997  {
998  const auto source_type = input_desc.getSourceType();
999  if (source_type == InputSourceType::TABLE) {
1000  const auto td = cat.getMetadataForTable(input_desc.getTableId());
1001  CHECK(td);
1002  return td->tableName;
1003  } else {
1004  return "$TEMPORARY_TABLE" + std::to_string(-input_desc.getTableId());
1005  }
1006 }
std::string to_string(char const *&&v)
int getTableId() const
InputSourceType getSourceType() const
#define CHECK(condition)
Definition: Logger.h:187
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 1008 of file Execute.cpp.

References GPU, and Executor::high_scan_limit.

Referenced by checkWorkUnitWatchdog().

1009  {
1010  if (device_type == ExecutorDeviceType::GPU) {
1011  return device_count * Executor::high_scan_limit;
1012  }
1014 }
static const size_t high_scan_limit
Definition: Execute.h:467

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

Referenced by Executor::dispatchFragments().

1645  {
1646  for (const auto& col : fetched_cols) {
1647  if (col.is_lazily_fetched) {
1648  return true;
1649  }
1650  }
1651  return false;
1652 }

+ 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 1364 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().

1364  {
1365  CHECK(ti.is_number() || ti.is_time() || ti.is_boolean() || ti.is_string());
1366  if (ti.is_fp()) {
1367  if (float_argument_input && ti.get_type() == kFLOAT) {
1368  int64_t float_null_val = 0;
1369  *reinterpret_cast<float*>(may_alias_ptr(&float_null_val)) =
1370  static_cast<float>(inline_fp_null_val(ti));
1371  return float_null_val;
1372  }
1373  const auto double_null_val = inline_fp_null_val(ti);
1374  return *reinterpret_cast<const int64_t*>(may_alias_ptr(&double_null_val));
1375  }
1376  return inline_int_null_val(ti);
1377 }
bool is_fp() const
Definition: sqltypes.h:476
bool is_boolean() const
Definition: sqltypes.h:479
double inline_fp_null_val(const SQL_TYPE_INFO &ti)
bool is_number() const
Definition: sqltypes.h:477
bool is_time() const
Definition: sqltypes.h:478
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:324
bool is_string() const
Definition: sqltypes.h:472
#define CHECK(condition)
Definition: Logger.h:187
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 2494 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().

2498  {
2499  if (col_cv->get_is_null()) {
2500  *col_data = inline_fixed_encoding_null_val(columnType);
2501  } else {
2502  const int dict_id = columnType.get_comp_param();
2503  const auto col_datum = col_cv->get_constval();
2504  const auto& str = *col_datum.stringval;
2505  const auto dd = catalog.getMetadataForDict(dict_id);
2506  CHECK(dd && dd->stringDict);
2507  int32_t str_id = dd->stringDict->getOrAdd(str);
2508  const bool checkpoint_ok = dd->stringDict->checkpoint();
2509  if (!checkpoint_ok) {
2510  throw std::runtime_error("Failed to checkpoint dictionary for column " +
2511  columnName);
2512  }
2513  const bool invalid = str_id > max_valid_int_value<T>();
2514  if (invalid || str_id == inline_int_null_value<int32_t>()) {
2515  if (invalid) {
2516  LOG(ERROR) << "Could not encode string: " << str
2517  << ", the encoded value doesn't fit in " << sizeof(T) * 8
2518  << " bits. Will store NULL instead.";
2519  }
2520  str_id = inline_fixed_encoding_null_val(columnType);
2521  }
2522  *col_data = str_id;
2523  }
2524  return *col_data;
2525 }
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:333
#define LOG(tag)
Definition: Logger.h:182
bool get_is_null() const
Definition: Analyzer.h:327
const DictDescriptor * getMetadataForDict(int dict_ref, bool loadDict=true) const
Definition: Catalog.cpp:1348
std::string * stringval
Definition: sqltypes.h:132
Datum get_constval() const
Definition: Analyzer.h:328
#define CHECK(condition)
Definition: Logger.h:187
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 2528 of file Execute.cpp.

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

2531  {
2532  return insert_one_dict_str(col_data, cd->columnName, cd->columnType, col_cv, catalog);
2533 }
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:2494
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 1511 of file Execute.cpp.

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

Referenced by Executor::collectAllDeviceShardedTopResults().

1516  {
1517  const auto output_buffer = output_storage->getUnderlyingBuffer();
1518  const auto input_buffer = input_storage->getUnderlyingBuffer();
1519  for (const auto sorted_idx : top_permutation) {
1520  // permuting all group-columns in this result set into the final buffer:
1521  for (size_t group_idx = 0; group_idx < input_query_mem_desc.getKeyCount();
1522  group_idx++) {
1523  const auto input_column_ptr =
1524  input_buffer + input_query_mem_desc.getPrependedGroupColOffInBytes(group_idx) +
1525  sorted_idx * input_query_mem_desc.groupColWidth(group_idx);
1526  const auto output_column_ptr =
1527  output_buffer +
1528  output_query_mem_desc.getPrependedGroupColOffInBytes(group_idx) +
1529  output_row_index * output_query_mem_desc.groupColWidth(group_idx);
1530  memcpy(output_column_ptr,
1531  input_column_ptr,
1532  output_query_mem_desc.groupColWidth(group_idx));
1533  }
1534  // permuting all agg-columns in this result set into the final buffer:
1535  for (size_t slot_idx = 0; slot_idx < input_query_mem_desc.getSlotCount();
1536  slot_idx++) {
1537  const auto input_column_ptr =
1538  input_buffer + input_query_mem_desc.getColOffInBytes(slot_idx) +
1539  sorted_idx * input_query_mem_desc.getPaddedSlotWidthBytes(slot_idx);
1540  const auto output_column_ptr =
1541  output_buffer + output_query_mem_desc.getColOffInBytes(slot_idx) +
1542  output_row_index * output_query_mem_desc.getPaddedSlotWidthBytes(slot_idx);
1543  memcpy(output_column_ptr,
1544  input_column_ptr,
1545  output_query_mem_desc.getPaddedSlotWidthBytes(slot_idx));
1546  }
1547  ++output_row_index;
1548  }
1549  return output_row_index;
1550 }
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 1561 of file Execute.cpp.

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

Referenced by Executor::collectAllDeviceShardedTopResults().

1565  {
1566  const auto output_buffer = output_storage->getUnderlyingBuffer();
1567  const auto input_buffer = input_storage->getUnderlyingBuffer();
1568  for (const auto sorted_idx : top_permutation) {
1569  const auto row_ptr = input_buffer + sorted_idx * output_query_mem_desc.getRowSize();
1570  memcpy(output_buffer + output_row_index * output_query_mem_desc.getRowSize(),
1571  row_ptr,
1572  output_query_mem_desc.getRowSize());
1573  ++output_row_index;
1574  }
1575  return output_row_index;
1576 }
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 1086 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().

1087  {
1088  return {ra_exe_unit_in.input_descs,
1089  ra_exe_unit_in.input_col_descs,
1090  ra_exe_unit_in.simple_quals,
1091  ra_exe_unit_in.quals,
1092  ra_exe_unit_in.join_quals,
1093  ra_exe_unit_in.groupby_exprs,
1094  ra_exe_unit_in.target_exprs,
1095  ra_exe_unit_in.estimator,
1096  ra_exe_unit_in.sort_info,
1097  new_scan_limit,
1098  ra_exe_unit_in.query_features,
1099  ra_exe_unit_in.use_bump_allocator};
1100 }
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 1884 of file Execute.cpp.

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

Referenced by Executor::fetchChunks().

1885  {
1886  const int table_id = col_desc->getScanDesc().getTableId();
1887  const int col_id = col_desc->getColId();
1888  return get_column_descriptor_maybe(col_id, table_id, cat);
1889 }
const ColumnDescriptor * get_column_descriptor_maybe(const int col_id, const int table_id, const Catalog_Namespace::Catalog &cat)
Definition: Execute.h:169
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: