OmniSciDB  c1a53651b2
 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)
 
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)
 
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 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)
 
size_t get_selected_input_descs_index (const shared::TableKey &table_key, std::vector< InputDescriptor > const &input_descs)
 
size_t get_selected_input_col_descs_index (const shared::TableKey &table_key, std::list< std::shared_ptr< InputColDescriptor const >> const &input_col_descs)
 
std::list< std::shared_ptr
< const InputColDescriptor > > 
get_selected_input_col_descs (const shared::TableKey &table_key, 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, const shared::TableKey &table_key)
 
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,
const shared::TableKey table_key 
)

Definition at line 3918 of file Execute.cpp.

References CHECK, and CHECK_EQ.

Referenced by Executor::addDeletedColumn().

3920  {
3921  auto deleted_cols_it = deleted_cols_map.find(table_key);
3922  if (deleted_cols_it == deleted_cols_map.end()) {
3923  CHECK(deleted_cols_map.insert(std::make_pair(table_key, deleted_cd)).second);
3924  } else {
3925  CHECK_EQ(deleted_cd, deleted_cols_it->second);
3926  }
3927 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
#define CHECK(condition)
Definition: Logger.h:291

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

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

Referenced by Executor::collectAllDeviceResults().

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

References CHECK.

Referenced by Executor::executePlanWithGroupBy().

3512  {
3513  CHECK(scan_limit);
3514  return results && results->rowCount() < scan_limit;
3515 }
#define CHECK(condition)
Definition: Logger.h:291

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

Definition at line 1516 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().

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

References CHECK.

Referenced by Executor::executeWorkUnitImpl().

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

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

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

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

Referenced by Executor::skipFragment().

3985  {
3986  const int32_t ldim = lhs_type.get_dimension();
3987  const int32_t rdim = rhs_type.get_dimension();
3988  CHECK(ldim != rdim);
3989  const auto scale = DateTimeUtils::get_timestamp_precision_scale(abs(rdim - ldim));
3990  if (ldim > rdim) {
3991  // LHS type precision is more than RHS col type. No chance of overflow/underflow.
3992  return {true, chunk_min / scale, chunk_max / scale};
3993  }
3994 
3995  using checked_int64_t = boost::multiprecision::number<
3996  boost::multiprecision::cpp_int_backend<64,
3997  64,
3998  boost::multiprecision::signed_magnitude,
3999  boost::multiprecision::checked,
4000  void>>;
4001 
4002  try {
4003  auto ret =
4004  std::make_tuple(true,
4005  int64_t(checked_int64_t(chunk_min) * checked_int64_t(scale)),
4006  int64_t(checked_int64_t(chunk_max) * checked_int64_t(scale)));
4007  return ret;
4008  } catch (const std::overflow_error& e) {
4009  // noop
4010  }
4011  return std::make_tuple(false, chunk_min, chunk_max);
4012 }
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:383
#define CHECK(condition)
Definition: Logger.h:291
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 1252 of file Execute.cpp.

References CHECK, and result_set::first_dict_encoded_idx().

Referenced by Executor::resultsUnion().

1254  {
1255  auto& first = results_per_device.front().first;
1256  CHECK(first);
1257  auto const first_target_idx = result_set::first_dict_encoded_idx(targets);
1258  if (first_target_idx) {
1259  first->translateDictEncodedColumns(targets, *first_target_idx);
1260  }
1261  for (size_t dev_idx = 1; dev_idx < results_per_device.size(); ++dev_idx) {
1262  const auto& next = results_per_device[dev_idx].first;
1263  CHECK(next);
1264  if (first_target_idx) {
1265  next->translateDictEncodedColumns(targets, *first_target_idx);
1266  }
1267  first->append(*next);
1268  }
1269  return std::move(first);
1270 }
std::optional< size_t > first_dict_encoded_idx(std::vector< TargetInfo > const &)
Definition: ResultSet.cpp:1570
#define CHECK(condition)
Definition: Logger.h:291

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

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

Referenced by Executor::reduceMultiDeviceResultSets().

1338  {
1339  auto clock_begin = timer_start();
1340  // ResultSetReductionJIT::codegen compilation-locks if new code will be generated
1341  *compilation_queue_time = timer_stop(clock_begin);
1342  const auto& this_result_set = results_per_device[0].first;
1343  ResultSetReductionJIT reduction_jit(this_result_set->getQueryMemDesc(),
1344  this_result_set->getTargetInfos(),
1345  this_result_set->getTargetInitVals(),
1346  executor_id);
1347  return reduction_jit.codegen();
1348 };
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 ( const shared::TableKey table_key,
std::list< std::shared_ptr< InputColDescriptor const >> const &  input_col_descs 
)

Definition at line 3074 of file Execute.cpp.

Referenced by Executor::fetchUnionChunks().

3076  {
3077  std::list<std::shared_ptr<const InputColDescriptor>> selected;
3078  for (auto const& input_col_desc : input_col_descs) {
3079  if (table_key == input_col_desc->getScanDesc().getTableKey()) {
3080  selected.push_back(input_col_desc);
3081  }
3082  }
3083  return selected;
3084 }

+ Here is the caller graph for this function:

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

Definition at line 3063 of file Execute.cpp.

Referenced by Executor::fetchUnionChunks().

3065  {
3066  auto const has_table_key = [&table_key](auto const& input_desc) {
3067  return table_key == input_desc->getScanDesc().getTableKey();
3068  };
3069  return std::distance(
3070  input_col_descs.begin(),
3071  std::find_if(input_col_descs.begin(), input_col_descs.end(), has_table_key));
3072 }

+ Here is the caller graph for this function:

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

Definition at line 3054 of file Execute.cpp.

Referenced by Executor::fetchUnionChunks().

3055  {
3056  auto const has_table_key = [&table_key](InputDescriptor const& input_desc) {
3057  return table_key == input_desc.getTableKey();
3058  };
3059  return std::find_if(input_descs.begin(), input_descs.end(), has_table_key) -
3060  input_descs.begin();
3061 }

+ Here is the caller graph for this function:

std::string anonymous_namespace{Execute.cpp}::get_table_name ( const InputDescriptor input_desc)

Definition at line 1495 of file Execute.cpp.

References CHECK, CHECK_GT, Catalog_Namespace::get_metadata_for_table(), InputDescriptor::getSourceType(), InputDescriptor::getTableKey(), TABLE, shared::TableKey::table_id, and to_string().

1495  {
1496  const auto source_type = input_desc.getSourceType();
1497  if (source_type == InputSourceType::TABLE) {
1498  const auto& table_key = input_desc.getTableKey();
1499  CHECK_GT(table_key.table_id, 0);
1500  const auto td = Catalog_Namespace::get_metadata_for_table(table_key);
1501  CHECK(td);
1502  return td->tableName;
1503  } else {
1504  return "$TEMPORARY_TABLE" + std::to_string(-input_desc.getTableKey().table_id);
1505  }
1506 }
const TableDescriptor * get_metadata_for_table(const ::shared::TableKey &table_key, bool populate_fragmenter)
#define CHECK_GT(x, y)
Definition: Logger.h:305
std::string to_string(char const *&&v)
const shared::TableKey & getTableKey() const
InputSourceType getSourceType() const
#define CHECK(condition)
Definition: Logger.h:291

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

References GPU, and Executor::high_scan_limit.

Referenced by checkWorkUnitWatchdog().

1509  {
1510  if (device_type == ExecutorDeviceType::GPU) {
1511  return device_count * Executor::high_scan_limit;
1512  }
1514 }
static const size_t high_scan_limit
Definition: Execute.h:603

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

Referenced by Executor::createKernels().

2496  {
2497  for (const auto& col : fetched_cols) {
2498  if (col.is_lazily_fetched) {
2499  return true;
2500  }
2501  }
2502  return false;
2503 }

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

2206  {
2207  CHECK(ti.is_number() || ti.is_time() || ti.is_boolean() || ti.is_string());
2208  if (ti.is_fp()) {
2209  if (float_argument_input && ti.get_type() == kFLOAT) {
2210  int64_t float_null_val = 0;
2211  *reinterpret_cast<float*>(may_alias_ptr(&float_null_val)) =
2212  static_cast<float>(inline_fp_null_val(ti));
2213  return float_null_val;
2214  }
2215  const auto double_null_val = inline_fp_null_val(ti);
2216  return *reinterpret_cast<const int64_t*>(may_alias_ptr(&double_null_val));
2217  }
2218  return inline_int_null_val(ti);
2219 }
bool is_fp() const
Definition: sqltypes.h:584
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:381
bool is_number() const
Definition: sqltypes.h:585
double inline_fp_null_val(const SQL_TYPE_INFO &ti)
bool is_time() const
Definition: sqltypes.h:586
bool is_boolean() const
Definition: sqltypes.h:587
#define CHECK(condition)
Definition: Logger.h:291
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
bool is_string() const
Definition: sqltypes.h:580

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

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

Referenced by Executor::collectAllDeviceShardedTopResults().

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

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

Referenced by Executor::collectAllDeviceShardedTopResults().

2415  {
2416  const auto output_buffer = output_storage->getUnderlyingBuffer();
2417  const auto input_buffer = input_storage->getUnderlyingBuffer();
2418  for (const auto sorted_idx : top_permutation) {
2419  const auto row_ptr = input_buffer + sorted_idx * output_query_mem_desc.getRowSize();
2420  memcpy(output_buffer + output_row_index * output_query_mem_desc.getRowSize(),
2421  row_ptr,
2422  output_query_mem_desc.getRowSize());
2423  ++output_row_index;
2424  }
2425  return output_row_index;
2426 }
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)

Definition at line 189 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, db_id] : phys_inputs) {
191  foreign_storage::populate_string_dictionary(table_id, col_id, db_id);
192  }
193 }
void populate_string_dictionary(int32_t table_id, int32_t col_id, int32_t db_id)
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 3087 of file Execute.cpp.

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

Referenced by Executor::fetchUnionChunks().

3090  {
3091  size_t const begin = local_col_id - local_col_id % N; // N divides begin
3092  size_t const end = begin + N;
3093  CHECK_LE(end, frag_col_buffers.size()) << (void*)ptr << ' ' << local_col_id << ' ' << N;
3094  for (size_t i = begin; i < end; ++i) {
3095  frag_col_buffers[i] = ptr;
3096  }
3097 }
#define CHECK_LE(x, y)
Definition: Logger.h:304
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:337

+ Here is the caller graph for this function:

const ColumnDescriptor* anonymous_namespace{Execute.cpp}::try_get_column_descriptor ( const InputColDescriptor col_desc)

Definition at line 2798 of file Execute.cpp.

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

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

2798  {
2799  const auto& table_key = col_desc->getScanDesc().getTableKey();
2800  const auto col_id = col_desc->getColId();
2801  return get_column_descriptor_maybe({table_key, col_id});
2802 }
const ColumnDescriptor * get_column_descriptor_maybe(const shared::ColumnKey &column_key)
Definition: Execute.h:220
int getColId() const
const shared::TableKey & getTableKey() const
const InputDescriptor & getScanDesc() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function: