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

Classes

class  ExprTableIdVisitor
 

Functions

void add_qualifier_to_execution_unit (RelAlgExecutionUnit &ra_exe_unit, const std::shared_ptr< Analyzer::Expr > &qual)
 
void check_if_loop_join_is_allowed (RelAlgExecutionUnit &ra_exe_unit, const ExecutionOptions &eo, const std::vector< InputTableInfo > &query_infos, const size_t level_idx, const std::string &fail_reason)
 
void check_valid_join_qual (std::shared_ptr< Analyzer::BinOper > &bin_oper)
 

Function Documentation

void anonymous_namespace{IRCodegen.cpp}::add_qualifier_to_execution_unit ( RelAlgExecutionUnit ra_exe_unit,
const std::shared_ptr< Analyzer::Expr > &  qual 
)

Definition at line 474 of file IRCodegen.cpp.

References qual_to_conjunctive_form(), RelAlgExecutionUnit::quals, and RelAlgExecutionUnit::simple_quals.

Referenced by Executor::buildCurrentLevelHashTable().

475  {
476  const auto qual_cf = qual_to_conjunctive_form(qual);
477  ra_exe_unit.simple_quals.insert(ra_exe_unit.simple_quals.end(),
478  qual_cf.simple_quals.begin(),
479  qual_cf.simple_quals.end());
480  ra_exe_unit.quals.insert(
481  ra_exe_unit.quals.end(), qual_cf.quals.begin(), qual_cf.quals.end());
482 }
QualsConjunctiveForm qual_to_conjunctive_form(const std::shared_ptr< Analyzer::Expr > qual_expr)
std::list< std::shared_ptr< Analyzer::Expr > > quals
std::list< std::shared_ptr< Analyzer::Expr > > simple_quals

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void anonymous_namespace{IRCodegen.cpp}::check_if_loop_join_is_allowed ( RelAlgExecutionUnit ra_exe_unit,
const ExecutionOptions eo,
const std::vector< InputTableInfo > &  query_infos,
const size_t  level_idx,
const std::string &  fail_reason 
)

Definition at line 484 of file IRCodegen.cpp.

References ExecutionOptions::allow_loop_joins, g_trivial_loop_join_threshold, get_loop_join_size(), RelAlgExecutionUnit::input_descs, RegisteredQueryHint::isHintRegistered(), RelAlgExecutionUnit::join_quals, kDisableLoopJoin, kLoopJoinInnerTableMaxNumRows, RegisteredQueryHint::loop_join_inner_table_max_num_rows, and RelAlgExecutionUnit::query_hint.

488  {
489  if (ra_exe_unit.input_descs.size() < 2) {
490  // We only support loop join at the end of folded joins
491  // where ra_exe_unit.input_descs.size() > 2 for now.
492  throw std::runtime_error("Hash join failed, reason(s): " + fail_reason +
493  " | Incorrect # tables for executing loop join");
494  }
495  const auto loop_join_size = get_loop_join_size(query_infos, ra_exe_unit);
496  const bool has_loop_size_hint =
498  const size_t loop_join_size_threshold =
499  has_loop_size_hint ? ra_exe_unit.query_hint.loop_join_inner_table_max_num_rows
501  if (eo.allow_loop_joins) {
502  if (has_loop_size_hint && loop_join_size_threshold < loop_join_size) {
503  throw std::runtime_error(
504  "Hash join failed, reason(s): " + fail_reason +
505  " | Cannot fall back to loop join for non-trivial inner table size");
506  }
507  return;
508  }
509  if (level_idx + 1 != ra_exe_unit.join_quals.size()) {
510  throw std::runtime_error(
511  "Hash join failed, reason(s): " + fail_reason +
512  " | Cannot fall back to loop join for intermediate join quals");
513  }
514  if (loop_join_size_threshold < loop_join_size) {
515  throw std::runtime_error(
516  "Hash join failed, reason(s): " + fail_reason +
517  " | Cannot fall back to loop join for non-trivial inner table size");
518  }
519  if (ra_exe_unit.query_hint.isHintRegistered(kDisableLoopJoin)) {
520  throw std::runtime_error("Hash join failed, reason(s): " + fail_reason +
521  " | Loop join is disabled by user");
522  }
523 }
std::vector< InputDescriptor > input_descs
unsigned g_trivial_loop_join_threshold
Definition: Execute.cpp:89
const JoinQualsPerNestingLevel join_quals
bool isHintRegistered(const QueryHint hint) const
Definition: QueryHint.h:348
RegisteredQueryHint query_hint
size_t loop_join_inner_table_max_num_rows
Definition: QueryHint.h:324
size_t get_loop_join_size(const std::vector< InputTableInfo > &query_infos, const RelAlgExecutionUnit &ra_exe_unit)
Definition: Execute.cpp:1579

+ Here is the call graph for this function:

void anonymous_namespace{IRCodegen.cpp}::check_valid_join_qual ( std::shared_ptr< Analyzer::BinOper > &  bin_oper)

Definition at line 525 of file IRCodegen.cpp.

References SQLTypeInfo::get_type(), Analyzer::Expr::get_type_info(), and kARRAY.

Referenced by Executor::buildCurrentLevelHashTable().

525  {
526  // check whether a join qual is valid before entering the hashtable build and codegen
527 
528  auto lhs_cv = dynamic_cast<const Analyzer::ColumnVar*>(bin_oper->get_left_operand());
529  auto rhs_cv = dynamic_cast<const Analyzer::ColumnVar*>(bin_oper->get_right_operand());
530  if (lhs_cv && rhs_cv && !bin_oper->is_overlaps_oper()) {
531  auto lhs_type = lhs_cv->get_type_info().get_type();
532  auto rhs_type = rhs_cv->get_type_info().get_type();
533  // check #1. avoid a join btw full array columns
534  if (lhs_type == SQLTypes::kARRAY && rhs_type == SQLTypes::kARRAY) {
535  throw std::runtime_error(
536  "Join operation between full array columns (i.e., R.arr = S.arr) instead of "
537  "indexed array columns (i.e., R.arr[1] = S.arr[2]) is not supported yet.");
538  }
539  }
540 }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:380
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:83

+ Here is the call graph for this function:

+ Here is the caller graph for this function: