OmniSciDB  1dac507f6e
 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 1470 of file Execute.cpp.

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

Referenced by Executor::collectAllDeviceResults().

1473  {
1474  std::vector<std::shared_ptr<Analyzer::Expr>> target_exprs_owned_copies;
1475  std::vector<Analyzer::Expr*> target_exprs;
1476  for (const auto target_expr : target_exprs_in) {
1477  const auto target_expr_copy =
1478  std::dynamic_pointer_cast<Analyzer::AggExpr>(target_expr->deep_copy());
1479  CHECK(target_expr_copy);
1480  auto ti = target_expr->get_type_info();
1481  ti.set_notnull(false);
1482  target_expr_copy->set_type_info(ti);
1483  if (target_expr_copy->get_arg()) {
1484  auto arg_ti = target_expr_copy->get_arg()->get_type_info();
1485  arg_ti.set_notnull(false);
1486  target_expr_copy->get_arg()->set_type_info(arg_ti);
1487  }
1488  target_exprs_owned_copies.push_back(target_expr_copy);
1489  target_exprs.push_back(target_expr_copy.get());
1490  }
1491  std::vector<TargetInfo> target_infos;
1492  std::vector<int64_t> entry;
1493  fill_entries_for_empty_input(target_infos, entry, target_exprs, query_mem_desc);
1494  const auto executor = query_mem_desc.getExecutor();
1495  CHECK(executor);
1496  auto row_set_mem_owner = executor->getRowSetMemoryOwner();
1497  CHECK(row_set_mem_owner);
1498  auto rs = std::make_shared<ResultSet>(
1499  target_infos, device_type, query_mem_desc, row_set_mem_owner, executor);
1500  rs->allocateStorage();
1501  rs->fillOneEntry(entry);
1502  return rs;
1503 }
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:1414
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 2395 of file Execute.cpp.

References CHECK().

Referenced by Executor::executePlanWithGroupBy().

2395  {
2396  CHECK(scan_limit);
2397  return results && results->rowCount() < scan_limit;
2398 }
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 1021 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().

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

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

References CHECK().

Referenced by Executor::executeWorkUnitImpl().

971  {
973  // Check for overflows since we're multiplying potentially big table sizes.
974  using checked_size_t = boost::multiprecision::number<
975  boost::multiprecision::cpp_int_backend<64,
976  64,
977  boost::multiprecision::unsigned_magnitude,
978  boost::multiprecision::checked,
979  void>>;
980  checked_size_t max_groups_buffer_entry_guess = 1;
981  for (const auto& query_info : query_infos) {
982  CHECK(!query_info.info.fragments.empty());
983  auto it = std::max_element(query_info.info.fragments.begin(),
984  query_info.info.fragments.end(),
985  [](const FragmentInfo& f1, const FragmentInfo& f2) {
986  return f1.getNumTuples() < f2.getNumTuples();
987  });
988  max_groups_buffer_entry_guess *= it->getNumTuples();
989  }
990  // Cap the rough approximation to 100M entries, it's unlikely we can do a great job for
991  // baseline group layout with that many entries anyway.
992  constexpr size_t max_groups_buffer_entry_guess_cap = 100000000;
993  try {
994  return std::min(static_cast<size_t>(max_groups_buffer_entry_guess),
995  max_groups_buffer_entry_guess_cap);
996  } catch (...) {
997  return max_groups_buffer_entry_guess_cap;
998  }
999 }
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 1414 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().

1417  {
1418  for (size_t target_idx = 0; target_idx < target_exprs.size(); ++target_idx) {
1419  const auto target_expr = target_exprs[target_idx];
1420  const auto agg_info = get_target_info(target_expr, g_bigint_count);
1421  CHECK(agg_info.is_agg);
1422  target_infos.push_back(agg_info);
1423  if (g_cluster) {
1424  const auto executor = query_mem_desc.getExecutor();
1425  CHECK(executor);
1426  auto row_set_mem_owner = executor->getRowSetMemoryOwner();
1427  CHECK(row_set_mem_owner);
1428  const auto& count_distinct_desc =
1429  query_mem_desc.getCountDistinctDescriptor(target_idx);
1430  if (count_distinct_desc.impl_type_ == CountDistinctImplType::Bitmap) {
1431  auto count_distinct_buffer = static_cast<int8_t*>(
1432  checked_calloc(count_distinct_desc.bitmapPaddedSizeBytes(), 1));
1433  CHECK(row_set_mem_owner);
1434  row_set_mem_owner->addCountDistinctBuffer(
1435  count_distinct_buffer, count_distinct_desc.bitmapPaddedSizeBytes(), true);
1436  entry.push_back(reinterpret_cast<int64_t>(count_distinct_buffer));
1437  continue;
1438  }
1439  if (count_distinct_desc.impl_type_ == CountDistinctImplType::StdSet) {
1440  auto count_distinct_set = new std::set<int64_t>();
1441  CHECK(row_set_mem_owner);
1442  row_set_mem_owner->addCountDistinctSet(count_distinct_set);
1443  entry.push_back(reinterpret_cast<int64_t>(count_distinct_set));
1444  continue;
1445  }
1446  }
1447  const bool float_argument_input = takes_float_argument(agg_info);
1448  if (agg_info.agg_kind == kCOUNT || agg_info.agg_kind == kAPPROX_COUNT_DISTINCT) {
1449  entry.push_back(0);
1450  } else if (agg_info.agg_kind == kAVG) {
1451  entry.push_back(inline_null_val(agg_info.sql_type, float_argument_input));
1452  entry.push_back(0);
1453  } else if (agg_info.agg_kind == kSAMPLE) {
1454  if (agg_info.sql_type.is_geometry()) {
1455  for (int i = 0; i < agg_info.sql_type.get_physical_coord_cols() * 2; i++) {
1456  entry.push_back(0);
1457  }
1458  } else if (agg_info.sql_type.is_varlen()) {
1459  entry.push_back(0);
1460  entry.push_back(0);
1461  } else {
1462  entry.push_back(inline_null_val(agg_info.sql_type, float_argument_input));
1463  }
1464  } else {
1465  entry.push_back(inline_null_val(agg_info.sql_type, float_argument_input));
1466  }
1467  }
1468 }
bool g_cluster
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
CHECK(cgen_state)
int64_t inline_null_val(const SQLTypeInfo &ti, const bool float_argument_input)
Definition: Execute.cpp:1399
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
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 3067 of file Execute.cpp.

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

Referenced by Executor::skipFragment().

3069  {
3070  CHECK(ldim != rdim);
3071  return ldim > rdim ? val / DateTimeUtils::get_timestamp_precision_scale(ldim - rdim)
3072  : val * DateTimeUtils::get_timestamp_precision_scale(rdim - ldim);
3073 }
CHECK(cgen_state)
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 797 of file Execute.cpp.

References CHECK().

Referenced by Executor::resultsUnion().

798  {
799  auto& first = results_per_device.front().first;
800  CHECK(first);
801  for (size_t dev_idx = 1; dev_idx < results_per_device.size(); ++dev_idx) {
802  const auto& next = results_per_device[dev_idx].first;
803  CHECK(next);
804  first->append(*next);
805  }
806  return std::move(first);
807 }
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 1001 of file Execute.cpp.

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

Referenced by checkWorkUnitWatchdog().

1002  {
1003  const auto source_type = input_desc.getSourceType();
1004  if (source_type == InputSourceType::TABLE) {
1005  const auto td = cat.getMetadataForTable(input_desc.getTableId());
1006  CHECK(td);
1007  return td->tableName;
1008  } else {
1009  return "$TEMPORARY_TABLE" + std::to_string(-input_desc.getTableId());
1010  }
1011 }
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 1013 of file Execute.cpp.

References GPU, and Executor::high_scan_limit.

Referenced by checkWorkUnitWatchdog().

1014  {
1015  if (device_type == ExecutorDeviceType::GPU) {
1016  return device_count * Executor::high_scan_limit;
1017  }
1019 }
static const size_t high_scan_limit
Definition: Execute.h:468

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

Referenced by Executor::dispatchFragments().

1681  {
1682  for (const auto& col : fetched_cols) {
1683  if (col.is_lazily_fetched) {
1684  return true;
1685  }
1686  }
1687  return false;
1688 }

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

1399  {
1400  CHECK(ti.is_number() || ti.is_time() || ti.is_boolean() || ti.is_string());
1401  if (ti.is_fp()) {
1402  if (float_argument_input && ti.get_type() == kFLOAT) {
1403  int64_t float_null_val = 0;
1404  *reinterpret_cast<float*>(may_alias_ptr(&float_null_val)) =
1405  static_cast<float>(inline_fp_null_val(ti));
1406  return float_null_val;
1407  }
1408  const auto double_null_val = inline_fp_null_val(ti);
1409  return *reinterpret_cast<const int64_t*>(may_alias_ptr(&double_null_val));
1410  }
1411  return inline_int_null_val(ti);
1412 }
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 2533 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().

2537  {
2538  if (col_cv->get_is_null()) {
2539  *col_data = inline_fixed_encoding_null_val(columnType);
2540  } else {
2541  const int dict_id = columnType.get_comp_param();
2542  const auto col_datum = col_cv->get_constval();
2543  const auto& str = *col_datum.stringval;
2544  const auto dd = catalog.getMetadataForDict(dict_id);
2545  CHECK(dd && dd->stringDict);
2546  int32_t str_id = dd->stringDict->getOrAdd(str);
2547  const bool checkpoint_ok = dd->stringDict->checkpoint();
2548  if (!checkpoint_ok) {
2549  throw std::runtime_error("Failed to checkpoint dictionary for column " +
2550  columnName);
2551  }
2552  const bool invalid = str_id > max_valid_int_value<T>();
2553  if (invalid || str_id == inline_int_null_value<int32_t>()) {
2554  if (invalid) {
2555  LOG(ERROR) << "Could not encode string: " << str
2556  << ", the encoded value doesn't fit in " << sizeof(T) * 8
2557  << " bits. Will store NULL instead.";
2558  }
2559  str_id = inline_fixed_encoding_null_val(columnType);
2560  }
2561  *col_data = str_id;
2562  }
2563  return *col_data;
2564 }
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:335
#define LOG(tag)
Definition: Logger.h:185
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:1350
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 2567 of file Execute.cpp.

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

2570  {
2571  return insert_one_dict_str(col_data, cd->columnName, cd->columnType, col_cv, catalog);
2572 }
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:2533
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 1547 of file Execute.cpp.

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

Referenced by Executor::collectAllDeviceShardedTopResults().

1552  {
1553  const auto output_buffer = output_storage->getUnderlyingBuffer();
1554  const auto input_buffer = input_storage->getUnderlyingBuffer();
1555  for (const auto sorted_idx : top_permutation) {
1556  // permuting all group-columns in this result set into the final buffer:
1557  for (size_t group_idx = 0; group_idx < input_query_mem_desc.getKeyCount();
1558  group_idx++) {
1559  const auto input_column_ptr =
1560  input_buffer + input_query_mem_desc.getPrependedGroupColOffInBytes(group_idx) +
1561  sorted_idx * input_query_mem_desc.groupColWidth(group_idx);
1562  const auto output_column_ptr =
1563  output_buffer +
1564  output_query_mem_desc.getPrependedGroupColOffInBytes(group_idx) +
1565  output_row_index * output_query_mem_desc.groupColWidth(group_idx);
1566  memcpy(output_column_ptr,
1567  input_column_ptr,
1568  output_query_mem_desc.groupColWidth(group_idx));
1569  }
1570  // permuting all agg-columns in this result set into the final buffer:
1571  for (size_t slot_idx = 0; slot_idx < input_query_mem_desc.getSlotCount();
1572  slot_idx++) {
1573  const auto input_column_ptr =
1574  input_buffer + input_query_mem_desc.getColOffInBytes(slot_idx) +
1575  sorted_idx * input_query_mem_desc.getPaddedSlotWidthBytes(slot_idx);
1576  const auto output_column_ptr =
1577  output_buffer + output_query_mem_desc.getColOffInBytes(slot_idx) +
1578  output_row_index * output_query_mem_desc.getPaddedSlotWidthBytes(slot_idx);
1579  memcpy(output_column_ptr,
1580  input_column_ptr,
1581  output_query_mem_desc.getPaddedSlotWidthBytes(slot_idx));
1582  }
1583  ++output_row_index;
1584  }
1585  return output_row_index;
1586 }
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 1597 of file Execute.cpp.

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

Referenced by Executor::collectAllDeviceShardedTopResults().

1601  {
1602  const auto output_buffer = output_storage->getUnderlyingBuffer();
1603  const auto input_buffer = input_storage->getUnderlyingBuffer();
1604  for (const auto sorted_idx : top_permutation) {
1605  const auto row_ptr = input_buffer + sorted_idx * output_query_mem_desc.getRowSize();
1606  memcpy(output_buffer + output_row_index * output_query_mem_desc.getRowSize(),
1607  row_ptr,
1608  output_query_mem_desc.getRowSize());
1609  ++output_row_index;
1610  }
1611  return output_row_index;
1612 }
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 1091 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().

1092  {
1093  return {ra_exe_unit_in.input_descs,
1094  ra_exe_unit_in.input_col_descs,
1095  ra_exe_unit_in.simple_quals,
1096  ra_exe_unit_in.quals,
1097  ra_exe_unit_in.join_quals,
1098  ra_exe_unit_in.groupby_exprs,
1099  ra_exe_unit_in.target_exprs,
1100  ra_exe_unit_in.estimator,
1101  ra_exe_unit_in.sort_info,
1102  new_scan_limit,
1103  ra_exe_unit_in.query_features,
1104  ra_exe_unit_in.use_bump_allocator};
1105 }
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 1920 of file Execute.cpp.

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

Referenced by Executor::fetchChunks().

1921  {
1922  const int table_id = col_desc->getScanDesc().getTableId();
1923  const int col_id = col_desc->getColId();
1924  return get_column_descriptor_maybe(col_id, table_id, cat);
1925 }
const ColumnDescriptor * get_column_descriptor_maybe(const int col_id, const int table_id, const Catalog_Namespace::Catalog &cat)
Definition: Execute.h:171
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: