OmniSciDB  c0231cc57d
 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 3906 of file Execute.cpp.

References CHECK, CHECK_EQ, and ColumnDescriptor::tableId.

Referenced by Executor::addDeletedColumn().

3907  {
3908  auto deleted_cols_it = deleted_cols_map.find(deleted_cd->tableId);
3909  if (deleted_cols_it == deleted_cols_map.end()) {
3910  CHECK(
3911  deleted_cols_map.insert(std::make_pair(deleted_cd->tableId, deleted_cd)).second);
3912  } else {
3913  CHECK_EQ(deleted_cd, deleted_cols_it->second);
3914  }
3915 }
#define CHECK_EQ(x, y)
Definition: Logger.h:230
#define CHECK(condition)
Definition: Logger.h:222

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

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

Referenced by Executor::collectAllDeviceResults().

2284  {
2285  std::vector<std::shared_ptr<Analyzer::Expr>> target_exprs_owned_copies;
2286  std::vector<Analyzer::Expr*> target_exprs;
2287  for (const auto target_expr : target_exprs_in) {
2288  const auto target_expr_copy =
2289  std::dynamic_pointer_cast<Analyzer::AggExpr>(target_expr->deep_copy());
2290  CHECK(target_expr_copy);
2291  auto ti = target_expr->get_type_info();
2292  ti.set_notnull(false);
2293  target_expr_copy->set_type_info(ti);
2294  if (target_expr_copy->get_arg()) {
2295  auto arg_ti = target_expr_copy->get_arg()->get_type_info();
2296  arg_ti.set_notnull(false);
2297  target_expr_copy->get_arg()->set_type_info(arg_ti);
2298  }
2299  target_exprs_owned_copies.push_back(target_expr_copy);
2300  target_exprs.push_back(target_expr_copy.get());
2301  }
2302  std::vector<TargetInfo> target_infos;
2303  std::vector<int64_t> entry;
2304  fill_entries_for_empty_input(target_infos, entry, target_exprs, query_mem_desc);
2305  const auto executor = query_mem_desc.getExecutor();
2306  CHECK(executor);
2307  auto row_set_mem_owner = executor->getRowSetMemoryOwner();
2308  CHECK(row_set_mem_owner);
2309  auto rs = std::make_shared<ResultSet>(target_infos,
2310  device_type,
2312  row_set_mem_owner,
2313  executor->getCatalog(),
2314  executor->blockSize(),
2315  executor->gridSize());
2316  rs->allocateStorage();
2317  rs->fillOneEntry(entry);
2318  return rs;
2319 }
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:2226
#define CHECK(condition)
Definition: Logger.h:222
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 3519 of file Execute.cpp.

References CHECK.

Referenced by Executor::executePlanWithGroupBy().

3519  {
3520  CHECK(scan_limit);
3521  return results && results->rowCount() < scan_limit;
3522 }
#define CHECK(condition)
Definition: Logger.h:222

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

1512  {
1513  for (const auto target_expr : ra_exe_unit.target_exprs) {
1514  if (dynamic_cast<const Analyzer::AggExpr*>(target_expr)) {
1515  return;
1516  }
1517  }
1518  if (!ra_exe_unit.scan_limit && table_infos.size() == 1 &&
1519  table_infos.front().info.getPhysicalNumTuples() < Executor::high_scan_limit) {
1520  // Allow a query with no scan limit to run on small tables
1521  return;
1522  }
1523  if (ra_exe_unit.use_bump_allocator) {
1524  // Bump allocator removes the scan limit (and any knowledge of the size of the output
1525  // relative to the size of the input), so we bypass this check for now
1526  return;
1527  }
1528  if (ra_exe_unit.sort_info.algorithm != SortAlgorithm::StreamingTopN &&
1529  ra_exe_unit.groupby_exprs.size() == 1 && !ra_exe_unit.groupby_exprs.front() &&
1530  (!ra_exe_unit.scan_limit ||
1531  ra_exe_unit.scan_limit > getDeviceBasedScanLimit(device_type, device_count))) {
1532  std::vector<std::string> table_names;
1533  const auto& input_descs = ra_exe_unit.input_descs;
1534  for (const auto& input_desc : input_descs) {
1535  table_names.push_back(get_table_name(input_desc, cat));
1536  }
1537  if (!ra_exe_unit.scan_limit) {
1538  throw WatchdogException(
1539  "Projection query would require a scan without a limit on table(s): " +
1540  boost::algorithm::join(table_names, ", "));
1541  } else {
1542  throw WatchdogException(
1543  "Projection query output result set on table(s): " +
1544  boost::algorithm::join(table_names, ", ") + " would contain " +
1545  std::to_string(ra_exe_unit.scan_limit) +
1546  " rows, which is more than the current system limit of " +
1547  std::to_string(getDeviceBasedScanLimit(device_type, device_count)));
1548  }
1549  }
1550 }
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:602
size_t getDeviceBasedScanLimit(const ExecutorDeviceType device_type, const int device_count)
Definition: Execute.cpp:1500
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 1458 of file Execute.cpp.

References CHECK.

Referenced by Executor::executeWorkUnitImpl().

1458  {
1460  // Check for overflows since we're multiplying potentially big table sizes.
1461  using checked_size_t = boost::multiprecision::number<
1462  boost::multiprecision::cpp_int_backend<64,
1463  64,
1464  boost::multiprecision::unsigned_magnitude,
1465  boost::multiprecision::checked,
1466  void>>;
1467  checked_size_t max_groups_buffer_entry_guess = 1;
1468  for (const auto& query_info : query_infos) {
1469  CHECK(!query_info.info.fragments.empty());
1470  auto it = std::max_element(query_info.info.fragments.begin(),
1471  query_info.info.fragments.end(),
1472  [](const FragmentInfo& f1, const FragmentInfo& f2) {
1473  return f1.getNumTuples() < f2.getNumTuples();
1474  });
1475  max_groups_buffer_entry_guess *= it->getNumTuples();
1476  }
1477  // Cap the rough approximation to 100M entries, it's unlikely we can do a great job for
1478  // baseline group layout with that many entries anyway.
1479  constexpr size_t max_groups_buffer_entry_guess_cap = 100000000;
1480  try {
1481  return std::min(static_cast<size_t>(max_groups_buffer_entry_guess),
1482  max_groups_buffer_entry_guess_cap);
1483  } catch (...) {
1484  return max_groups_buffer_entry_guess_cap;
1485  }
1486 }
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:222

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

Referenced by operator<<().

1579  {
1580  std::vector<std::string> expr_strs;
1581  for (const auto& expr : expr_container) {
1582  if (!expr) {
1583  expr_strs.emplace_back("NULL");
1584  } else {
1585  expr_strs.emplace_back(expr->toString());
1586  }
1587  }
1588  return expr_strs;
1589 }

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

1593  {
1594  std::vector<std::string> expr_strs;
1595  for (const auto& expr : expr_container) {
1596  expr_strs.emplace_back(expr.toString());
1597  }
1598  return expr_strs;
1599 }
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 2226 of file Execute.cpp.

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

Referenced by build_row_for_empty_input().

2229  {
2230  for (size_t target_idx = 0; target_idx < target_exprs.size(); ++target_idx) {
2231  const auto target_expr = target_exprs[target_idx];
2232  const auto agg_info = get_target_info(target_expr, g_bigint_count);
2233  CHECK(agg_info.is_agg);
2234  target_infos.push_back(agg_info);
2235  if (g_cluster) {
2236  const auto executor = query_mem_desc.getExecutor();
2237  CHECK(executor);
2238  auto row_set_mem_owner = executor->getRowSetMemoryOwner();
2239  CHECK(row_set_mem_owner);
2240  const auto& count_distinct_desc =
2241  query_mem_desc.getCountDistinctDescriptor(target_idx);
2242  if (count_distinct_desc.impl_type_ == CountDistinctImplType::Bitmap) {
2243  CHECK(row_set_mem_owner);
2244  auto count_distinct_buffer = row_set_mem_owner->allocateCountDistinctBuffer(
2245  count_distinct_desc.bitmapPaddedSizeBytes(),
2246  /*thread_idx=*/0); // TODO: can we detect thread idx here?
2247  entry.push_back(reinterpret_cast<int64_t>(count_distinct_buffer));
2248  continue;
2249  }
2250  if (count_distinct_desc.impl_type_ == CountDistinctImplType::UnorderedSet) {
2251  auto count_distinct_set = new CountDistinctSet();
2252  CHECK(row_set_mem_owner);
2253  row_set_mem_owner->addCountDistinctSet(count_distinct_set);
2254  entry.push_back(reinterpret_cast<int64_t>(count_distinct_set));
2255  continue;
2256  }
2257  }
2258  const bool float_argument_input = takes_float_argument(agg_info);
2259  if (agg_info.agg_kind == kCOUNT || agg_info.agg_kind == kAPPROX_COUNT_DISTINCT) {
2260  entry.push_back(0);
2261  } else if (agg_info.agg_kind == kAVG) {
2262  entry.push_back(0);
2263  entry.push_back(0);
2264  } else if (agg_info.agg_kind == kSINGLE_VALUE || agg_info.agg_kind == kSAMPLE) {
2265  if (agg_info.sql_type.is_geometry() && !agg_info.is_varlen_projection) {
2266  for (int i = 0; i < agg_info.sql_type.get_physical_coord_cols() * 2; i++) {
2267  entry.push_back(0);
2268  }
2269  } else if (agg_info.sql_type.is_varlen()) {
2270  entry.push_back(0);
2271  entry.push_back(0);
2272  } else {
2273  entry.push_back(inline_null_val(agg_info.sql_type, float_argument_input));
2274  }
2275  } else {
2276  entry.push_back(inline_null_val(agg_info.sql_type, float_argument_input));
2277  }
2278  }
2279 }
robin_hood::unordered_set< int64_t > CountDistinctSet
Definition: CountDistinct.h:35
bool takes_float_argument(const TargetInfo &target_info)
Definition: TargetInfo.h:111
TargetInfo get_target_info(const Analyzer::Expr *target_expr, const bool bigint_count)
Definition: TargetInfo.h:97
int64_t inline_null_val(const SQLTypeInfo &ti, const bool float_argument_input)
Definition: Execute.cpp:2211
bool g_bigint_count
const CountDistinctDescriptor & getCountDistinctDescriptor(const size_t idx) const
Definition: sqldefs.h:77
#define CHECK(condition)
Definition: Logger.h:222
bool g_cluster
Definition: sqldefs.h:73
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 3962 of file Execute.cpp.

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

Referenced by Executor::skipFragment().

3966  {
3967  const int32_t ldim = lhs_type.get_dimension();
3968  const int32_t rdim = rhs_type.get_dimension();
3969  CHECK(ldim != rdim);
3970  const auto scale = DateTimeUtils::get_timestamp_precision_scale(abs(rdim - ldim));
3971  if (ldim > rdim) {
3972  // LHS type precision is more than RHS col type. No chance of overflow/underflow.
3973  return {true, chunk_min / scale, chunk_max / scale};
3974  }
3975 
3976  using checked_int64_t = boost::multiprecision::number<
3977  boost::multiprecision::cpp_int_backend<64,
3978  64,
3979  boost::multiprecision::signed_magnitude,
3980  boost::multiprecision::checked,
3981  void>>;
3982 
3983  try {
3984  auto ret =
3985  std::make_tuple(true,
3986  int64_t(checked_int64_t(chunk_min) * checked_int64_t(scale)),
3987  int64_t(checked_int64_t(chunk_max) * checked_int64_t(scale)));
3988  return ret;
3989  } catch (const std::overflow_error& e) {
3990  // noop
3991  }
3992  return std::make_tuple(false, chunk_min, chunk_max);
3993 }
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:406
#define CHECK(condition)
Definition: Logger.h:222
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 1243 of file Execute.cpp.

References CHECK, and result_set::first_dict_encoded_idx().

Referenced by Executor::resultsUnion().

1245  {
1246  auto& first = results_per_device.front().first;
1247  CHECK(first);
1248  auto const first_target_idx = result_set::first_dict_encoded_idx(targets);
1249  if (first_target_idx) {
1250  first->translateDictEncodedColumns(targets, *first_target_idx);
1251  }
1252  for (size_t dev_idx = 1; dev_idx < results_per_device.size(); ++dev_idx) {
1253  const auto& next = results_per_device[dev_idx].first;
1254  CHECK(next);
1255  if (first_target_idx) {
1256  next->translateDictEncodedColumns(targets, *first_target_idx);
1257  }
1258  first->append(*next);
1259  }
1260  return std::move(first);
1261 }
std::optional< size_t > first_dict_encoded_idx(std::vector< TargetInfo > const &)
Definition: ResultSet.cpp:1475
#define CHECK(condition)
Definition: Logger.h:222

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

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

Referenced by Executor::reduceMultiDeviceResultSets().

1331  {
1332  auto clock_begin = timer_start();
1333  // ResultSetReductionJIT::codegen compilation-locks if new code will be generated
1334  *compilation_queue_time = timer_stop(clock_begin);
1335  const auto& this_result_set = results_per_device[0].first;
1336  ResultSetReductionJIT reduction_jit(this_result_set->getQueryMemDesc(),
1337  this_result_set->getTargetInfos(),
1338  this_result_set->getTargetInitVals(),
1339  executor_id);
1340  return reduction_jit.codegen();
1341 };
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 3083 of file Execute.cpp.

Referenced by Executor::fetchUnionChunks().

3085  {
3086  std::list<std::shared_ptr<const InputColDescriptor>> selected;
3087  for (auto const& input_col_desc : input_col_descs) {
3088  if (table_id == input_col_desc->getScanDesc().getTableId()) {
3089  selected.push_back(input_col_desc);
3090  }
3091  }
3092  return selected;
3093 }

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

Referenced by Executor::fetchUnionChunks().

3074  {
3075  auto const has_table_id = [table_id](auto const& input_desc) {
3076  return table_id == input_desc->getScanDesc().getTableId();
3077  };
3078  return std::distance(
3079  input_col_descs.begin(),
3080  std::find_if(input_col_descs.begin(), input_col_descs.end(), has_table_id));
3081 }

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

Referenced by Executor::fetchUnionChunks().

3064  {
3065  auto const has_table_id = [table_id](InputDescriptor const& input_desc) {
3066  return table_id == input_desc.getTableId();
3067  };
3068  return std::find_if(input_descs.begin(), input_descs.end(), has_table_id) -
3069  input_descs.begin();
3070 }

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

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

1489  {
1490  const auto source_type = input_desc.getSourceType();
1491  if (source_type == InputSourceType::TABLE) {
1492  const auto td = cat.getMetadataForTable(input_desc.getTableId());
1493  CHECK(td);
1494  return td->tableName;
1495  } else {
1496  return "$TEMPORARY_TABLE" + std::to_string(-input_desc.getTableId());
1497  }
1498 }
std::string to_string(char const *&&v)
int getTableId() const
InputSourceType getSourceType() const
#define CHECK(condition)
Definition: Logger.h:222
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 1500 of file Execute.cpp.

References GPU, and Executor::high_scan_limit.

Referenced by checkWorkUnitWatchdog().

1501  {
1502  if (device_type == ExecutorDeviceType::GPU) {
1503  return device_count * Executor::high_scan_limit;
1504  }
1506 }
static const size_t high_scan_limit
Definition: Execute.h:602

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

Referenced by Executor::createKernels().

2503  {
2504  for (const auto& col : fetched_cols) {
2505  if (col.is_lazily_fetched) {
2506  return true;
2507  }
2508  }
2509  return false;
2510 }

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

2211  {
2212  CHECK(ti.is_number() || ti.is_time() || ti.is_boolean() || ti.is_string());
2213  if (ti.is_fp()) {
2214  if (float_argument_input && ti.get_type() == kFLOAT) {
2215  int64_t float_null_val = 0;
2216  *reinterpret_cast<float*>(may_alias_ptr(&float_null_val)) =
2217  static_cast<float>(inline_fp_null_val(ti));
2218  return float_null_val;
2219  }
2220  const auto double_null_val = inline_fp_null_val(ti);
2221  return *reinterpret_cast<const int64_t*>(may_alias_ptr(&double_null_val));
2222  }
2223  return inline_int_null_val(ti);
2224 }
bool is_fp() const
Definition: sqltypes.h:604
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:404
bool is_number() const
Definition: sqltypes.h:605
double inline_fp_null_val(const SQL_TYPE_INFO &ti)
bool is_time() const
Definition: sqltypes.h:606
bool is_boolean() const
Definition: sqltypes.h:607
#define CHECK(condition)
Definition: Logger.h:222
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
bool is_string() const
Definition: sqltypes.h:600

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

Referenced by foreign_storage::populate_string_dictionary().

195  {
196  const auto& fragments = fragmenter->getFragmentsForQuery().fragments;
197  // The fragmenter always returns at least one fragment, even when the table is empty.
198  return (fragments.size() == 1 && fragments[0].getChunkMetadataMap().empty());
199 }
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 2367 of file Execute.cpp.

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

Referenced by Executor::collectAllDeviceShardedTopResults().

2372  {
2373  const auto output_buffer = output_storage->getUnderlyingBuffer();
2374  const auto input_buffer = input_storage->getUnderlyingBuffer();
2375  for (const auto sorted_idx : top_permutation) {
2376  // permuting all group-columns in this result set into the final buffer:
2377  for (size_t group_idx = 0; group_idx < input_query_mem_desc.getKeyCount();
2378  group_idx++) {
2379  const auto input_column_ptr =
2380  input_buffer + input_query_mem_desc.getPrependedGroupColOffInBytes(group_idx) +
2381  sorted_idx * input_query_mem_desc.groupColWidth(group_idx);
2382  const auto output_column_ptr =
2383  output_buffer +
2384  output_query_mem_desc.getPrependedGroupColOffInBytes(group_idx) +
2385  output_row_index * output_query_mem_desc.groupColWidth(group_idx);
2386  memcpy(output_column_ptr,
2387  input_column_ptr,
2388  output_query_mem_desc.groupColWidth(group_idx));
2389  }
2390  // permuting all agg-columns in this result set into the final buffer:
2391  for (size_t slot_idx = 0; slot_idx < input_query_mem_desc.getSlotCount();
2392  slot_idx++) {
2393  const auto input_column_ptr =
2394  input_buffer + input_query_mem_desc.getColOffInBytes(slot_idx) +
2395  sorted_idx * input_query_mem_desc.getPaddedSlotWidthBytes(slot_idx);
2396  const auto output_column_ptr =
2397  output_buffer + output_query_mem_desc.getColOffInBytes(slot_idx) +
2398  output_row_index * output_query_mem_desc.getPaddedSlotWidthBytes(slot_idx);
2399  memcpy(output_column_ptr,
2400  input_column_ptr,
2401  output_query_mem_desc.getPaddedSlotWidthBytes(slot_idx));
2402  }
2403  ++output_row_index;
2404  }
2405  return output_row_index;
2406 }
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 2417 of file Execute.cpp.

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

Referenced by Executor::collectAllDeviceShardedTopResults().

2421  {
2422  const auto output_buffer = output_storage->getUnderlyingBuffer();
2423  const auto input_buffer = input_storage->getUnderlyingBuffer();
2424  for (const auto sorted_idx : top_permutation) {
2425  const auto row_ptr = input_buffer + sorted_idx * output_query_mem_desc.getRowSize();
2426  memcpy(output_buffer + output_row_index * output_query_mem_desc.getRowSize(),
2427  row_ptr,
2428  output_query_mem_desc.getRowSize());
2429  ++output_row_index;
2430  }
2431  return output_row_index;
2432 }
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 188 of file Execute.cpp.

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

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

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

1718  {
1719  return {ra_exe_unit_in.input_descs,
1720  ra_exe_unit_in.input_col_descs,
1721  ra_exe_unit_in.simple_quals,
1722  ra_exe_unit_in.quals,
1723  ra_exe_unit_in.join_quals,
1724  ra_exe_unit_in.groupby_exprs,
1725  ra_exe_unit_in.target_exprs,
1726  ra_exe_unit_in.target_exprs_original_type_infos,
1727  ra_exe_unit_in.estimator,
1728  ra_exe_unit_in.sort_info,
1729  new_scan_limit,
1730  ra_exe_unit_in.query_hint,
1731  ra_exe_unit_in.query_plan_dag_hash,
1732  ra_exe_unit_in.hash_table_build_plan_dag,
1733  ra_exe_unit_in.table_id_to_node_map,
1734  ra_exe_unit_in.use_bump_allocator,
1735  ra_exe_unit_in.union_all,
1736  ra_exe_unit_in.query_state};
1737 }
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 3096 of file Execute.cpp.

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

Referenced by Executor::fetchUnionChunks().

3099  {
3100  size_t const begin = local_col_id - local_col_id % N; // N divides begin
3101  size_t const end = begin + N;
3102  CHECK_LE(end, frag_col_buffers.size()) << (void*)ptr << ' ' << local_col_id << ' ' << N;
3103  for (size_t i = begin; i < end; ++i) {
3104  frag_col_buffers[i] = ptr;
3105  }
3106 }
#define CHECK_LE(x, y)
Definition: Logger.h:233
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 1601 of file Execute.cpp.

References Default, SpeculativeTopN, StreamingTopN, and UNREACHABLE.

Referenced by operator<<().

1601  {
1602  switch (algorithm) {
1604  return "ResultSet";
1606  return "Speculative Top N";
1608  return "Streaming Top N";
1609  }
1610  UNREACHABLE();
1611  return "";
1612 }
#define UNREACHABLE()
Definition: Logger.h:266

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

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

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

2806  {
2807  const int table_id = col_desc->getScanDesc().getTableId();
2808  const int col_id = col_desc->getColId();
2809  return get_column_descriptor_maybe(col_id, table_id, cat);
2810 }
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: