36 const std::vector<double>& inverse_bucket_sizes_for_dimension,
37 const std::vector<InnerOuter> inner_outer_pairs) {
43 const auto& inner_outer_pair = inner_outer_pairs[i];
44 const auto inner_col = inner_outer_pair.first;
45 const auto& ti = inner_col->get_type_info();
46 const auto elem_ti = ti.get_elem_type();
50 elem_ti.get_type() ==
kDOUBLE});
60 const std::vector<Fragmenter_Namespace::FragmentInfo>& fragment_info,
63 std::vector<std::shared_ptr<Chunk_NS::Chunk>>& chunks_owner,
65 std::vector<std::shared_ptr<void>>& malloc_owner,
68 static std::mutex fragment_fetch_mutex;
69 std::lock_guard<std::mutex> fragment_fetch_lock(fragment_fetch_mutex);
74 effective_memory_level,
82 CHECK(dev_buff_owner);
100 const int device_id) {
105 for (
size_t i = 0; i < memsz; ++i) {
117 const int device_id)
const {
118 return toStringFlat<int64_t>(
this, device_type, device_id);
122 const int device_id)
const {
123 return toStringFlat<int32_t>(
this, device_type, device_id);
129 for (
auto k : e.
key) {
172 os <<
"(" << inner_outer_string_op_infos.first <<
", "
173 << inner_outer_string_op_infos.second <<
")";
178 std::ostringstream os;
179 os << inner_outer_string_op_infos;
185 const std::vector<InnerOuterStringOpInfos>& inner_outer_string_op_infos_pairs) {
187 bool first_elem =
true;
188 for (
const auto& inner_outer_string_op_infos : inner_outer_string_op_infos_pairs) {
193 os << inner_outer_string_op_infos;
200 const std::vector<InnerOuterStringOpInfos>& inner_outer_string_op_infos_pairs) {
201 std::ostringstream os;
202 os << inner_outer_string_op_infos_pairs;
207 const std::vector<llvm::Value*>& hash_join_idx_args_in,
208 const bool is_sharded,
209 const bool col_is_nullable,
211 const int64_t sub_buff_size,
213 bool is_bucketized) {
215 using namespace std::string_literals;
217 std::string fname(is_bucketized ?
"bucketized_hash_join_idx"s :
"hash_join_idx"s);
225 if (!is_bw_eq && col_is_nullable) {
226 fname +=
"_nullable";
229 const auto slot_lv = executor->cgen_state_->emitCall(fname, hash_join_idx_args_in);
230 const auto slot_valid_lv = executor->cgen_state_->ir_builder_.CreateICmpSGE(
231 slot_lv, executor->cgen_state_->llInt(int64_t(0)));
233 auto pos_ptr = hash_join_idx_args_in[0];
236 auto count_ptr = executor->cgen_state_->ir_builder_.CreateAdd(
237 pos_ptr, executor->cgen_state_->llInt(sub_buff_size));
238 auto hash_join_idx_args = hash_join_idx_args_in;
239 hash_join_idx_args[0] = executor->cgen_state_->ir_builder_.CreatePtrToInt(
240 count_ptr, llvm::Type::getInt64Ty(executor->cgen_state_->context_));
242 const auto row_count_lv = executor->cgen_state_->ir_builder_.CreateSelect(
244 executor->cgen_state_->emitCall(fname, hash_join_idx_args),
245 executor->cgen_state_->llInt(int64_t(0)));
246 auto rowid_base_i32 = executor->cgen_state_->ir_builder_.CreateIntToPtr(
247 executor->cgen_state_->ir_builder_.CreateAdd(
248 pos_ptr, executor->cgen_state_->llInt(2 * sub_buff_size)),
249 llvm::Type::getInt32PtrTy(executor->cgen_state_->context_));
250 auto rowid_ptr_i32 = executor->cgen_state_->ir_builder_.CreateGEP(
251 rowid_base_i32->getType()->getScalarType()->getPointerElementType(),
254 return {rowid_ptr_i32, row_count_lv, slot_lv};
259 llvm::Value* hash_ptr =
nullptr;
260 const auto total_table_count =
261 executor->plan_state_->join_info_.join_hash_tables_.size();
262 CHECK_LT(table_idx, total_table_count);
263 if (total_table_count > 1) {
264 auto hash_tables_ptr =
268 ? executor->cgen_state_->ir_builder_.CreateGEP(
269 hash_tables_ptr->getType()->getScalarType()->getPointerElementType(),
271 executor->cgen_state_->llInt(static_cast<int64_t>(table_idx)))
273 hash_ptr = executor->cgen_state_->ir_builder_.CreateLoad(
274 hash_pptr->getType()->getPointerElementType(), hash_pptr);
276 hash_ptr =
get_arg_by_name(executor->cgen_state_->row_func_,
"join_hash_tables");
284 const std::shared_ptr<Analyzer::BinOper> qual_bin_oper,
285 const std::vector<InputTableInfo>& query_infos,
289 const int device_count,
296 std::shared_ptr<HashJoin> join_hash_table;
299 throw std::runtime_error(
300 "Overlaps hash join disabled, attempting to fall back to loop join");
302 if (qual_bin_oper->is_overlaps_oper()) {
303 VLOG(1) <<
"Trying to build geo hash table:";
311 hashtable_build_dag_map,
313 table_id_to_node_map);
314 }
else if (dynamic_cast<const Analyzer::ExpressionTuple*>(
315 qual_bin_oper->get_left_operand())) {
316 VLOG(1) <<
"Trying to build keyed hash table:";
325 hashtable_build_dag_map,
326 table_id_to_node_map);
329 VLOG(1) <<
"Trying to build perfect hash table:";
338 hashtable_build_dag_map,
339 table_id_to_node_map);
342 CHECK_EQ(join_quals.size(), size_t(1));
343 const auto join_qual =
345 VLOG(1) <<
"Trying to build keyed hash table after perfect hash table:";
354 hashtable_build_dag_map,
355 table_id_to_node_map);
358 CHECK(join_hash_table);
361 for (
int device_id = 0; device_id < join_hash_table->getDeviceCount();
365 VLOG(2) <<
"Built GPU hash table: "
371 VLOG(2) <<
"Built CPU hash table: "
376 return join_hash_table;
379 std::pair<const StringDictionaryProxy*, StringDictionaryProxy*>
381 const Executor* executor,
382 const bool has_string_ops) {
383 const auto inner_col = cols.first;
385 const auto inner_ti = inner_col->get_type_info();
387 std::pair<const StringDictionaryProxy*, StringDictionaryProxy*>
388 inner_outer_str_dict_proxies{
nullptr,
nullptr};
389 if (inner_ti.is_string() && outer_col) {
390 CHECK(outer_col->get_type_info().is_string());
391 inner_outer_str_dict_proxies.first =
392 executor->getStringDictionaryProxy(inner_col->get_comp_param(),
true);
393 CHECK(inner_outer_str_dict_proxies.first);
394 inner_outer_str_dict_proxies.second =
395 executor->getStringDictionaryProxy(outer_col->get_comp_param(),
true);
396 CHECK(inner_outer_str_dict_proxies.second);
397 if (!has_string_ops &&
398 *inner_outer_str_dict_proxies.first == *inner_outer_str_dict_proxies.second) {
400 CHECK(inner_col->get_comp_param() == outer_col->get_comp_param());
401 inner_outer_str_dict_proxies.first =
nullptr;
402 inner_outer_str_dict_proxies.second =
nullptr;
405 return inner_outer_str_dict_proxies;
412 const Executor* executor) {
413 const bool has_string_ops = inner_outer_string_op_infos.first.
size() ||
414 inner_outer_string_op_infos.second.size();
415 const auto inner_outer_proxies =
417 const bool translate_dictionary =
418 inner_outer_proxies.first && inner_outer_proxies.second;
419 if (translate_dictionary) {
420 const auto inner_dict_id = inner_outer_proxies.first->getDictId();
421 const auto outer_dict_id = inner_outer_proxies.second->getDictId();
422 CHECK(has_string_ops || inner_dict_id != outer_dict_id);
423 const auto id_map = executor->getJoinIntersectionStringProxyTranslationMap(
424 inner_outer_proxies.first,
425 inner_outer_proxies.second,
426 inner_outer_string_op_infos.first,
427 inner_outer_string_op_infos.second,
428 executor->getRowSetMemoryOwner());
429 if (!inner_outer_string_op_infos.second.empty()) {
434 static_cast<int64_t
>(
435 inner_outer_proxies.second->transientEntryCount() + 1) *
447 const std::vector<Fragmenter_Namespace::FragmentInfo>& fragments) {
448 auto const fragment_id = [](
auto const& frag_info) {
return frag_info.fragmentId; };
449 std::vector<int> frag_ids(fragments.size());
450 std::transform(fragments.cbegin(), fragments.cend(), frag_ids.begin(), fragment_id);
451 std::sort(frag_ids.begin(), frag_ids.end());
456 const std::vector<InnerOuter>& inner_outer_pairs,
457 const Executor* executor,
458 const std::vector<InnerOuterStringOpInfos>& inner_outer_string_op_infos_pairs) {
460 std::vector<const void*> sd_inner_proxy_per_key;
461 std::vector<void*> sd_outer_proxy_per_key;
462 std::vector<ChunkKey> cache_key_chunks;
463 const auto db_id = executor->getCatalog()->getCurrentDB().dbId;
464 const bool has_string_op_infos = inner_outer_string_op_infos_pairs.size();
465 if (has_string_op_infos) {
466 CHECK_EQ(inner_outer_pairs.size(), inner_outer_string_op_infos_pairs.size());
468 size_t string_op_info_pairs_idx = 0;
469 for (
const auto& inner_outer_pair : inner_outer_pairs) {
470 const auto inner_col = inner_outer_pair.first;
471 const auto outer_col = inner_outer_pair.second;
472 const auto& inner_ti = inner_col->get_type_info();
473 const auto& outer_ti = outer_col->get_type_info();
474 ChunkKey cache_key_chunks_for_column{
475 db_id, inner_col->get_table_id(), inner_col->get_column_id()};
476 if (inner_ti.is_string() &&
477 (!(inner_ti.get_comp_param() == outer_ti.get_comp_param()) ||
478 (has_string_op_infos &&
479 (inner_outer_string_op_infos_pairs[string_op_info_pairs_idx].first.size() ||
480 inner_outer_string_op_infos_pairs[string_op_info_pairs_idx].second.size())))) {
481 CHECK(outer_ti.is_string());
484 const auto sd_inner_proxy = executor->getStringDictionaryProxy(
485 inner_ti.get_comp_param(), executor->getRowSetMemoryOwner(),
true);
486 auto sd_outer_proxy = executor->getStringDictionaryProxy(
487 outer_ti.get_comp_param(), executor->getRowSetMemoryOwner(),
true);
488 CHECK(sd_inner_proxy && sd_outer_proxy);
489 sd_inner_proxy_per_key.push_back(sd_inner_proxy);
490 sd_outer_proxy_per_key.push_back(sd_outer_proxy);
491 cache_key_chunks_for_column.push_back(sd_outer_proxy->getGeneration());
493 sd_inner_proxy_per_key.emplace_back();
494 sd_outer_proxy_per_key.emplace_back();
496 cache_key_chunks.push_back(cache_key_chunks_for_column);
497 string_op_info_pairs_idx++;
499 return {sd_inner_proxy_per_key, sd_outer_proxy_per_key, cache_key_chunks};
502 std::vector<const StringDictionaryProxy::IdMap*>
505 const std::vector<InnerOuterStringOpInfos>& string_op_infos_for_keys,
506 const Executor* executor) {
509 const size_t num_proxies = inner_proxies.size();
510 CHECK_EQ(num_proxies, outer_proxies.size());
511 std::vector<const StringDictionaryProxy::IdMap*> proxy_translation_maps;
512 proxy_translation_maps.reserve(num_proxies);
513 for (
size_t proxy_pair_idx = 0; proxy_pair_idx < num_proxies; ++proxy_pair_idx) {
514 const bool translate_proxies =
515 inner_proxies[proxy_pair_idx] && outer_proxies[proxy_pair_idx];
516 if (translate_proxies) {
517 const auto inner_proxy =
524 CHECK_NE(inner_proxy->getDictId(), outer_proxy->getDictId());
525 proxy_translation_maps.emplace_back(
526 executor->getJoinIntersectionStringProxyTranslationMap(
529 string_op_infos_for_keys[proxy_pair_idx].first,
530 string_op_infos_for_keys[proxy_pair_idx].second,
531 executor->getRowSetMemoryOwner()));
533 proxy_translation_maps.emplace_back(
nullptr);
536 return proxy_translation_maps;
541 const std::vector<StringOps_Namespace::StringOpInfo>& string_op_infos,
544 if (!string_op_infos.empty()) {
545 const auto coerced_col_var =
547 CHECK(coerced_col_var);
548 std::vector<llvm::Value*> codegen_val_vec{
550 return codegen_val_vec[0];
552 return code_generator.
codegen(col_or_string_oper,
true, co)[0];
556 std::string_view column,
558 Executor* executor) {
559 auto catalog = executor->getCatalog();
562 auto tmeta = catalog->getMetadataForTable(std::string(table));
565 auto cmeta = catalog->getMetadataForColumn(tmeta->tableId, std::string(column));
568 auto ti = cmeta->columnType;
570 if (ti.is_geometry() && ti.get_type() !=
kPOINT) {
572 switch (ti.get_type()) {
574 geoColumnId = cmeta->columnId + 2;
578 geoColumnId = cmeta->columnId + 3;
582 geoColumnId = cmeta->columnId + 4;
588 cmeta = catalog->getMetadataForColumn(tmeta->tableId, geoColumnId);
590 ti = cmeta->columnType;
594 std::make_shared<Analyzer::ColumnVar>(ti, tmeta->tableId, cmeta->columnId, rte_idx);
609 std::set<const Analyzer::ColumnVar*>
result;
610 for (
const auto& expr_component : expr_tuple->
getTuple()) {
611 const auto component_rte_set = visitor.
visit(expr_component.get());
612 result.insert(component_rte_set.begin(), component_rte_set.end());
618 const std::set<const Analyzer::ColumnVar*>& aggregate,
619 const std::set<const Analyzer::ColumnVar*>& next_result)
const override {
621 result.insert(next_result.begin(), next_result.end());
627 std::unordered_set<int> phys_table_ids;
628 for (
auto cv : cvs) {
629 phys_table_ids.insert(cv->get_table_id());
632 std::unordered_set<PhysicalInput> phys_inputs;
633 for (
auto cv : cvs) {
634 phys_inputs.emplace(
PhysicalInput{cv->get_column_id(), cv->get_table_id()});
637 executor->setupCaching(phys_inputs, phys_table_ids);
641 std::set<const Analyzer::ColumnVar*> cvs,
642 Executor* executor) {
643 auto catalog = executor->getCatalog();
646 std::unordered_set<int> phys_table_ids;
647 for (
auto cv : cvs) {
648 phys_table_ids.insert(cv->get_table_id());
654 std::vector<InputTableInfo> query_infos(phys_table_ids.size());
656 for (
auto id : phys_table_ids) {
657 auto tmeta = catalog->getMetadataForTable(
id);
658 query_infos[i].table_id = id;
659 query_infos[i].info = tmeta->fragmenter->getFragmentsForQuery();
668 std::string_view table1,
669 std::string_view column1,
670 std::string_view table2,
671 std::string_view column2,
674 const int device_count,
676 Executor* executor) {
680 auto qual_bin_oper = std::make_shared<Analyzer::BinOper>(
kBOOLEAN,
kEQ,
kONE, a1, a2);
682 std::set<const Analyzer::ColumnVar*> cvs =
704 const std::shared_ptr<Analyzer::BinOper> qual_bin_oper,
707 const int device_count,
709 Executor* executor) {
710 std::set<const Analyzer::ColumnVar*> cvs =
731 std::vector<std::shared_ptr<Analyzer::BinOper>> qual_bin_opers,
734 const int device_count,
736 Executor* executor) {
737 std::set<const Analyzer::ColumnVar*> cvs;
738 for (
auto& qual : qual_bin_opers) {
740 cvs.insert(cv.begin(), cv.end());
745 std::shared_ptr<HashJoin> hash_table;
746 std::string error_msg;
747 for (
auto& qual : qual_bin_opers) {
760 if (candidate_hash_table) {
761 hash_table = candidate_hash_table;
764 error_msg = e.what();
768 return std::make_pair(error_msg, hash_table);
772 const size_t shard_count,
773 const Executor* executor) {
779 const auto inner_td = executor->getCatalog()->getMetadataForTable(table_id);
787 template <
typename T>
789 auto* target_expr = expr;
790 if (
auto cast_expr = dynamic_cast<const Analyzer::UOper*>(expr)) {
791 target_expr = cast_expr->get_operand();
794 return dynamic_cast<const T*
>(target_expr);
802 const bool is_overlaps_join) {
805 if (!is_overlaps_join) {
807 throw HashJoinFail(
"Equijoin types must be identical, found: " +
812 throw HashJoinFail(
"Cannot apply hash join to inner column type " +
818 throw HashJoinFail(
"Equijoin with different decimal types");
824 if (lhs_ti.
is_string() && (
static_cast<bool>(lhs_cast) != static_cast<bool>(rhs_cast) ||
825 (lhs_cast && lhs_cast->get_optype() !=
kCAST) ||
826 (rhs_cast && rhs_cast->get_optype() !=
kCAST))) {
828 "Cannot use hash join for given expression (non-cast unary operator)");
831 if (lhs_ti.
is_decimal() && (lhs_cast || rhs_cast)) {
832 throw HashJoinFail(
"Cannot use hash join for given expression (cast to decimal)");
834 auto lhs_col = getHashJoinColumn<Analyzer::ColumnVar>(lhs);
835 auto rhs_col = getHashJoinColumn<Analyzer::ColumnVar>(rhs);
837 const auto lhs_string_oper = getHashJoinColumn<Analyzer::StringOper>(lhs);
838 const auto rhs_string_oper = getHashJoinColumn<Analyzer::StringOper>(rhs);
840 auto process_string_op_infos = [](
const auto& string_oper,
auto& col,
auto& ti) {
841 std::vector<StringOps_Namespace::StringOpInfo> string_op_infos;
853 "Hash joins involving string operators currently restricted to column inputs "
854 "(i.e. not case statements).");
856 ti = col->get_type_info();
857 CHECK(ti.is_dict_encoded_string());
858 const auto chained_string_op_exprs = string_oper->getChainedStringOpExprs();
859 CHECK_GT(chained_string_op_exprs.size(), 0UL);
860 for (
const auto& chained_string_op_expr : chained_string_op_exprs) {
861 auto chained_string_op =
863 CHECK(chained_string_op);
865 chained_string_op->get_kind(), chained_string_op->getLiteralArgs());
866 string_op_infos.emplace_back(string_op_info);
869 return string_op_infos;
872 auto outer_string_op_infos = process_string_op_infos(lhs_string_oper, lhs_col, lhs_ti);
873 auto inner_string_op_infos = process_string_op_infos(rhs_string_oper, rhs_col, rhs_ti);
875 if (!lhs_col && !rhs_col) {
877 "Cannot use hash join for given expression (both lhs and rhs are invalid)",
883 auto outer_ti = lhs_ti;
884 auto inner_ti = rhs_ti;
887 if (!lhs_col || (rhs_col && lhs_col->get_rte_idx() < rhs_col->get_rte_idx())) {
893 if (lhs_col && lhs_col->get_rte_idx() == 0) {
895 "Cannot use hash join for given expression (lhs' rte idx is zero)",
896 inner_qual_decision);
901 std::swap(outer_string_op_infos, inner_string_op_infos);
905 throw HashJoinFail(
"Cannot use hash join for given expression (invalid inner col)",
906 inner_qual_decision);
911 if (outer_constant_col) {
913 "Cannot use hash join for given expression: try to join with a constant "
915 inner_qual_decision);
918 int outer_rte_idx = rte_idx_visitor.
visit(outer_expr);
921 if (inner_col->get_rte_idx() <= outer_rte_idx) {
923 "Cannot use hash join for given expression (inner's rte <= outer's rte)",
924 inner_qual_decision);
930 inner_col->get_column_id(), inner_col->get_table_id(),
cat);
931 const auto inner_col_real_ti =
get_column_type(inner_col->get_column_id(),
932 inner_col->get_table_id(),
935 const auto& outer_col_ti =
937 ? outer_col->get_type_info()
940 if ((inner_col_real_ti.is_decimal() || outer_col_ti.is_decimal()) &&
941 (lhs_cast || rhs_cast)) {
942 throw HashJoinFail(
"Cannot use hash join for given expression (cast from decimal)");
944 if (is_overlaps_join) {
945 if (!inner_col_real_ti.is_array()) {
947 "Overlaps join only supported for inner columns with array type");
949 auto is_bounds_array = [](
const auto ti) {
950 return ti.is_fixlen_array() && ti.get_size() == 32;
952 if (!is_bounds_array(inner_col_real_ti)) {
954 "Overlaps join only supported for 4-element double fixed length arrays");
956 if (!(outer_col_ti.get_type() ==
kPOINT || is_bounds_array(outer_col_ti) ||
959 "Overlaps join only supported for geometry outer columns of type point, "
960 "geometry columns with bounds or constructed points");
963 if (!(inner_col_real_ti.is_integer() || inner_col_real_ti.is_time() ||
964 inner_col_real_ti.is_decimal() ||
965 (inner_col_real_ti.is_string() &&
968 "Can only apply hash join to integer-like types and dictionary encoded "
973 auto normalized_inner_col = inner_col;
974 auto normalized_outer_col = outer_col ? outer_col : outer_expr;
976 const auto& normalized_inner_ti = normalized_inner_col->get_type_info();
977 const auto& normalized_outer_ti = normalized_outer_col->get_type_info();
979 if (normalized_inner_ti.is_string() != normalized_outer_ti.is_string()) {
980 throw HashJoinFail(std::string(
"Could not build hash tables for incompatible types " +
981 normalized_inner_ti.get_type_name() +
" and " +
982 normalized_outer_ti.get_type_name()));
984 return std::make_pair(std::make_pair(normalized_inner_col, normalized_outer_col),
985 std::make_pair(inner_string_op_infos, outer_string_op_infos));
988 std::pair<std::vector<InnerOuter>, std::vector<InnerOuterStringOpInfos>>
992 std::pair<std::vector<InnerOuter>, std::vector<InnerOuterStringOpInfos>>
result;
993 const auto lhs_tuple_expr =
995 const auto rhs_tuple_expr =
998 CHECK_EQ(static_cast<bool>(lhs_tuple_expr), static_cast<bool>(rhs_tuple_expr));
999 if (lhs_tuple_expr) {
1000 const auto& lhs_tuple = lhs_tuple_expr->getTuple();
1001 const auto& rhs_tuple = rhs_tuple_expr->getTuple();
1002 CHECK_EQ(lhs_tuple.size(), rhs_tuple.size());
1003 for (
size_t i = 0; i < lhs_tuple.size(); ++i) {
1009 result.first.emplace_back(col_pair.first);
1010 result.second.emplace_back(col_pair.second);
1013 CHECK(!lhs_tuple_expr && !rhs_tuple_expr);
1019 result.first.emplace_back(col_pair.first);
1020 result.second.emplace_back(col_pair.second);
1027 bool invalid_cache_key,
1046 const Executor* executor) {
1049 std::shared_ptr<Analyzer::BinOper> redirected_bin_oper;
1051 std::tie(inner_col, outer_col) =
1052 get_cols(join_condition, *executor->getCatalog(), executor->getTemporaryTables());
1056 if (!inner_col || !outer_col) {
static std::vector< int > collectFragmentIds(const std::vector< Fragmenter_Namespace::FragmentInfo > &fragments)
int64_t getIntMin() const
std::vector< int > ChunkKey
std::vector< InputTableInfo > getSyntheticInputTableInfo(std::set< const Analyzer::ColumnVar * > cvs, Executor *executor)
virtual HashJoinMatchingSet codegenMatchingSet(const CompilationOptions &, const size_t)=0
static llvm::Value * codegenHashTableLoad(const size_t table_idx, Executor *executor)
class for a per-database catalog. also includes metadata for the current database and the current use...
std::pair< const Analyzer::ColumnVar *, const Analyzer::Expr * > InnerOuter
std::string toStringFlat(const HashJoin *hash_table, const ExecutorDeviceType device_type, const int device_id)
static bool canAccessHashTable(bool allow_hash_table_recycling, bool invalid_cache_key, JoinType join_type)
std::vector< const void * > sd_inner_proxy_per_key
virtual std::string toStringFlat64(const ExecutorDeviceType device_type, const int device_id) const
std::list< std::shared_ptr< Analyzer::Expr > > coalesce_singleton_equi_join(const std::shared_ptr< Analyzer::BinOper > &join_qual)
std::ostream & operator<<(std::ostream &os, const SessionInfo &session_info)
static std::pair< std::vector< InnerOuter >, std::vector< InnerOuterStringOpInfos > > normalizeColumnPairs(const Analyzer::BinOper *condition, const Catalog_Namespace::Catalog &cat, const TemporaryTables *temporary_tables)
static JoinColumn makeJoinColumn(Executor *executor, const Analyzer::ColumnVar &hash_col, const std::vector< Fragmenter_Namespace::FragmentInfo > &fragments, const Data_Namespace::MemoryLevel effective_mem_lvl, const int device_id, DeviceAllocator *device_allocator, const size_t thread_idx, std::vector< std::shared_ptr< Chunk_NS::Chunk >> &chunks_owner, std::vector< std::shared_ptr< void >> &malloc_owner, ColumnCacheMap &column_cache)
Creates a JoinColumn struct containing an array of JoinChunk structs.
void setBucketInfo(const std::vector< double > &bucket_sizes_for_dimension, const std::vector< InnerOuter > inner_outer_pairs)
std::set< const Analyzer::ColumnVar * > aggregateResult(const std::set< const Analyzer::ColumnVar * > &aggregate, const std::set< const Analyzer::ColumnVar * > &next_result) const override
HOST DEVICE int get_scale() const
const Expr * get_right_operand() const
bool is_constructed_point(const Analyzer::Expr *expr)
JoinColumn fetchJoinColumn(const Analyzer::ColumnVar *hash_col, const std::vector< Fragmenter_Namespace::FragmentInfo > &fragment_info, const Data_Namespace::MemoryLevel effective_memory_level, const int device_id, std::vector< std::shared_ptr< Chunk_NS::Chunk >> &chunks_owner, DeviceAllocator *dev_buff_owner, std::vector< std::shared_ptr< void >> &malloc_owner, Executor *executor, ColumnCacheMap *column_cache)
static std::shared_ptr< OverlapsJoinHashTable > getInstance(const std::shared_ptr< Analyzer::BinOper > condition, const std::vector< InputTableInfo > &query_infos, const Data_Namespace::MemoryLevel memory_level, const JoinType join_type, const int device_count, ColumnCacheMap &column_cache, Executor *executor, const HashTableBuildDagMap &hashtable_build_dag_map, const RegisteredQueryHint &query_hint, const TableIdToNodeMap &table_id_to_node_map)
Make hash table from an in-flight SQL query's parse tree etc.
static std::pair< const StringDictionaryProxy *, StringDictionaryProxy * > getStrDictProxies(const InnerOuter &cols, const Executor *executor, const bool has_string_ops)
DEVICE void sort(ARGS &&...args)
const SQLTypeInfo get_column_type(const int col_id, const int table_id, const ColumnDescriptor *cd, const TemporaryTables *temporary_tables)
llvm::Value * codegenPseudoStringOper(const Analyzer::ColumnVar *, const std::vector< StringOps_Namespace::StringOpInfo > &string_op_infos, const CompilationOptions &)
virtual int8_t * alloc(const size_t num_bytes)=0
T visit(const Analyzer::Expr *expr) const
HOST DEVICE SQLTypes get_type() const
static llvm::Value * codegenColOrStringOper(const Analyzer::Expr *col_or_string_oper, const std::vector< StringOps_Namespace::StringOpInfo > &string_op_infos, CodeGenerator &code_generator, const CompilationOptions &co)
bool g_enable_data_recycler
virtual std::string toStringFlat32(const ExecutorDeviceType device_type, const int device_id) const
bool g_enable_overlaps_hashjoin
const std::vector< JoinColumnTypeInfo > join_column_types
virtual void copyToDevice(void *device_dst, const void *host_src, const size_t num_bytes) const =0
size_t col_chunks_buff_sz
static std::pair< InnerOuter, InnerOuterStringOpInfos > normalizeColumnPair(const Analyzer::Expr *lhs, const Analyzer::Expr *rhs, const Catalog_Namespace::Catalog &cat, const TemporaryTables *temporary_tables, const bool is_overlaps_join=false)
std::unordered_map< size_t, HashTableBuildDag > HashTableBuildDagMap
const std::vector< std::shared_ptr< Analyzer::Expr > > & getTuple() const
llvm::Value * get_arg_by_name(llvm::Function *func, const std::string &name)
std::vector< void * > sd_outer_proxy_per_key
const ColumnDescriptor * get_column_descriptor_maybe(const int col_id, const int table_id, const Catalog_Namespace::Catalog &cat)
std::unordered_map< int, const RelAlgNode * > TableIdToNodeMap
int8_t * getJoinHashBuffer(const ExecutorDeviceType device_type, const int device_id) const
static std::vector< const StringDictionaryProxy::IdMap * > translateCompositeStrDictProxies(const CompositeKeyInfo &composite_key_info, const std::vector< InnerOuterStringOpInfos > &string_op_infos_for_keys, const Executor *executor)
OUTPUT transform(INPUT const &input, FUNC const &func)
const int8_t * col_chunks_buff
std::string toString(const Executor::ExtModuleKinds &kind)
static void checkHashJoinReplicationConstraint(const int table_id, const size_t shard_count, const Executor *executor)
const SQLTypeInfo & get_type_info() const
int get_precision() const
static ExpressionRange makeIntRange(const int64_t int_min, const int64_t int_max, const int64_t bucket, const bool has_nulls)
static const StringDictionaryProxy::IdMap * translateInnerToOuterStrDictProxies(const InnerOuter &cols, const InnerOuterStringOpInfos &inner_outer_string_op_infos, ExpressionRange &old_col_range, const Executor *executor)
std::unordered_map< int, std::unordered_map< int, std::shared_ptr< const ColumnarResults >>> ColumnCacheMap
void setupSyntheticCaching(std::set< const Analyzer::ColumnVar * > cvs, Executor *executor)
static std::shared_ptr< BaselineJoinHashTable > getInstance(const std::shared_ptr< Analyzer::BinOper > condition, const std::vector< InputTableInfo > &query_infos, const Data_Namespace::MemoryLevel memory_level, const JoinType join_type, const HashType preferred_hash_type, const int device_count, ColumnCacheMap &column_cache, Executor *executor, const HashTableBuildDagMap &hashtable_build_dag_map, const TableIdToNodeMap &table_id_to_node_map)
Make hash table from an in-flight SQL query's parse tree etc.
std::vector< llvm::Value * > codegen(const Analyzer::Expr *, const bool fetch_columns, const CompilationOptions &)
static RegisteredQueryHint defaults()
Expression class for string functions The "arg" constructor parameter must be an expression that reso...
static std::shared_ptr< PerfectJoinHashTable > getInstance(const std::shared_ptr< Analyzer::BinOper > qual_bin_oper, const std::vector< InputTableInfo > &query_infos, const Data_Namespace::MemoryLevel memory_level, const JoinType join_type, const HashType preferred_hash_type, const int device_count, ColumnCacheMap &column_cache, Executor *executor, const HashTableBuildDagMap &hashtable_build_dag_map, const TableIdToNodeMap &table_id_to_node_map)
Make hash table from an in-flight SQL query's parse tree etc.
size_t getJoinHashBufferSize(const ExecutorDeviceType device_type)
bool table_is_replicated(const TableDescriptor *td)
std::set< DecodedJoinHashBufferEntry > DecodedJoinHashBufferSet
std::set< const Analyzer::ColumnVar * > visitColumnVarTuple(const Analyzer::ExpressionTuple *expr_tuple) const override
std::string get_type_name() const
int64_t getIntMax() const
std::set< const Analyzer::ColumnVar * > visitColumnVar(const Analyzer::ColumnVar *column) const override
std::pair< std::vector< StringOps_Namespace::StringOpInfo >, std::vector< StringOps_Namespace::StringOpInfo >> InnerOuterStringOpInfos
std::set< int32_t > payload
#define DEBUG_TIMER(name)
static const T * getHashJoinColumn(const Analyzer::Expr *expr)
const Expr * get_left_operand() const
bool is_overlaps_oper() const
static std::shared_ptr< HashJoin > getSyntheticInstance(std::string_view table1, std::string_view column1, std::string_view table2, std::string_view column2, const Data_Namespace::MemoryLevel memory_level, const HashType preferred_hash_type, const int device_count, ColumnCacheMap &column_cache, Executor *executor)
Make hash table from named tables and columns (such as for testing).
std::vector< int64_t > key
std::vector< JoinBucketInfo > join_buckets
size_t get_shard_count(const Analyzer::BinOper *join_condition, const Executor *executor)
static std::shared_ptr< HashJoin > getInstance(const std::shared_ptr< Analyzer::BinOper > qual_bin_oper, const std::vector< InputTableInfo > &query_infos, const Data_Namespace::MemoryLevel memory_level, const JoinType join_type, const HashType preferred_hash_type, const int device_count, ColumnCacheMap &column_cache, Executor *executor, const HashTableBuildDagMap &hashtable_build_dag_map, const RegisteredQueryHint &query_hint, const TableIdToNodeMap &table_id_to_node_map)
Make hash table from an in-flight SQL query's parse tree etc.
std::shared_ptr< Analyzer::ColumnVar > getSyntheticColumnVar(std::string_view table, std::string_view column, int rte_idx, Executor *executor)
DEVICE void swap(ARGS &&...args)
InnerOuter get_cols(const Analyzer::BinOper *qual_bin_oper, const Catalog_Namespace::Catalog &cat, const TemporaryTables *temporary_tables)
bool g_use_hashtable_cache
const std::vector< JoinColumn > join_columns
static CompositeKeyInfo getCompositeKeyInfo(const std::vector< InnerOuter > &inner_outer_pairs, const Executor *executor, const std::vector< InnerOuterStringOpInfos > &inner_outer_string_op_infos_pairs={})