OmniSciDB  72c90bc290
 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 535 of file IRCodegen.cpp.

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

Referenced by Executor::buildCurrentLevelHashTable().

536  {
537  const auto qual_cf = qual_to_conjunctive_form(qual);
538  ra_exe_unit.simple_quals.insert(ra_exe_unit.simple_quals.end(),
539  qual_cf.simple_quals.begin(),
540  qual_cf.simple_quals.end());
541  ra_exe_unit.quals.insert(
542  ra_exe_unit.quals.end(), qual_cf.quals.begin(), qual_cf.quals.end());
543 }
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 545 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.

549  {
550  if (ra_exe_unit.input_descs.size() < 2) {
551  // We only support loop join at the end of folded joins
552  // where ra_exe_unit.input_descs.size() > 2 for now.
553  throw std::runtime_error("Hash join failed, reason(s): " + fail_reason +
554  " | Incorrect # tables for executing loop join");
555  }
556  const auto loop_join_size = get_loop_join_size(query_infos, ra_exe_unit);
557  const bool has_loop_size_hint =
559  const size_t loop_join_size_threshold =
560  has_loop_size_hint ? ra_exe_unit.query_hint.loop_join_inner_table_max_num_rows
562  if (eo.allow_loop_joins) {
563  if (has_loop_size_hint && loop_join_size_threshold < loop_join_size) {
564  throw std::runtime_error(
565  "Hash join failed, reason(s): " + fail_reason +
566  " | Cannot fall back to loop join for non-trivial inner table size");
567  }
568  return;
569  }
570  if (level_idx + 1 != ra_exe_unit.join_quals.size()) {
571  throw std::runtime_error(
572  "Hash join failed, reason(s): " + fail_reason +
573  " | Cannot fall back to loop join for intermediate join quals");
574  }
575  if (loop_join_size_threshold < loop_join_size) {
576  throw std::runtime_error(
577  "Hash join failed, reason(s): " + fail_reason +
578  " | Cannot fall back to loop join for non-trivial inner table size");
579  }
580  if (ra_exe_unit.query_hint.isHintRegistered(kDisableLoopJoin)) {
581  throw std::runtime_error("Hash join failed, reason(s): " + fail_reason +
582  " | Loop join is disabled by user");
583  }
584 }
std::vector< InputDescriptor > input_descs
unsigned g_trivial_loop_join_threshold
Definition: Execute.cpp:92
const JoinQualsPerNestingLevel join_quals
bool isHintRegistered(const QueryHint hint) const
Definition: QueryHint.h:383
RegisteredQueryHint query_hint
size_t loop_join_inner_table_max_num_rows
Definition: QueryHint.h:357
size_t get_loop_join_size(const std::vector< InputTableInfo > &query_infos, const RelAlgExecutionUnit &ra_exe_unit)
Definition: Execute.cpp:1880

+ 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 586 of file IRCodegen.cpp.

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

Referenced by Executor::buildCurrentLevelHashTable().

586  {
587  // check whether a join qual is valid before entering the hashtable build and codegen
588 
589  auto lhs_cv = dynamic_cast<const Analyzer::ColumnVar*>(bin_oper->get_left_operand());
590  auto rhs_cv = dynamic_cast<const Analyzer::ColumnVar*>(bin_oper->get_right_operand());
591  if (lhs_cv && rhs_cv && !bin_oper->is_bbox_intersect_oper()) {
592  auto lhs_type = lhs_cv->get_type_info().get_type();
593  auto rhs_type = rhs_cv->get_type_info().get_type();
594  // check #1. avoid a join btw full array columns
595  if (lhs_type == SQLTypes::kARRAY && rhs_type == SQLTypes::kARRAY) {
596  throw std::runtime_error(
597  "Join operation between full array columns (i.e., R.arr = S.arr) instead of "
598  "indexed array columns (i.e., R.arr[1] = S.arr[2]) is not supported yet.");
599  }
600  }
601  auto const lhs_et =
602  dynamic_cast<const Analyzer::ExpressionTuple*>(bin_oper->get_left_operand());
603  if (lhs_et) {
604  CHECK_LE(lhs_et->getTuple().size(), g_maximum_conditions_to_coalesce);
605  }
606 }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:391
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:79
#define CHECK_LE(x, y)
Definition: Logger.h:304
const size_t g_maximum_conditions_to_coalesce

+ Here is the call graph for this function:

+ Here is the caller graph for this function: