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

Classes

struct  GetTargetInfo
 
class  OutVecOwner
 

Functions

void prepare_string_dictionaries (const std::unordered_set< PhysicalInput > &phys_inputs, const Catalog_Namespace::Catalog &catalog)
 
bool is_empty_table (Fragmenter_Namespace::AbstractFragmenter *fragmenter)
 
ResultSetPtr get_merged_result (std::vector< std::pair< ResultSetPtr, std::vector< size_t >>> &results_per_device, std::vector< TargetInfo > const &targets)
 
ReductionCode get_reduction_code (const size_t executor_id, std::vector< std::pair< ResultSetPtr, std::vector< size_t >>> &results_per_device, int64_t *compilation_queue_time)
 
size_t compute_buffer_entry_guess (const std::vector< InputTableInfo > &query_infos)
 
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 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)
 
size_t get_selected_input_descs_index (int const table_id, std::vector< InputDescriptor > const &input_descs)
 
size_t get_selected_input_col_descs_index (int const table_id, std::list< std::shared_ptr< InputColDescriptor const >> const &input_col_descs)
 
std::list< std::shared_ptr
< const InputColDescriptor > > 
get_selected_input_col_descs (int const table_id, std::list< std::shared_ptr< InputColDescriptor const >> const &input_col_descs)
 
void set_mod_range (std::vector< int8_t const * > &frag_col_buffers, int8_t const *const ptr, size_t const local_col_id, size_t const N)
 
bool check_rows_less_than_needed (const ResultSetPtr &results, const size_t scan_limit)
 
void add_deleted_col_to_map (PlanState::DeletedColumnsMap &deleted_cols_map, const ColumnDescriptor *deleted_cd)
 
std::tuple< bool, int64_t,
int64_t > 
get_hpt_overflow_underflow_safe_scaled_values (const int64_t chunk_min, const int64_t chunk_max, const SQLTypeInfo &lhs_type, const SQLTypeInfo &rhs_type)
 

Function Documentation

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

Definition at line 3949 of file Execute.cpp.

References CHECK, CHECK_EQ, and ColumnDescriptor::tableId.

Referenced by Executor::addDeletedColumn().

3950  {
3951  auto deleted_cols_it = deleted_cols_map.find(deleted_cd->tableId);
3952  if (deleted_cols_it == deleted_cols_map.end()) {
3953  CHECK(
3954  deleted_cols_map.insert(std::make_pair(deleted_cd->tableId, deleted_cd)).second);
3955  } else {
3956  CHECK_EQ(deleted_cd, deleted_cols_it->second);
3957  }
3958 }
#define CHECK_EQ(x, y)
Definition: Logger.h:297
#define CHECK(condition)
Definition: Logger.h:289

+ Here is the caller graph for this function:

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

Definition at line 2300 of file Execute.cpp.

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

Referenced by Executor::collectAllDeviceResults().

2303  {
2304  std::vector<std::shared_ptr<Analyzer::Expr>> target_exprs_owned_copies;
2305  std::vector<Analyzer::Expr*> target_exprs;
2306  for (const auto target_expr : target_exprs_in) {
2307  const auto target_expr_copy =
2308  std::dynamic_pointer_cast<Analyzer::AggExpr>(target_expr->deep_copy());
2309  CHECK(target_expr_copy);
2310  auto ti = target_expr->get_type_info();
2311  ti.set_notnull(false);
2312  target_expr_copy->set_type_info(ti);
2313  if (target_expr_copy->get_arg()) {
2314  auto arg_ti = target_expr_copy->get_arg()->get_type_info();
2315  arg_ti.set_notnull(false);
2316  target_expr_copy->get_arg()->set_type_info(arg_ti);
2317  }
2318  target_exprs_owned_copies.push_back(target_expr_copy);
2319  target_exprs.push_back(target_expr_copy.get());
2320  }
2321  std::vector<TargetInfo> target_infos;
2322  std::vector<int64_t> entry;
2323  fill_entries_for_empty_input(target_infos, entry, target_exprs, query_mem_desc);
2324  const auto executor = query_mem_desc.getExecutor();
2325  CHECK(executor);
2326  auto row_set_mem_owner = executor->getRowSetMemoryOwner();
2327  CHECK(row_set_mem_owner);
2328  auto rs = std::make_shared<ResultSet>(target_infos,
2329  device_type,
2331  row_set_mem_owner,
2332  executor->getCatalog(),
2333  executor->blockSize(),
2334  executor->gridSize());
2335  rs->allocateStorage();
2336  rs->fillOneEntry(entry);
2337  return rs;
2338 }
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:2245
#define CHECK(condition)
Definition: Logger.h:289
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 3543 of file Execute.cpp.

References CHECK.

Referenced by Executor::executePlanWithGroupBy().

3543  {
3544  CHECK(scan_limit);
3545  return results && results->rowCount() < scan_limit;
3546 }
#define CHECK(condition)
Definition: Logger.h:289

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

References SortInfo::algorithm, foreign_storage::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().

1537  {
1538  for (const auto target_expr : ra_exe_unit.target_exprs) {
1539  if (dynamic_cast<const Analyzer::AggExpr*>(target_expr)) {
1540  return;
1541  }
1542  }
1543  if (!ra_exe_unit.scan_limit && table_infos.size() == 1 &&
1544  table_infos.front().info.getPhysicalNumTuples() < Executor::high_scan_limit) {
1545  // Allow a query with no scan limit to run on small tables
1546  return;
1547  }
1548  if (ra_exe_unit.use_bump_allocator) {
1549  // Bump allocator removes the scan limit (and any knowledge of the size of the output
1550  // relative to the size of the input), so we bypass this check for now
1551  return;
1552  }
1553  if (ra_exe_unit.sort_info.algorithm != SortAlgorithm::StreamingTopN &&
1554  ra_exe_unit.groupby_exprs.size() == 1 && !ra_exe_unit.groupby_exprs.front() &&
1555  (!ra_exe_unit.scan_limit ||
1556  ra_exe_unit.scan_limit > getDeviceBasedScanLimit(device_type, device_count))) {
1557  std::vector<std::string> table_names;
1558  const auto& input_descs = ra_exe_unit.input_descs;
1559  for (const auto& input_desc : input_descs) {
1560  table_names.push_back(get_table_name(input_desc, cat));
1561  }
1562  if (!ra_exe_unit.scan_limit) {
1563  throw WatchdogException(
1564  "Projection query would require a scan without a limit on table(s): " +
1565  boost::algorithm::join(table_names, ", "));
1566  } else {
1567  throw WatchdogException(
1568  "Projection query output result set on table(s): " +
1569  boost::algorithm::join(table_names, ", ") + " would contain " +
1570  std::to_string(ra_exe_unit.scan_limit) +
1571  " rows, which is more than the current system limit of " +
1572  std::to_string(getDeviceBasedScanLimit(device_type, device_count)));
1573  }
1574  }
1575 }
std::vector< Analyzer::Expr * > target_exprs
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:608
size_t getDeviceBasedScanLimit(const ExecutorDeviceType device_type, const int device_count)
Definition: Execute.cpp:1525
std::string get_table_name(int32_t db_id, int32_t table_id)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1483 of file Execute.cpp.

References CHECK.

Referenced by Executor::executeWorkUnitImpl().

1483  {
1485  // Check for overflows since we're multiplying potentially big table sizes.
1486  using checked_size_t = boost::multiprecision::number<
1487  boost::multiprecision::cpp_int_backend<64,
1488  64,
1489  boost::multiprecision::unsigned_magnitude,
1490  boost::multiprecision::checked,
1491  void>>;
1492  checked_size_t max_groups_buffer_entry_guess = 1;
1493  for (const auto& query_info : query_infos) {
1494  CHECK(!query_info.info.fragments.empty());
1495  auto it = std::max_element(query_info.info.fragments.begin(),
1496  query_info.info.fragments.end(),
1497  [](const FragmentInfo& f1, const FragmentInfo& f2) {
1498  return f1.getNumTuples() < f2.getNumTuples();
1499  });
1500  max_groups_buffer_entry_guess *= it->getNumTuples();
1501  }
1502  // Cap the rough approximation to 100M entries, it's unlikely we can do a great job for
1503  // baseline group layout with that many entries anyway.
1504  constexpr size_t max_groups_buffer_entry_guess_cap = 100000000;
1505  try {
1506  return std::min(static_cast<size_t>(max_groups_buffer_entry_guess),
1507  max_groups_buffer_entry_guess_cap);
1508  } catch (...) {
1509  return max_groups_buffer_entry_guess_cap;
1510  }
1511 }
Used by Fragmenter classes to store info about each fragment - the fragment id and number of tuples(r...
Definition: Fragmenter.h:86
#define CHECK(condition)
Definition: Logger.h:289

+ Here is the caller graph for this function:

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

Definition at line 1597 of file Execute.cpp.

Referenced by operator<<().

1597  {
1598  std::vector<std::string> expr_strs;
1599  for (const auto& expr : expr_container) {
1600  if (!expr) {
1601  expr_strs.emplace_back("NULL");
1602  } else {
1603  expr_strs.emplace_back(expr->toString());
1604  }
1605  }
1606  return expr_strs;
1607 }

+ Here is the caller graph for this function:

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

Definition at line 1610 of file Execute.cpp.

1611  {
1612  std::vector<std::string> expr_strs;
1613  for (const auto& expr : expr_container) {
1614  expr_strs.emplace_back(expr.toString());
1615  }
1616  return expr_strs;
1617 }
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 2245 of file Execute.cpp.

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

Referenced by build_row_for_empty_input().

2248  {
2249  for (size_t target_idx = 0; target_idx < target_exprs.size(); ++target_idx) {
2250  const auto target_expr = target_exprs[target_idx];
2251  const auto agg_info = get_target_info(target_expr, g_bigint_count);
2252  CHECK(agg_info.is_agg);
2253  target_infos.push_back(agg_info);
2254  if (g_cluster) {
2255  const auto executor = query_mem_desc.getExecutor();
2256  CHECK(executor);
2257  auto row_set_mem_owner = executor->getRowSetMemoryOwner();
2258  CHECK(row_set_mem_owner);
2259  const auto& count_distinct_desc =
2260  query_mem_desc.getCountDistinctDescriptor(target_idx);
2261  if (count_distinct_desc.impl_type_ == CountDistinctImplType::Bitmap) {
2262  CHECK(row_set_mem_owner);
2263  auto count_distinct_buffer = row_set_mem_owner->allocateCountDistinctBuffer(
2264  count_distinct_desc.bitmapPaddedSizeBytes(),
2265  /*thread_idx=*/0); // TODO: can we detect thread idx here?
2266  entry.push_back(reinterpret_cast<int64_t>(count_distinct_buffer));
2267  continue;
2268  }
2269  if (count_distinct_desc.impl_type_ == CountDistinctImplType::UnorderedSet) {
2270  auto count_distinct_set = new CountDistinctSet();
2271  CHECK(row_set_mem_owner);
2272  row_set_mem_owner->addCountDistinctSet(count_distinct_set);
2273  entry.push_back(reinterpret_cast<int64_t>(count_distinct_set));
2274  continue;
2275  }
2276  }
2277  const bool float_argument_input = takes_float_argument(agg_info);
2278  if (shared::is_any<kCOUNT, kCOUNT_IF, kAPPROX_COUNT_DISTINCT>(agg_info.agg_kind)) {
2279  entry.push_back(0);
2280  } else if (shared::is_any<kAVG>(agg_info.agg_kind)) {
2281  entry.push_back(0);
2282  entry.push_back(0);
2283  } else if (shared::is_any<kSINGLE_VALUE, kSAMPLE>(agg_info.agg_kind)) {
2284  if (agg_info.sql_type.is_geometry() && !agg_info.is_varlen_projection) {
2285  for (int i = 0; i < agg_info.sql_type.get_physical_coord_cols() * 2; i++) {
2286  entry.push_back(0);
2287  }
2288  } else if (agg_info.sql_type.is_varlen()) {
2289  entry.push_back(0);
2290  entry.push_back(0);
2291  } else {
2292  entry.push_back(inline_null_val(agg_info.sql_type, float_argument_input));
2293  }
2294  } else {
2295  entry.push_back(inline_null_val(agg_info.sql_type, float_argument_input));
2296  }
2297  }
2298 }
robin_hood::unordered_set< int64_t > CountDistinctSet
Definition: CountDistinct.h:35
bool takes_float_argument(const TargetInfo &target_info)
Definition: TargetInfo.h:102
TargetInfo get_target_info(const Analyzer::Expr *target_expr, const bool bigint_count)
Definition: TargetInfo.h:88
int64_t inline_null_val(const SQLTypeInfo &ti, const bool float_argument_input)
Definition: Execute.cpp:2230
bool g_bigint_count
const CountDistinctDescriptor & getCountDistinctDescriptor(const size_t idx) const
#define CHECK(condition)
Definition: Logger.h:289
bool g_cluster
const Executor * getExecutor() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 4005 of file Execute.cpp.

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

Referenced by Executor::skipFragment().

4009  {
4010  const int32_t ldim = lhs_type.get_dimension();
4011  const int32_t rdim = rhs_type.get_dimension();
4012  CHECK(ldim != rdim);
4013  const auto scale = DateTimeUtils::get_timestamp_precision_scale(abs(rdim - ldim));
4014  if (ldim > rdim) {
4015  // LHS type precision is more than RHS col type. No chance of overflow/underflow.
4016  return {true, chunk_min / scale, chunk_max / scale};
4017  }
4018 
4019  using checked_int64_t = boost::multiprecision::number<
4020  boost::multiprecision::cpp_int_backend<64,
4021  64,
4022  boost::multiprecision::signed_magnitude,
4023  boost::multiprecision::checked,
4024  void>>;
4025 
4026  try {
4027  auto ret =
4028  std::make_tuple(true,
4029  int64_t(checked_int64_t(chunk_min) * checked_int64_t(scale)),
4030  int64_t(checked_int64_t(chunk_max) * checked_int64_t(scale)));
4031  return ret;
4032  } catch (const std::overflow_error& e) {
4033  // noop
4034  }
4035  return std::make_tuple(false, chunk_min, chunk_max);
4036 }
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 64, 64, boost::multiprecision::signed_magnitude, boost::multiprecision::checked, void >> checked_int64_t
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:382
#define CHECK(condition)
Definition: Logger.h:289
constexpr int64_t get_timestamp_precision_scale(const int32_t dimen)
Definition: DateTimeUtils.h:51

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1267 of file Execute.cpp.

References CHECK, and result_set::first_dict_encoded_idx().

Referenced by Executor::resultsUnion().

1269  {
1270  auto& first = results_per_device.front().first;
1271  CHECK(first);
1272  auto const first_target_idx = result_set::first_dict_encoded_idx(targets);
1273  if (first_target_idx) {
1274  first->translateDictEncodedColumns(targets, *first_target_idx);
1275  }
1276  for (size_t dev_idx = 1; dev_idx < results_per_device.size(); ++dev_idx) {
1277  const auto& next = results_per_device[dev_idx].first;
1278  CHECK(next);
1279  if (first_target_idx) {
1280  next->translateDictEncodedColumns(targets, *first_target_idx);
1281  }
1282  first->append(*next);
1283  }
1284  return std::move(first);
1285 }
std::optional< size_t > first_dict_encoded_idx(std::vector< TargetInfo > const &)
Definition: ResultSet.cpp:1573
#define CHECK(condition)
Definition: Logger.h:289

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1352 of file Execute.cpp.

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

Referenced by Executor::reduceMultiDeviceResultSets().

1355  {
1356  auto clock_begin = timer_start();
1357  // ResultSetReductionJIT::codegen compilation-locks if new code will be generated
1358  *compilation_queue_time = timer_stop(clock_begin);
1359  const auto& this_result_set = results_per_device[0].first;
1360  ResultSetReductionJIT reduction_jit(this_result_set->getQueryMemDesc(),
1361  this_result_set->getTargetInfos(),
1362  this_result_set->getTargetInitVals(),
1363  executor_id);
1364  return reduction_jit.codegen();
1365 };
TypeR::rep timer_stop(Type clock_begin)
Definition: measure.h:48
virtual ReductionCode codegen() const
Type timer_start()
Definition: measure.h:42

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 3103 of file Execute.cpp.

Referenced by Executor::fetchUnionChunks().

3105  {
3106  std::list<std::shared_ptr<const InputColDescriptor>> selected;
3107  for (auto const& input_col_desc : input_col_descs) {
3108  if (table_id == input_col_desc->getScanDesc().getTableId()) {
3109  selected.push_back(input_col_desc);
3110  }
3111  }
3112  return selected;
3113 }

+ Here is the caller graph for this function:

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

Definition at line 3092 of file Execute.cpp.

Referenced by Executor::fetchUnionChunks().

3094  {
3095  auto const has_table_id = [table_id](auto const& input_desc) {
3096  return table_id == input_desc->getScanDesc().getTableId();
3097  };
3098  return std::distance(
3099  input_col_descs.begin(),
3100  std::find_if(input_col_descs.begin(), input_col_descs.end(), has_table_id));
3101 }

+ Here is the caller graph for this function:

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

Definition at line 3083 of file Execute.cpp.

Referenced by Executor::fetchUnionChunks().

3084  {
3085  auto const has_table_id = [table_id](InputDescriptor const& input_desc) {
3086  return table_id == input_desc.getTableId();
3087  };
3088  return std::find_if(input_descs.begin(), input_descs.end(), has_table_id) -
3089  input_descs.begin();
3090 }

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

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

1514  {
1515  const auto source_type = input_desc.getSourceType();
1516  if (source_type == InputSourceType::TABLE) {
1517  const auto td = cat.getMetadataForTable(input_desc.getTableId());
1518  CHECK(td);
1519  return td->tableName;
1520  } else {
1521  return "$TEMPORARY_TABLE" + std::to_string(-input_desc.getTableId());
1522  }
1523 }
std::string to_string(char const *&&v)
int getTableId() const
InputSourceType getSourceType() const
#define CHECK(condition)
Definition: Logger.h:289
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:

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

Definition at line 1525 of file Execute.cpp.

References GPU, and Executor::high_scan_limit.

Referenced by checkWorkUnitWatchdog().

1526  {
1527  if (device_type == ExecutorDeviceType::GPU) {
1528  return device_count * Executor::high_scan_limit;
1529  }
1531 }
static const size_t high_scan_limit
Definition: Execute.h:608

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

Referenced by Executor::createKernels().

2522  {
2523  for (const auto& col : fetched_cols) {
2524  if (col.is_lazily_fetched) {
2525  return true;
2526  }
2527  }
2528  return false;
2529 }

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

2230  {
2231  CHECK(ti.is_number() || ti.is_time() || ti.is_boolean() || ti.is_string());
2232  if (ti.is_fp()) {
2233  if (float_argument_input && ti.get_type() == kFLOAT) {
2234  int64_t float_null_val = 0;
2235  *reinterpret_cast<float*>(may_alias_ptr(&float_null_val)) =
2236  static_cast<float>(inline_fp_null_val(ti));
2237  return float_null_val;
2238  }
2239  const auto double_null_val = inline_fp_null_val(ti);
2240  return *reinterpret_cast<const int64_t*>(may_alias_ptr(&double_null_val));
2241  }
2242  return inline_int_null_val(ti);
2243 }
bool is_fp() const
Definition: sqltypes.h:580
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:380
bool is_number() const
Definition: sqltypes.h:581
double inline_fp_null_val(const SQL_TYPE_INFO &ti)
bool is_time() const
Definition: sqltypes.h:582
bool is_boolean() const
Definition: sqltypes.h:583
#define CHECK(condition)
Definition: Logger.h:289
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
bool is_string() const
Definition: sqltypes.h:576

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 196 of file Execute.cpp.

Referenced by foreign_storage::populate_string_dictionary().

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

+ Here is the caller graph for this function:

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

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

Referenced by Executor::collectAllDeviceShardedTopResults().

2391  {
2392  const auto output_buffer = output_storage->getUnderlyingBuffer();
2393  const auto input_buffer = input_storage->getUnderlyingBuffer();
2394  for (const auto sorted_idx : top_permutation) {
2395  // permuting all group-columns in this result set into the final buffer:
2396  for (size_t group_idx = 0; group_idx < input_query_mem_desc.getKeyCount();
2397  group_idx++) {
2398  const auto input_column_ptr =
2399  input_buffer + input_query_mem_desc.getPrependedGroupColOffInBytes(group_idx) +
2400  sorted_idx * input_query_mem_desc.groupColWidth(group_idx);
2401  const auto output_column_ptr =
2402  output_buffer +
2403  output_query_mem_desc.getPrependedGroupColOffInBytes(group_idx) +
2404  output_row_index * output_query_mem_desc.groupColWidth(group_idx);
2405  memcpy(output_column_ptr,
2406  input_column_ptr,
2407  output_query_mem_desc.groupColWidth(group_idx));
2408  }
2409  // permuting all agg-columns in this result set into the final buffer:
2410  for (size_t slot_idx = 0; slot_idx < input_query_mem_desc.getSlotCount();
2411  slot_idx++) {
2412  const auto input_column_ptr =
2413  input_buffer + input_query_mem_desc.getColOffInBytes(slot_idx) +
2414  sorted_idx * input_query_mem_desc.getPaddedSlotWidthBytes(slot_idx);
2415  const auto output_column_ptr =
2416  output_buffer + output_query_mem_desc.getColOffInBytes(slot_idx) +
2417  output_row_index * output_query_mem_desc.getPaddedSlotWidthBytes(slot_idx);
2418  memcpy(output_column_ptr,
2419  input_column_ptr,
2420  output_query_mem_desc.getPaddedSlotWidthBytes(slot_idx));
2421  }
2422  ++output_row_index;
2423  }
2424  return output_row_index;
2425 }
int8_t * getUnderlyingBuffer() const
int8_t groupColWidth(const size_t key_idx) const
const int8_t getPaddedSlotWidthBytes(const size_t slot_idx) const
size_t getColOffInBytes(const size_t col_idx) const
size_t getPrependedGroupColOffInBytes(const size_t group_idx) const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

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

Definition at line 2436 of file Execute.cpp.

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

Referenced by Executor::collectAllDeviceShardedTopResults().

2440  {
2441  const auto output_buffer = output_storage->getUnderlyingBuffer();
2442  const auto input_buffer = input_storage->getUnderlyingBuffer();
2443  for (const auto sorted_idx : top_permutation) {
2444  const auto row_ptr = input_buffer + sorted_idx * output_query_mem_desc.getRowSize();
2445  memcpy(output_buffer + output_row_index * output_query_mem_desc.getRowSize(),
2446  row_ptr,
2447  output_query_mem_desc.getRowSize());
2448  ++output_row_index;
2449  }
2450  return output_row_index;
2451 }
int8_t * getUnderlyingBuffer() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 189 of file Execute.cpp.

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

190  {
191  for (const auto [col_id, table_id] : phys_inputs) {
192  foreign_storage::populate_string_dictionary(table_id, col_id, catalog);
193  }
194 }
void populate_string_dictionary(const int32_t table_id, const int32_t col_id, const Catalog_Namespace::Catalog &catalog)
Definition: Execute.cpp:206

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

References RelAlgExecutionUnit::estimator, RelAlgExecutionUnit::groupby_exprs, RelAlgExecutionUnit::hash_table_build_plan_dag, RelAlgExecutionUnit::input_col_descs, RelAlgExecutionUnit::input_descs, RelAlgExecutionUnit::join_quals, RelAlgExecutionUnit::quals, RelAlgExecutionUnit::query_hint, RelAlgExecutionUnit::query_plan_dag_hash, RelAlgExecutionUnit::query_state, RelAlgExecutionUnit::simple_quals, RelAlgExecutionUnit::sort_info, RelAlgExecutionUnit::table_id_to_node_map, RelAlgExecutionUnit::target_exprs, RelAlgExecutionUnit::target_exprs_original_type_infos, RelAlgExecutionUnit::union_all, and RelAlgExecutionUnit::use_bump_allocator.

Referenced by Executor::executeWorkUnit().

1736  {
1737  return {ra_exe_unit_in.input_descs,
1738  ra_exe_unit_in.input_col_descs,
1739  ra_exe_unit_in.simple_quals,
1740  ra_exe_unit_in.quals,
1741  ra_exe_unit_in.join_quals,
1742  ra_exe_unit_in.groupby_exprs,
1743  ra_exe_unit_in.target_exprs,
1744  ra_exe_unit_in.target_exprs_original_type_infos,
1745  ra_exe_unit_in.estimator,
1746  ra_exe_unit_in.sort_info,
1747  new_scan_limit,
1748  ra_exe_unit_in.query_hint,
1749  ra_exe_unit_in.query_plan_dag_hash,
1750  ra_exe_unit_in.hash_table_build_plan_dag,
1751  ra_exe_unit_in.table_id_to_node_map,
1752  ra_exe_unit_in.use_bump_allocator,
1753  ra_exe_unit_in.union_all,
1754  ra_exe_unit_in.query_state};
1755 }
std::vector< Analyzer::Expr * > target_exprs
QueryPlanHash query_plan_dag_hash
const std::optional< bool > union_all
std::vector< InputDescriptor > input_descs
const std::list< std::shared_ptr< Analyzer::Expr > > groupby_exprs
const JoinQualsPerNestingLevel join_quals
TableIdToNodeMap table_id_to_node_map
const std::shared_ptr< Analyzer::Estimator > estimator
std::unordered_map< size_t, SQLTypeInfo > target_exprs_original_type_infos
std::list< std::shared_ptr< Analyzer::Expr > > quals
RegisteredQueryHint query_hint
std::shared_ptr< const query_state::QueryState > query_state
std::list< std::shared_ptr< const InputColDescriptor > > input_col_descs
std::list< std::shared_ptr< Analyzer::Expr > > simple_quals
HashTableBuildDagMap hash_table_build_plan_dag

+ Here is the caller graph for this function:

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

Definition at line 3116 of file Execute.cpp.

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

Referenced by Executor::fetchUnionChunks().

3119  {
3120  size_t const begin = local_col_id - local_col_id % N; // N divides begin
3121  size_t const end = begin + N;
3122  CHECK_LE(end, frag_col_buffers.size()) << (void*)ptr << ' ' << local_col_id << ' ' << N;
3123  for (size_t i = begin; i < end; ++i) {
3124  frag_col_buffers[i] = ptr;
3125  }
3126 }
#define CHECK_LE(x, y)
Definition: Logger.h:300
constexpr unsigned N
Definition: Utm.h:110

+ Here is the caller graph for this function:

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

Definition at line 1619 of file Execute.cpp.

References Default, SpeculativeTopN, StreamingTopN, and UNREACHABLE.

Referenced by operator<<().

1619  {
1620  switch (algorithm) {
1622  return "ResultSet";
1624  return "Speculative Top N";
1626  return "Streaming Top N";
1627  }
1628  UNREACHABLE();
1629  return "";
1630 }
#define UNREACHABLE()
Definition: Logger.h:333

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

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

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

2826  {
2827  const int table_id = col_desc->getScanDesc().getTableId();
2828  const int col_id = col_desc->getColId();
2829  return get_column_descriptor_maybe(col_id, table_id, cat);
2830 }
const ColumnDescriptor * get_column_descriptor_maybe(const int col_id, const int table_id, const Catalog_Namespace::Catalog &cat)
Definition: Execute.h:220
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: