OmniSciDB  c1a53651b2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BaselineJoinHashTable Class Reference

#include <BaselineJoinHashTable.h>

+ Inheritance diagram for BaselineJoinHashTable:
+ Collaboration diagram for BaselineJoinHashTable:

Classes

struct  AlternativeCacheKeyForBaselineHashJoin
 

Public Member Functions

std::string toString (const ExecutorDeviceType device_type, const int device_id=0, bool raw=false) const override
 
std::set
< DecodedJoinHashBufferEntry
toSet (const ExecutorDeviceType device_type, const int device_id) const override
 
llvm::Value * codegenSlot (const CompilationOptions &, const size_t) override
 
HashJoinMatchingSet codegenMatchingSet (const CompilationOptions &, const size_t) override
 
shared::TableKey getInnerTableId () const noexceptoverride
 
int getInnerTableRteIdx () const noexceptoverride
 
HashType getHashType () const noexceptoverride
 
Data_Namespace::MemoryLevel getMemoryLevel () const noexceptoverride
 
int getDeviceCount () const noexceptoverride
 
size_t offsetBufferOff () const noexceptoverride
 
size_t countBufferOff () const noexceptoverride
 
size_t payloadBufferOff () const noexceptoverride
 
std::string getHashJoinType () const final
 
const RegisteredQueryHintgetRegisteredQueryHint ()
 
virtual ~BaselineJoinHashTable ()
 
- Public Member Functions inherited from HashJoin
virtual std::string toStringFlat64 (const ExecutorDeviceType device_type, const int device_id) const
 
virtual std::string toStringFlat32 (const ExecutorDeviceType device_type, const int device_id) const
 
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)
 
HashTablegetHashTableForDevice (const size_t device_id) const
 
size_t getJoinHashBufferSize (const ExecutorDeviceType device_type)
 
size_t getJoinHashBufferSize (const ExecutorDeviceType device_type, const int device_id) const
 
int8_t * getJoinHashBuffer (const ExecutorDeviceType device_type, const int device_id) const
 
void freeHashBufferMemory ()
 

Static Public Member Functions

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 RegisteredQueryHint &query_hints, const TableIdToNodeMap &table_id_to_node_map)
 Make hash table from an in-flight SQL query's parse tree etc. More...
 
static size_t getShardCountForCondition (const Analyzer::BinOper *condition, const Executor *executor, const std::vector< InnerOuter > &inner_outer_pairs)
 
static void invalidateCache ()
 
static void markCachedItemAsDirty (size_t table_key)
 
static HashtableRecyclergetHashTableCache ()
 
static HashingSchemeRecyclergetHashingSchemeCache ()
 
- Static Public Member Functions inherited from HashJoin
static bool layoutRequiresAdditionalBuffers (HashType layout) noexcept
 
static std::string getHashTypeString (HashType ht) noexcept
 
static HashJoinMatchingSet codegenMatchingSet (const std::vector< llvm::Value * > &hash_join_idx_args_in, const bool is_sharded, const bool col_is_nullable, const bool is_bw_eq, const int64_t sub_buff_size, Executor *executor, const bool is_bucketized=false)
 
static llvm::Value * codegenHashTableLoad (const size_t table_idx, Executor *executor)
 
static std::shared_ptr< HashJoingetInstance (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. More...
 
static std::shared_ptr< HashJoingetSyntheticInstance (std::string_view table1, std::string_view column1, const Catalog_Namespace::Catalog &catalog1, std::string_view table2, std::string_view column2, const Catalog_Namespace::Catalog &catalog2, 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). More...
 
static std::shared_ptr< HashJoingetSyntheticInstance (const std::shared_ptr< Analyzer::BinOper > qual_bin_oper, 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). More...
 
static std::pair< std::string,
std::shared_ptr< HashJoin > > 
getSyntheticInstance (std::vector< std::shared_ptr< Analyzer::BinOper >>, const Data_Namespace::MemoryLevel memory_level, const HashType preferred_hash_type, const int device_count, ColumnCacheMap &column_cache, Executor *executor)
 
static shared::TableKey getInnerTableId (const std::vector< InnerOuter > &inner_outer_pairs)
 
static bool canAccessHashTable (bool allow_hash_table_recycling, bool invalid_cache_key, JoinType join_type)
 
static void checkHashJoinReplicationConstraint (const shared::TableKey &table_key, const size_t shard_count, const Executor *executor)
 
static std::pair< InnerOuter,
InnerOuterStringOpInfos
normalizeColumnPair (const Analyzer::Expr *lhs, const Analyzer::Expr *rhs, const TemporaryTables *temporary_tables, const bool is_overlaps_join=false)
 
template<typename T >
static const T * getHashJoinColumn (const Analyzer::Expr *expr)
 
static std::pair< std::vector
< InnerOuter >, std::vector
< InnerOuterStringOpInfos > > 
normalizeColumnPairs (const Analyzer::BinOper *condition, const TemporaryTables *temporary_tables)
 
static std::vector< int > collectFragmentIds (const std::vector< Fragmenter_Namespace::FragmentInfo > &fragments)
 
static CompositeKeyInfo getCompositeKeyInfo (const std::vector< InnerOuter > &inner_outer_pairs, const Executor *executor, const std::vector< InnerOuterStringOpInfos > &inner_outer_string_op_infos_pairs={})
 
static std::vector< const
StringDictionaryProxy::IdMap * > 
translateCompositeStrDictProxies (const CompositeKeyInfo &composite_key_info, const std::vector< InnerOuterStringOpInfos > &string_op_infos_for_keys, const Executor *executor)
 
static std::pair< const
StringDictionaryProxy
*, StringDictionaryProxy * > 
getStrDictProxies (const InnerOuter &cols, const Executor *executor, const bool has_string_ops)
 
static const
StringDictionaryProxy::IdMap
translateInnerToOuterStrDictProxies (const InnerOuter &cols, const InnerOuterStringOpInfos &inner_outer_string_op_infos, ExpressionRange &old_col_range, const Executor *executor)
 

Protected Member Functions

 BaselineJoinHashTable (const std::shared_ptr< Analyzer::BinOper > condition, const JoinType join_type, const std::vector< InputTableInfo > &query_infos, const Data_Namespace::MemoryLevel memory_level, ColumnCacheMap &column_cache, Executor *executor, const std::vector< InnerOuter > &inner_outer_pairs, const std::vector< InnerOuterStringOpInfos > &col_pairs_string_op_infos, const int device_count, const RegisteredQueryHint &query_hints, const HashTableBuildDagMap &hashtable_build_dag_map, const TableIdToNodeMap &table_id_to_node_map)
 
size_t getComponentBufferSize () const noexceptoverride
 
size_t getKeyBufferSize () const noexcept
 
virtual void reifyWithLayout (const HashType layout)
 
virtual ColumnsForDevice fetchColumnsForDevice (const std::vector< Fragmenter_Namespace::FragmentInfo > &fragments, const int device_id, DeviceAllocator *dev_buff_owner)
 
virtual std::pair< size_t, size_t > approximateTupleCount (const std::vector< ColumnsForDevice > &) const
 
virtual size_t getKeyComponentWidth () const
 
virtual size_t getKeyComponentCount () const
 
virtual llvm::Value * codegenKey (const CompilationOptions &)
 
size_t shardCount () const
 
Data_Namespace::MemoryLevel getEffectiveMemoryLevel (const std::vector< InnerOuter > &inner_outer_pairs) const
 
void reify (const HashType preferred_layout)
 
void copyCpuHashTableToGpu (std::shared_ptr< BaselineHashTable > &cpu_hash_table, const int device_id, Data_Namespace::DataMgr *data_mgr)
 
virtual void reifyForDevice (const ColumnsForDevice &columns_for_device, const HashType layout, const int device_id, const size_t entry_count, const size_t emitted_keys_count, const logger::ThreadLocalIds parent_thread_local_ids)
 
virtual int initHashTableForDevice (const std::vector< JoinColumn > &join_columns, const std::vector< JoinColumnTypeInfo > &join_column_types, const std::vector< JoinBucketInfo > &join_buckets, const HashType layout, const Data_Namespace::MemoryLevel effective_memory_level, const size_t entry_count, const size_t emitted_keys_count, const int device_id)
 
llvm::Value * hashPtr (const size_t index)
 
std::shared_ptr< HashTableinitHashTableOnCpuFromCache (QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier)
 
void putHashTableOnCpuToCache (QueryPlanHash key, CacheItemType item_type, std::shared_ptr< HashTable > hashtable_ptr, DeviceIdentifier device_identifier, size_t hashtable_building_time)
 
bool isBitwiseEq () const override
 
ChunkKey genChunkKey (const std::vector< Fragmenter_Namespace::FragmentInfo > &fragments) const
 

Static Protected Member Functions

static shared::TableKey getInnerTableId (const std::vector< InnerOuter > &inner_outer_pairs)
 
static QueryPlanHash getAlternativeCacheKey (AlternativeCacheKeyForBaselineHashJoin &info)
 
- Static Protected Member Functions inherited from HashJoin
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)
 

Protected Attributes

const std::shared_ptr
< Analyzer::BinOper
condition_
 
const JoinType join_type_
 
const std::vector
< InputTableInfo > & 
query_infos_
 
const Data_Namespace::MemoryLevel memory_level_
 
Executorexecutor_
 
ColumnCacheMapcolumn_cache_
 
std::mutex cpu_hash_table_buff_mutex_
 
std::mutex str_proxy_translation_mutex_
 
std::vector< const
StringDictionaryProxy::IdMap * > 
str_proxy_translation_maps_
 
std::vector< InnerOuterinner_outer_pairs_
 
std::vector
< InnerOuterStringOpInfos
inner_outer_string_op_infos_pairs_
 
const int device_count_
 
RegisteredQueryHint query_hints_
 
bool needs_dict_translation_
 
std::optional< HashTypelayout_override_
 
HashTableBuildDagMap hashtable_build_dag_map_
 
std::vector< QueryPlanHashhashtable_cache_key_
 
HashtableCacheMetaInfo hashtable_cache_meta_info_
 
std::unordered_set< size_t > table_keys_
 
const TableIdToNodeMap table_id_to_node_map_
 
- Protected Attributes inherited from HashJoin
std::vector< std::shared_ptr
< HashTable > > 
hash_tables_for_device_
 

Static Protected Attributes

static std::unique_ptr
< HashtableRecycler
hash_table_cache_
 
static std::unique_ptr
< HashingSchemeRecycler
hash_table_layout_cache_
 

Detailed Description

Definition at line 49 of file BaselineJoinHashTable.h.

Constructor & Destructor Documentation

virtual BaselineJoinHashTable::~BaselineJoinHashTable ( )
inlinevirtual

Definition at line 139 of file BaselineJoinHashTable.h.

139 {}
BaselineJoinHashTable::BaselineJoinHashTable ( const std::shared_ptr< Analyzer::BinOper condition,
const JoinType  join_type,
const std::vector< InputTableInfo > &  query_infos,
const Data_Namespace::MemoryLevel  memory_level,
ColumnCacheMap column_cache,
Executor executor,
const std::vector< InnerOuter > &  inner_outer_pairs,
const std::vector< InnerOuterStringOpInfos > &  col_pairs_string_op_infos,
const int  device_count,
const RegisteredQueryHint query_hints,
const HashTableBuildDagMap hashtable_build_dag_map,
const TableIdToNodeMap table_id_to_node_map 
)
protected

Definition at line 114 of file BaselineJoinHashTable.cpp.

References CHECK_GT, device_count_, and HashJoin::hash_tables_for_device_.

Referenced by getInstance().

127  : condition_(condition)
128  , join_type_(join_type)
129  , query_infos_(query_infos)
130  , memory_level_(memory_level)
131  , executor_(executor)
132  , column_cache_(column_cache)
133  , inner_outer_pairs_(inner_outer_pairs)
134  , inner_outer_string_op_infos_pairs_(col_pairs_string_op_infos)
135  , device_count_(device_count)
136  , query_hints_(query_hints)
137  , needs_dict_translation_(false)
138  , hashtable_build_dag_map_(hashtable_build_dag_map)
139  , table_id_to_node_map_(table_id_to_node_map) {
141  hash_tables_for_device_.resize(std::max(device_count_, 1));
142 }
std::vector< std::shared_ptr< HashTable > > hash_tables_for_device_
Definition: HashJoin.h:363
HashTableBuildDagMap hashtable_build_dag_map_
const TableIdToNodeMap table_id_to_node_map_
RegisteredQueryHint query_hints_
#define CHECK_GT(x, y)
Definition: Logger.h:305
const std::vector< InputTableInfo > & query_infos_
std::vector< InnerOuter > inner_outer_pairs_
std::vector< InnerOuterStringOpInfos > inner_outer_string_op_infos_pairs_
ColumnCacheMap & column_cache_
const Data_Namespace::MemoryLevel memory_level_
const std::shared_ptr< Analyzer::BinOper > condition_

+ Here is the caller graph for this function:

Member Function Documentation

std::pair< size_t, size_t > BaselineJoinHashTable::approximateTupleCount ( const std::vector< ColumnsForDevice > &  columns_per_device) const
protectedvirtual

Definition at line 516 of file BaselineJoinHashTable.cpp.

References approximate_distinct_tuples(), approximate_distinct_tuples_on_device(), threading_serial::async(), Bitmap, CHECK, CHECK_EQ, CPU, Data_Namespace::CPU_LEVEL, cpu_threads(), device_count_, executor_, getEffectiveMemoryLevel(), getQueryEngineCudaStreamForDevice(), GPU, Data_Namespace::GPU_LEVEL, hll_size(), hll_unify(), inner_outer_pairs_, transfer_flat_object_to_gpu(), transfer_vector_of_flat_objects_to_gpu(), and UNREACHABLE.

Referenced by reifyWithLayout().

517  {
518  const auto effective_memory_level = getEffectiveMemoryLevel(inner_outer_pairs_);
519  CountDistinctDescriptor count_distinct_desc{
521  0,
522  11,
523  true,
524  effective_memory_level == Data_Namespace::MemoryLevel::GPU_LEVEL
527  1};
528  const auto padded_size_bytes = count_distinct_desc.bitmapPaddedSizeBytes();
529 
530  CHECK(!columns_per_device.empty() && !columns_per_device.front().join_columns.empty());
531 
532  if (effective_memory_level == Data_Namespace::MemoryLevel::CPU_LEVEL) {
533  int thread_count = cpu_threads();
534  std::vector<uint8_t> hll_buffer_all_cpus(thread_count * padded_size_bytes);
535  auto hll_result = &hll_buffer_all_cpus[0];
536 
537  approximate_distinct_tuples(hll_result,
538  count_distinct_desc.bitmap_sz_bits,
539  padded_size_bytes,
540  columns_per_device.front().join_columns,
541  columns_per_device.front().join_column_types,
542  thread_count);
543  for (int i = 1; i < thread_count; ++i) {
544  hll_unify(hll_result,
545  hll_result + i * padded_size_bytes,
546  1 << count_distinct_desc.bitmap_sz_bits);
547  }
548  return std::make_pair(hll_size(hll_result, count_distinct_desc.bitmap_sz_bits), 0);
549  }
550 #ifdef HAVE_CUDA
551  auto data_mgr = executor_->getDataMgr();
552  std::vector<std::vector<uint8_t>> host_hll_buffers(device_count_);
553  for (auto& host_hll_buffer : host_hll_buffers) {
554  host_hll_buffer.resize(count_distinct_desc.bitmapPaddedSizeBytes());
555  }
556  std::vector<std::future<void>> approximate_distinct_device_threads;
557  for (int device_id = 0; device_id < device_count_; ++device_id) {
558  approximate_distinct_device_threads.emplace_back(std::async(
560  [device_id,
561  &columns_per_device,
562  &count_distinct_desc,
563  data_mgr,
564  &host_hll_buffers] {
565  auto allocator = std::make_unique<CudaAllocator>(
566  data_mgr, device_id, getQueryEngineCudaStreamForDevice(device_id));
567  auto device_hll_buffer =
568  allocator->alloc(count_distinct_desc.bitmapPaddedSizeBytes());
569  data_mgr->getCudaMgr()->zeroDeviceMem(
570  device_hll_buffer,
571  count_distinct_desc.bitmapPaddedSizeBytes(),
572  device_id,
574  const auto& columns_for_device = columns_per_device[device_id];
575  auto join_columns_gpu = transfer_vector_of_flat_objects_to_gpu(
576  columns_for_device.join_columns, *allocator);
577  auto join_column_types_gpu = transfer_vector_of_flat_objects_to_gpu(
578  columns_for_device.join_column_types, *allocator);
579  const auto key_handler =
580  GenericKeyHandler(columns_for_device.join_columns.size(),
581  true,
582  join_columns_gpu,
583  join_column_types_gpu,
584  nullptr,
585  nullptr);
586  const auto key_handler_gpu =
587  transfer_flat_object_to_gpu(key_handler, *allocator);
589  reinterpret_cast<uint8_t*>(device_hll_buffer),
590  count_distinct_desc.bitmap_sz_bits,
591  key_handler_gpu,
592  columns_for_device.join_columns[0].num_elems);
593 
594  auto& host_hll_buffer = host_hll_buffers[device_id];
595  allocator->copyFromDevice(&host_hll_buffer[0],
596  device_hll_buffer,
597  count_distinct_desc.bitmapPaddedSizeBytes());
598  }));
599  }
600  for (auto& child : approximate_distinct_device_threads) {
601  child.get();
602  }
603  CHECK_EQ(Data_Namespace::MemoryLevel::GPU_LEVEL, effective_memory_level);
604  auto& result_hll_buffer = host_hll_buffers.front();
605  auto hll_result = reinterpret_cast<int32_t*>(&result_hll_buffer[0]);
606  for (int device_id = 1; device_id < device_count_; ++device_id) {
607  auto& host_hll_buffer = host_hll_buffers[device_id];
608  hll_unify(hll_result,
609  reinterpret_cast<int32_t*>(&host_hll_buffer[0]),
610  1 << count_distinct_desc.bitmap_sz_bits);
611  }
612  return std::make_pair(hll_size(hll_result, count_distinct_desc.bitmap_sz_bits), 0);
613 #else
614  UNREACHABLE();
615  return {0, 0};
616 #endif // HAVE_CUDA
617 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
Data_Namespace::MemoryLevel getEffectiveMemoryLevel(const std::vector< InnerOuter > &inner_outer_pairs) const
T * transfer_flat_object_to_gpu(const T &object, DeviceAllocator &allocator)
void hll_unify(T1 *lhs, T2 *rhs, const size_t m)
Definition: HyperLogLog.h:107
#define UNREACHABLE()
Definition: Logger.h:337
size_t hll_size(const T *M, const size_t bitmap_sz_bits)
Definition: HyperLogLog.h:88
std::vector< InnerOuter > inner_outer_pairs_
void approximate_distinct_tuples(uint8_t *hll_buffer_all_cpus, const uint32_t b, const size_t padded_size_bytes, const std::vector< JoinColumn > &join_column_per_key, const std::vector< JoinColumnTypeInfo > &type_info_per_key, const int thread_count)
future< Result > async(Fn &&fn, Args &&...args)
CUstream getQueryEngineCudaStreamForDevice(int device_num)
Definition: QueryEngine.cpp:7
void approximate_distinct_tuples_on_device(uint8_t *hll_buffer, const uint32_t b, const GenericKeyHandler *key_handler, const int64_t num_elems)
#define CHECK(condition)
Definition: Logger.h:291
T * transfer_vector_of_flat_objects_to_gpu(const std::vector< T > &vec, DeviceAllocator &allocator)
int cpu_threads()
Definition: thread_count.h:25

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

llvm::Value * BaselineJoinHashTable::codegenKey ( const CompilationOptions co)
protectedvirtual

Definition at line 1014 of file BaselineJoinHashTable.cpp.

References AUTOMATIC_IR_METADATA, CHECK, HashJoin::codegenColOrStringOper(), executor_, get_int_type(), get_max_rte_scan_table(), getKeyComponentCount(), getKeyComponentWidth(), inner_outer_pairs_, inner_outer_string_op_infos_pairs_, LL_BUILDER, LL_CONTEXT, LL_INT, and self_join_not_covered_by_left_deep_tree().

Referenced by codegenMatchingSet(), and codegenSlot().

1014  {
1015  AUTOMATIC_IR_METADATA(executor_->cgen_state_.get());
1016  const auto key_component_width = getKeyComponentWidth();
1017  CHECK(key_component_width == 4 || key_component_width == 8);
1018  const auto key_size_lv = LL_INT(getKeyComponentCount() * key_component_width);
1019  llvm::Value* key_buff_lv{nullptr};
1020  switch (key_component_width) {
1021  case 4:
1022  key_buff_lv =
1023  LL_BUILDER.CreateAlloca(llvm::Type::getInt32Ty(LL_CONTEXT), key_size_lv);
1024  break;
1025  case 8:
1026  key_buff_lv =
1027  LL_BUILDER.CreateAlloca(llvm::Type::getInt64Ty(LL_CONTEXT), key_size_lv);
1028  break;
1029  default:
1030  CHECK(false);
1031  }
1032 
1033  CodeGenerator code_generator(executor_);
1034  for (size_t i = 0; i < getKeyComponentCount(); ++i) {
1035  const auto key_comp_dest_lv = LL_BUILDER.CreateGEP(
1036  key_buff_lv->getType()->getScalarType()->getPointerElementType(),
1037  key_buff_lv,
1038  LL_INT(i));
1039  const auto& inner_outer_pair = inner_outer_pairs_[i];
1040  const auto outer_col = inner_outer_pair.second;
1041  const auto key_col_var = dynamic_cast<const Analyzer::ColumnVar*>(outer_col);
1042  const auto val_col_var =
1043  dynamic_cast<const Analyzer::ColumnVar*>(inner_outer_pair.first);
1044  if (key_col_var && val_col_var &&
1046  key_col_var,
1047  val_col_var,
1048  get_max_rte_scan_table(executor_->cgen_state_->scan_idx_to_hash_pos_))) {
1049  throw std::runtime_error(
1050  "Query execution fails because the query contains not supported self-join "
1051  "pattern. We suspect the query requires multiple left-deep join tree due to "
1052  "the join condition of the self-join and is not supported for now. Please "
1053  "consider rewriting table order in "
1054  "FROM clause.");
1055  }
1056  auto key_lv = HashJoin::codegenColOrStringOper(
1057  outer_col, inner_outer_string_op_infos_pairs_[i].second, code_generator, co);
1058  const auto key_lv_ext =
1059  LL_BUILDER.CreateSExt(key_lv, get_int_type(key_component_width * 8, LL_CONTEXT));
1060  LL_BUILDER.CreateStore(key_lv_ext, key_comp_dest_lv);
1061  }
1062  return key_buff_lv;
1063 }
bool self_join_not_covered_by_left_deep_tree(const Analyzer::ColumnVar *key_side, const Analyzer::ColumnVar *val_side, const int max_rte_covered)
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)
Definition: HashJoin.cpp:545
llvm::Type * get_int_type(const int width, llvm::LLVMContext &context)
const int get_max_rte_scan_table(std::unordered_map< int, llvm::Value * > &scan_idx_to_hash_pos)
std::vector< InnerOuter > inner_outer_pairs_
std::vector< InnerOuterStringOpInfos > inner_outer_string_op_infos_pairs_
#define LL_INT(v)
#define LL_CONTEXT
#define AUTOMATIC_IR_METADATA(CGENSTATE)
#define LL_BUILDER
#define CHECK(condition)
Definition: Logger.h:291
virtual size_t getKeyComponentCount() const
virtual size_t getKeyComponentWidth() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

HashJoinMatchingSet BaselineJoinHashTable::codegenMatchingSet ( const CompilationOptions co,
const size_t  index 
)
overridevirtual

Implements HashJoin.

Definition at line 932 of file BaselineJoinHashTable.cpp.

References AUTOMATIC_IR_METADATA, CHECK, HashJoin::codegenHashTableLoad(), codegenKey(), HashJoin::codegenMatchingSet(), executor_, get_int_type(), getComponentBufferSize(), HashJoin::getHashTableForDevice(), getHashType(), getKeyComponentCount(), getKeyComponentWidth(), LL_BUILDER, LL_CONTEXT, LL_INT, offsetBufferOff(), OneToMany, and to_string().

934  {
935  AUTOMATIC_IR_METADATA(executor_->cgen_state_.get());
936  const auto hash_table = getHashTableForDevice(size_t(0));
937  CHECK(hash_table);
938  const auto key_component_width = getKeyComponentWidth();
939  CHECK(key_component_width == 4 || key_component_width == 8);
940  auto key_buff_lv = codegenKey(co);
942  auto hash_ptr = HashJoin::codegenHashTableLoad(index, executor_);
943  const auto composite_dict_ptr_type =
944  llvm::Type::getIntNPtrTy(LL_CONTEXT, key_component_width * 8);
945  const auto composite_key_dict =
946  hash_ptr->getType()->isPointerTy()
947  ? LL_BUILDER.CreatePointerCast(hash_ptr, composite_dict_ptr_type)
948  : LL_BUILDER.CreateIntToPtr(hash_ptr, composite_dict_ptr_type);
949  const auto key_component_count = getKeyComponentCount();
950  const auto key = executor_->cgen_state_->emitExternalCall(
951  "get_composite_key_index_" + std::to_string(key_component_width * 8),
953  {key_buff_lv,
954  LL_INT(key_component_count),
955  composite_key_dict,
956  LL_INT(hash_table->getEntryCount())});
957  auto one_to_many_ptr = hash_ptr;
958  if (one_to_many_ptr->getType()->isPointerTy()) {
959  one_to_many_ptr =
960  LL_BUILDER.CreatePtrToInt(hash_ptr, llvm::Type::getInt64Ty(LL_CONTEXT));
961  } else {
962  CHECK(one_to_many_ptr->getType()->isIntegerTy(64));
963  }
964  const auto composite_key_dict_size = offsetBufferOff();
965  one_to_many_ptr =
966  LL_BUILDER.CreateAdd(one_to_many_ptr, LL_INT(composite_key_dict_size));
968  {one_to_many_ptr, key, LL_INT(int64_t(0)), LL_INT(hash_table->getEntryCount() - 1)},
969  false,
970  false,
971  false,
973  executor_);
974 }
size_t offsetBufferOff() const noexceptoverride
virtual HashJoinMatchingSet codegenMatchingSet(const CompilationOptions &, const size_t)=0
static llvm::Value * codegenHashTableLoad(const size_t table_idx, Executor *executor)
Definition: HashJoin.cpp:257
size_t getComponentBufferSize() const noexceptoverride
llvm::Type * get_int_type(const int width, llvm::LLVMContext &context)
std::string to_string(char const *&&v)
virtual llvm::Value * codegenKey(const CompilationOptions &)
HashType getHashType() const noexceptoverride
#define LL_INT(v)
#define LL_CONTEXT
#define AUTOMATIC_IR_METADATA(CGENSTATE)
HashTable * getHashTableForDevice(const size_t device_id) const
Definition: HashJoin.h:281
#define LL_BUILDER
#define CHECK(condition)
Definition: Logger.h:291
virtual size_t getKeyComponentCount() const
virtual size_t getKeyComponentWidth() const

+ Here is the call graph for this function:

llvm::Value * BaselineJoinHashTable::codegenSlot ( const CompilationOptions co,
const size_t  index 
)
overridevirtual

Implements HashJoin.

Definition at line 914 of file BaselineJoinHashTable.cpp.

References AUTOMATIC_IR_METADATA, CHECK, codegenKey(), executor_, get_int_type(), HashJoin::getHashTableForDevice(), getHashType(), getKeyComponentCount(), getKeyComponentWidth(), hashPtr(), LL_BUILDER, LL_CONTEXT, LL_INT, OneToOne, and to_string().

915  {
916  AUTOMATIC_IR_METADATA(executor_->cgen_state_.get());
918  const auto key_component_width = getKeyComponentWidth();
919  CHECK(key_component_width == 4 || key_component_width == 8);
920  auto key_buff_lv = codegenKey(co);
921  const auto hash_ptr = hashPtr(index);
922  const auto key_ptr_lv =
923  LL_BUILDER.CreatePointerCast(key_buff_lv, llvm::Type::getInt8PtrTy(LL_CONTEXT));
924  const auto key_size_lv = LL_INT(getKeyComponentCount() * key_component_width);
925  const auto hash_table = getHashTableForDevice(size_t(0));
926  return executor_->cgen_state_->emitExternalCall(
927  "baseline_hash_join_idx_" + std::to_string(key_component_width * 8),
929  {hash_ptr, key_ptr_lv, key_size_lv, LL_INT(hash_table->getEntryCount())});
930 }
llvm::Type * get_int_type(const int width, llvm::LLVMContext &context)
std::string to_string(char const *&&v)
virtual llvm::Value * codegenKey(const CompilationOptions &)
HashType getHashType() const noexceptoverride
#define LL_INT(v)
#define LL_CONTEXT
#define AUTOMATIC_IR_METADATA(CGENSTATE)
HashTable * getHashTableForDevice(const size_t device_id) const
Definition: HashJoin.h:281
#define LL_BUILDER
llvm::Value * hashPtr(const size_t index)
#define CHECK(condition)
Definition: Logger.h:291
virtual size_t getKeyComponentCount() const
virtual size_t getKeyComponentWidth() const

+ Here is the call graph for this function:

void BaselineJoinHashTable::copyCpuHashTableToGpu ( std::shared_ptr< BaselineHashTable > &  cpu_hash_table,
const int  device_id,
Data_Namespace::DataMgr data_mgr 
)
protected

Definition at line 718 of file BaselineJoinHashTable.cpp.

References BaselineJoinHashTableBuilder::allocateDeviceMemory(), CHECK, CPU, executor_, BaselineJoinHashTableBuilder::getHashTable(), getKeyComponentCount(), getKeyComponentWidth(), getQueryEngineCudaStreamForDevice(), HashJoin::hash_tables_for_device_, and query_hints_.

Referenced by initHashTableForDevice(), and reifyWithLayout().

721  {
723 
724  builder.allocateDeviceMemory(cpu_hash_table->getLayout(),
727  cpu_hash_table->getEntryCount(),
728  cpu_hash_table->getEmittedKeysCount(),
729  device_id,
730  executor_,
731  query_hints_);
732  auto gpu_target_hash_table = builder.getHashTable();
733  CHECK(gpu_target_hash_table);
734 
735  const auto gpu_buff = gpu_target_hash_table->getGpuBuffer();
736  CHECK(gpu_buff);
737  auto allocator = std::make_unique<CudaAllocator>(
738  data_mgr, device_id, getQueryEngineCudaStreamForDevice(device_id));
739  allocator->copyToDevice(
740  gpu_buff,
741  cpu_hash_table->getCpuBuffer(),
742  cpu_hash_table->getHashTableBufferSize(ExecutorDeviceType::CPU));
743  hash_tables_for_device_[device_id] = std::move(gpu_target_hash_table);
744 }
std::vector< std::shared_ptr< HashTable > > hash_tables_for_device_
Definition: HashJoin.h:363
RegisteredQueryHint query_hints_
void allocateDeviceMemory(const HashType layout, const size_t key_component_width, const size_t key_component_count, const size_t keyspace_entry_count, const size_t emitted_keys_count, const int device_id, const Executor *executor, const RegisteredQueryHint &query_hint)
std::unique_ptr< BaselineHashTable > getHashTable()
CUstream getQueryEngineCudaStreamForDevice(int device_num)
Definition: QueryEngine.cpp:7
#define CHECK(condition)
Definition: Logger.h:291
virtual size_t getKeyComponentCount() const
virtual size_t getKeyComponentWidth() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t BaselineJoinHashTable::countBufferOff ( ) const
overridevirtualnoexcept

Implements HashJoin.

Definition at line 980 of file BaselineJoinHashTable.cpp.

References getComponentBufferSize(), getHashType(), getKeyBufferSize(), HashJoin::layoutRequiresAdditionalBuffers(), and offsetBufferOff().

Referenced by payloadBufferOff(), toSet(), and toString().

980  {
983  } else {
984  return getKeyBufferSize();
985  }
986 }
size_t offsetBufferOff() const noexceptoverride
size_t getKeyBufferSize() const noexcept
size_t getComponentBufferSize() const noexceptoverride
HashType getHashType() const noexceptoverride
static bool layoutRequiresAdditionalBuffers(HashType layout) noexcept
Definition: HashJoin.h:161

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ColumnsForDevice BaselineJoinHashTable::fetchColumnsForDevice ( const std::vector< Fragmenter_Namespace::FragmentInfo > &  fragments,
const int  device_id,
DeviceAllocator dev_buff_owner 
)
protectedvirtual

Definition at line 619 of file BaselineJoinHashTable.cpp.

References column_cache_, executor_, HashJoin::fetchJoinColumn(), get_column_descriptor_maybe(), get_effective_memory_level(), get_join_column_type_kind(), inline_fixed_encoding_null_val(), inner_outer_pairs_, isBitwiseEq(), memory_level_, and needs_dict_translation_.

Referenced by reifyWithLayout().

622  {
623  const auto effective_memory_level =
625 
626  std::vector<JoinColumn> join_columns;
627  std::vector<std::shared_ptr<Chunk_NS::Chunk>> chunks_owner;
628  std::vector<JoinColumnTypeInfo> join_column_types;
629  std::vector<JoinBucketInfo> join_bucket_info;
630  std::vector<std::shared_ptr<void>> malloc_owner;
631  for (const auto& inner_outer_pair : inner_outer_pairs_) {
632  const auto inner_col = inner_outer_pair.first;
633  const auto inner_cd = get_column_descriptor_maybe(inner_col->getColumnKey());
634  if (inner_cd && inner_cd->isVirtualCol) {
636  }
637  join_columns.emplace_back(fetchJoinColumn(inner_col,
638  fragments,
639  effective_memory_level,
640  device_id,
641  chunks_owner,
642  dev_buff_owner,
643  malloc_owner,
644  executor_,
645  &column_cache_));
646  const auto& ti = inner_col->get_type_info();
647  join_column_types.emplace_back(JoinColumnTypeInfo{static_cast<size_t>(ti.get_size()),
648  0,
649  0,
651  isBitwiseEq(),
652  0,
654  }
655  return {join_columns, join_column_types, chunks_owner, join_bucket_info, malloc_owner};
656 }
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)
Definition: HashJoin.cpp:58
Data_Namespace::MemoryLevel get_effective_memory_level(const Data_Namespace::MemoryLevel memory_level, const bool needs_dict_translation)
std::vector< InnerOuter > inner_outer_pairs_
const ColumnDescriptor * get_column_descriptor_maybe(const shared::ColumnKey &column_key)
Definition: Execute.h:220
ColumnCacheMap & column_cache_
const Data_Namespace::MemoryLevel memory_level_
ColumnType get_join_column_type_kind(const SQLTypeInfo &ti)
bool isBitwiseEq() const override
int64_t inline_fixed_encoding_null_val(const SQL_TYPE_INFO &ti)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ChunkKey BaselineJoinHashTable::genChunkKey ( const std::vector< Fragmenter_Namespace::FragmentInfo > &  fragments) const
protected

Definition at line 1142 of file BaselineJoinHashTable.cpp.

Referenced by reifyWithLayout().

1143  {
1144  std::vector<int> fragment_ids;
1145  std::for_each(
1146  fragments.cbegin(), fragments.cend(), [&fragment_ids](const auto& fragment) {
1147  fragment_ids.push_back(fragment.fragmentId);
1148  });
1149  return fragment_ids;
1150 }

+ Here is the caller graph for this function:

static QueryPlanHash BaselineJoinHashTable::getAlternativeCacheKey ( AlternativeCacheKeyForBaselineHashJoin info)
inlinestaticprotected

Definition at line 234 of file BaselineJoinHashTable.h.

References BaselineJoinHashTable::AlternativeCacheKeyForBaselineHashJoin::inner_outer_pairs, BaselineJoinHashTable::AlternativeCacheKeyForBaselineHashJoin::inner_outer_string_op_infos_pairs, BaselineJoinHashTable::AlternativeCacheKeyForBaselineHashJoin::join_type, BaselineJoinHashTable::AlternativeCacheKeyForBaselineHashJoin::num_elements, BaselineJoinHashTable::AlternativeCacheKeyForBaselineHashJoin::optype, and toString().

Referenced by reifyWithLayout().

235  {
236  auto hash = boost::hash_value(::toString(info.optype));
237  for (InnerOuter inner_outer : info.inner_outer_pairs) {
238  auto inner_col = inner_outer.first;
239  auto rhs_col_var = dynamic_cast<const Analyzer::ColumnVar*>(inner_outer.second);
240  auto outer_col = rhs_col_var ? rhs_col_var : inner_col;
241  boost::hash_combine(hash, inner_col->toString());
242  if (inner_col->get_type_info().is_string()) {
243  boost::hash_combine(hash, outer_col->toString());
244  }
245  }
246  if (info.inner_outer_string_op_infos_pairs.size()) {
247  boost::hash_combine(hash, ::toString(info.inner_outer_string_op_infos_pairs));
248  }
249  boost::hash_combine(hash, info.num_elements);
250  boost::hash_combine(hash, info.join_type);
251  return hash;
252  }
std::string toString(const ExecutorDeviceType device_type, const int device_id=0, bool raw=false) const override
std::pair< const Analyzer::ColumnVar *, const Analyzer::Expr * > InnerOuter
Definition: HashJoin.h:106

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t BaselineJoinHashTable::getComponentBufferSize ( ) const
overrideprotectedvirtualnoexcept

Implements HashJoin.

Definition at line 1009 of file BaselineJoinHashTable.cpp.

References HashJoin::getHashTableForDevice().

Referenced by codegenMatchingSet(), countBufferOff(), and payloadBufferOff().

1009  {
1010  const auto hash_table = getHashTableForDevice(size_t(0));
1011  return hash_table->getEntryCount() * sizeof(int32_t);
1012 }
HashTable * getHashTableForDevice(const size_t device_id) const
Definition: HashJoin.h:281

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int BaselineJoinHashTable::getDeviceCount ( ) const
inlineoverridevirtualnoexcept

Implements HashJoin.

Definition at line 92 of file BaselineJoinHashTable.h.

References device_count_.

92 { return device_count_; };
Data_Namespace::MemoryLevel BaselineJoinHashTable::getEffectiveMemoryLevel ( const std::vector< InnerOuter > &  inner_outer_pairs) const
protected

Definition at line 708 of file BaselineJoinHashTable.cpp.

References Data_Namespace::CPU_LEVEL, executor_, inner_outer_string_op_infos_pairs_, memory_level_, needs_dict_translation_, and needs_dictionary_translation().

Referenced by approximateTupleCount(), and reifyWithLayout().

709  {
711  inner_outer_pairs, inner_outer_string_op_infos_pairs_, executor_)) {
714  }
715  return memory_level_;
716 }
bool needs_dictionary_translation(const std::vector< InnerOuter > &inner_outer_pairs, const std::vector< InnerOuterStringOpInfos > &inner_outer_string_op_infos_pairs, const Executor *executor)
std::vector< InnerOuterStringOpInfos > inner_outer_string_op_infos_pairs_
const Data_Namespace::MemoryLevel memory_level_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static HashingSchemeRecycler* BaselineJoinHashTable::getHashingSchemeCache ( )
inlinestatic

Definition at line 132 of file BaselineJoinHashTable.h.

References CHECK, and hash_table_layout_cache_.

132  {
134  return hash_table_layout_cache_.get();
135  }
#define CHECK(condition)
Definition: Logger.h:291
static std::unique_ptr< HashingSchemeRecycler > hash_table_layout_cache_
std::string BaselineJoinHashTable::getHashJoinType ( ) const
inlinefinalvirtual

Implements HashJoin.

Definition at line 100 of file BaselineJoinHashTable.h.

100 { return "Baseline"; }
static HashtableRecycler* BaselineJoinHashTable::getHashTableCache ( )
inlinestatic

Definition at line 128 of file BaselineJoinHashTable.h.

References CHECK, and hash_table_cache_.

Referenced by QueryRunner::QueryRunner::getCachedHashtableWithoutCacheKey(), QueryRunner::QueryRunner::getCacheItemMetric(), and QueryRunner::QueryRunner::getNumberOfCachedItem().

128  {
130  return hash_table_cache_.get();
131  }
static std::unique_ptr< HashtableRecycler > hash_table_cache_
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function:

HashType BaselineJoinHashTable::getHashType ( ) const
overridevirtualnoexcept

Implements HashJoin.

Definition at line 1094 of file BaselineJoinHashTable.cpp.

References CHECK, HashJoin::getHashTableForDevice(), and layout_override_.

Referenced by codegenMatchingSet(), codegenSlot(), countBufferOff(), payloadBufferOff(), and toString().

1094  {
1095  auto hash_table = getHashTableForDevice(size_t(0));
1096  CHECK(hash_table);
1097  if (layout_override_) {
1098  return *layout_override_;
1099  } else {
1100  return hash_table->getLayout();
1101  }
1102 }
HashTable * getHashTableForDevice(const size_t device_id) const
Definition: HashJoin.h:281
std::optional< HashType > layout_override_
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

shared::TableKey BaselineJoinHashTable::getInnerTableId ( ) const
overridevirtualnoexcept

Implements HashJoin.

Definition at line 1079 of file BaselineJoinHashTable.cpp.

References CHECK, and inner_outer_pairs_.

Referenced by initHashTableForDevice(), reify(), and reifyWithLayout().

1079  {
1080  try {
1082  } catch (...) {
1083  CHECK(false);
1084  }
1085  return {0, 0};
1086 }
std::vector< InnerOuter > inner_outer_pairs_
#define CHECK(condition)
Definition: Logger.h:291
shared::TableKey getInnerTableId() const noexceptoverride

+ Here is the caller graph for this function:

shared::TableKey BaselineJoinHashTable::getInnerTableId ( const std::vector< InnerOuter > &  inner_outer_pairs)
staticprotected

Definition at line 1104 of file BaselineJoinHashTable.cpp.

References CHECK.

1105  {
1106  CHECK(!inner_outer_pairs.empty());
1107  const auto first_inner_col = inner_outer_pairs.front().first;
1108  return first_inner_col->getTableKey();
1109 }
#define CHECK(condition)
Definition: Logger.h:291
int BaselineJoinHashTable::getInnerTableRteIdx ( ) const
overridevirtualnoexcept

Implements HashJoin.

Definition at line 1088 of file BaselineJoinHashTable.cpp.

References CHECK, and inner_outer_pairs_.

1088  {
1089  CHECK(!inner_outer_pairs_.empty());
1090  const auto first_inner_col = inner_outer_pairs_.front().first;
1091  return first_inner_col->get_rte_idx();
1092 }
std::vector< InnerOuter > inner_outer_pairs_
#define CHECK(condition)
Definition: Logger.h:291
std::shared_ptr< BaselineJoinHashTable > 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 RegisteredQueryHint query_hints,
const TableIdToNodeMap table_id_to_node_map 
)
static

Make hash table from an in-flight SQL query's parse tree etc.

Definition at line 41 of file BaselineJoinHashTable.cpp.

References BaselineJoinHashTable(), HashJoin::getHashTypeString(), HashJoin::normalizeColumnPairs(), VLOG, and VLOGGING.

Referenced by HashJoin::getInstance().

52  {
53  decltype(std::chrono::steady_clock::now()) ts1, ts2;
54 
55  if (VLOGGING(1)) {
56  VLOG(1) << "Building keyed hash table " << getHashTypeString(preferred_hash_type)
57  << " for qual: " << condition->toString();
58  ts1 = std::chrono::steady_clock::now();
59  }
60  auto inner_outer_pairs =
61  HashJoin::normalizeColumnPairs(condition.get(), executor->getTemporaryTables());
62  const auto& inner_outer_cols = inner_outer_pairs.first;
63  const auto& col_pairs_string_op_infos = inner_outer_pairs.second;
64  auto join_hash_table = std::shared_ptr<BaselineJoinHashTable>(
65  new BaselineJoinHashTable(condition,
66  join_type,
67  query_infos,
68  memory_level,
69  column_cache,
70  executor,
71  inner_outer_cols,
72  col_pairs_string_op_infos,
73  device_count,
74  query_hints,
75  hashtable_build_dag_map,
76  table_id_to_node_map));
77  try {
78  join_hash_table->reify(preferred_hash_type);
79  } catch (const TableMustBeReplicated& e) {
80  // Throw a runtime error to abort the query
81  join_hash_table->freeHashBufferMemory();
82  throw std::runtime_error(e.what());
83  } catch (const HashJoinFail& e) {
84  // HashJoinFail exceptions log an error and trigger a retry with a join loop (if
85  // possible)
86  join_hash_table->freeHashBufferMemory();
87  throw HashJoinFail(std::string("Could not build a 1-to-1 correspondence for columns "
88  "involved in equijoin | ") +
89  e.what());
90  } catch (const ColumnarConversionNotSupported& e) {
91  throw HashJoinFail(std::string("Could not build hash tables for equijoin | ") +
92  e.what());
93  } catch (const OutOfMemory& e) {
94  throw HashJoinFail(
95  std::string("Ran out of memory while building hash tables for equijoin | ") +
96  e.what());
97  } catch (const JoinHashTableTooBig& e) {
98  throw e;
99  } catch (const std::exception& e) {
100  throw std::runtime_error(
101  std::string("Fatal error while attempting to build hash tables for join: ") +
102  e.what());
103  }
104  if (VLOGGING(1)) {
105  ts2 = std::chrono::steady_clock::now();
106  VLOG(1) << "Built keyed hash table "
107  << getHashTypeString(join_hash_table->getHashType()) << " in "
108  << std::chrono::duration_cast<std::chrono::milliseconds>(ts2 - ts1).count()
109  << " ms";
110  }
111  return join_hash_table;
112 }
BaselineJoinHashTable(const std::shared_ptr< Analyzer::BinOper > condition, const JoinType join_type, const std::vector< InputTableInfo > &query_infos, const Data_Namespace::MemoryLevel memory_level, ColumnCacheMap &column_cache, Executor *executor, const std::vector< InnerOuter > &inner_outer_pairs, const std::vector< InnerOuterStringOpInfos > &col_pairs_string_op_infos, const int device_count, const RegisteredQueryHint &query_hints, const HashTableBuildDagMap &hashtable_build_dag_map, const TableIdToNodeMap &table_id_to_node_map)
#define VLOGGING(n)
Definition: Logger.h:289
static std::string getHashTypeString(HashType ht) noexcept
Definition: HashJoin.h:165
static std::pair< std::vector< InnerOuter >, std::vector< InnerOuterStringOpInfos > > normalizeColumnPairs(const Analyzer::BinOper *condition, const TemporaryTables *temporary_tables)
Definition: HashJoin.cpp:996
#define VLOG(n)
Definition: Logger.h:387

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t BaselineJoinHashTable::getKeyBufferSize ( ) const
protectednoexcept

Definition at line 996 of file BaselineJoinHashTable.cpp.

References CHECK, HashJoin::getHashTableForDevice(), getKeyComponentCount(), getKeyComponentWidth(), and HashJoin::layoutRequiresAdditionalBuffers().

Referenced by countBufferOff(), offsetBufferOff(), and payloadBufferOff().

996  {
997  const auto key_component_width = getKeyComponentWidth();
998  CHECK(key_component_width == 4 || key_component_width == 8);
999  const auto key_component_count = getKeyComponentCount();
1000  auto hash_table = getHashTableForDevice(size_t(0));
1001  CHECK(hash_table);
1002  if (layoutRequiresAdditionalBuffers(hash_table->getLayout())) {
1003  return hash_table->getEntryCount() * key_component_count * key_component_width;
1004  } else {
1005  return hash_table->getEntryCount() * (key_component_count + 1) * key_component_width;
1006  }
1007 }
HashTable * getHashTableForDevice(const size_t device_id) const
Definition: HashJoin.h:281
#define CHECK(condition)
Definition: Logger.h:291
virtual size_t getKeyComponentCount() const
virtual size_t getKeyComponentWidth() const
static bool layoutRequiresAdditionalBuffers(HashType layout) noexcept
Definition: HashJoin.h:161

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t BaselineJoinHashTable::getKeyComponentCount ( ) const
protectedvirtual

Definition at line 704 of file BaselineJoinHashTable.cpp.

References inner_outer_pairs_.

Referenced by codegenKey(), codegenMatchingSet(), codegenSlot(), copyCpuHashTableToGpu(), getKeyBufferSize(), initHashTableForDevice(), toSet(), and toString().

704  {
705  return inner_outer_pairs_.size();
706 }
std::vector< InnerOuter > inner_outer_pairs_

+ Here is the caller graph for this function:

size_t BaselineJoinHashTable::getKeyComponentWidth ( ) const
protectedvirtual

Definition at line 692 of file BaselineJoinHashTable.cpp.

References CHECK_EQ, and inner_outer_pairs_.

Referenced by codegenKey(), codegenMatchingSet(), codegenSlot(), copyCpuHashTableToGpu(), getKeyBufferSize(), initHashTableForDevice(), toSet(), and toString().

692  {
693  for (const auto& inner_outer_pair : inner_outer_pairs_) {
694  const auto inner_col = inner_outer_pair.first;
695  const auto& inner_col_ti = inner_col->get_type_info();
696  if (inner_col_ti.get_logical_size() > 4) {
697  CHECK_EQ(8, inner_col_ti.get_logical_size());
698  return 8;
699  }
700  }
701  return 4;
702 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
std::vector< InnerOuter > inner_outer_pairs_

+ Here is the caller graph for this function:

Data_Namespace::MemoryLevel BaselineJoinHashTable::getMemoryLevel ( ) const
inlineoverridevirtualnoexcept

Implements HashJoin.

Definition at line 88 of file BaselineJoinHashTable.h.

References memory_level_.

88  {
89  return memory_level_;
90  };
const Data_Namespace::MemoryLevel memory_level_
const RegisteredQueryHint& BaselineJoinHashTable::getRegisteredQueryHint ( )
inline

Definition at line 137 of file BaselineJoinHashTable.h.

References query_hints_.

137 { return query_hints_; }
RegisteredQueryHint query_hints_
size_t BaselineJoinHashTable::getShardCountForCondition ( const Analyzer::BinOper condition,
const Executor executor,
const std::vector< InnerOuter > &  inner_outer_pairs 
)
static

Definition at line 144 of file BaselineJoinHashTable.cpp.

References get_shard_count().

Referenced by RangeJoinHashTable::getInstance(), reify(), shardCount(), OverlapsJoinHashTable::shardCount(), and Executor::skipFragmentPair().

147  {
148  for (const auto& inner_outer_pair : inner_outer_pairs) {
149  const auto pair_shard_count = get_shard_count(inner_outer_pair, executor);
150  if (pair_shard_count) {
151  return pair_shard_count;
152  }
153  }
154  return 0;
155 }
size_t get_shard_count(const Analyzer::BinOper *join_condition, const Executor *executor)
Definition: HashJoin.cpp:1048

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

llvm::Value * BaselineJoinHashTable::hashPtr ( const size_t  index)
protected

Definition at line 1065 of file BaselineJoinHashTable.cpp.

References AUTOMATIC_IR_METADATA, HashJoin::codegenHashTableLoad(), executor_, LL_BUILDER, and LL_CONTEXT.

Referenced by codegenSlot().

1065  {
1066  AUTOMATIC_IR_METADATA(executor_->cgen_state_.get());
1067  auto hash_ptr = HashJoin::codegenHashTableLoad(index, executor_);
1068  const auto pi8_type = llvm::Type::getInt8PtrTy(LL_CONTEXT);
1069  return hash_ptr->getType()->isPointerTy()
1070  ? LL_BUILDER.CreatePointerCast(hash_ptr, pi8_type)
1071  : LL_BUILDER.CreateIntToPtr(hash_ptr, pi8_type);
1072 }
static llvm::Value * codegenHashTableLoad(const size_t table_idx, Executor *executor)
Definition: HashJoin.cpp:257
#define LL_CONTEXT
#define AUTOMATIC_IR_METADATA(CGENSTATE)
#define LL_BUILDER

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int BaselineJoinHashTable::initHashTableForDevice ( const std::vector< JoinColumn > &  join_columns,
const std::vector< JoinColumnTypeInfo > &  join_column_types,
const std::vector< JoinBucketInfo > &  join_buckets,
const HashType  layout,
const Data_Namespace::MemoryLevel  effective_memory_level,
const size_t  entry_count,
const size_t  emitted_keys_count,
const int  device_id 
)
protectedvirtual

Definition at line 769 of file BaselineJoinHashTable.cpp.

References BASELINE_HT, CHECK, CHECK_EQ, CHECK_LT, copyCpuHashTableToGpu(), DataRecyclerUtil::CPU_DEVICE_IDENTIFIER, cpu_hash_table_buff_mutex_, Data_Namespace::CPU_LEVEL, DEBUG_TIMER, decomposeStrDictTranslationMaps(), executor_, HashJoin::getCompositeKeyInfo(), BaselineJoinHashTableBuilder::getHashTable(), getInnerTableId(), getKeyComponentCount(), getKeyComponentWidth(), getQueryEngineCudaStreamForDevice(), Data_Namespace::GPU_LEVEL, hash_table_layout_cache_, HashJoin::hash_tables_for_device_, hashtable_cache_key_, HT_HASHING_SCHEME, BaselineJoinHashTableBuilder::initHashTableOnCpu(), BaselineJoinHashTableBuilder::initHashTableOnGpu(), inner_outer_pairs_, inner_outer_string_op_infos_pairs_, HashtableRecycler::isSafeToCacheHashtable(), join_type_, memory_level_, needs_dict_translation_, putHashTableOnCpuToCache(), query_hints_, str_proxy_translation_maps_, table_id_to_node_map_, transfer_vector_of_flat_objects_to_gpu(), and UNREACHABLE.

Referenced by reifyForDevice().

777  {
778  auto timer = DEBUG_TIMER(__func__);
779  const auto key_component_count = getKeyComponentCount();
780  int err = 0;
781  decltype(std::chrono::steady_clock::now()) ts1, ts2;
782  ts1 = std::chrono::steady_clock::now();
783  auto allow_hashtable_recycling =
784  HashtableRecycler::isSafeToCacheHashtable(table_id_to_node_map_,
788  HashType hashtable_layout = layout;
789  if (effective_memory_level == Data_Namespace::CPU_LEVEL) {
790  std::lock_guard<std::mutex> cpu_hash_table_buff_lock(cpu_hash_table_buff_mutex_);
791 
792  const auto composite_key_info = HashJoin::getCompositeKeyInfo(
793  inner_outer_pairs_, executor_, inner_outer_string_op_infos_pairs_);
794 
795  CHECK(!join_columns.empty());
796 
798  CHECK_EQ(device_id, 0);
799  }
800  CHECK_LT(static_cast<size_t>(device_id), hash_tables_for_device_.size());
801  std::shared_ptr<HashTable> hash_table{nullptr};
802  const auto str_proxy_translation_map_ptrs_and_offsets =
805 
806  const auto key_handler =
807  GenericKeyHandler(key_component_count,
808  true,
809  &join_columns[0],
810  &join_column_types[0],
811  &str_proxy_translation_map_ptrs_and_offsets.first[0],
812  &str_proxy_translation_map_ptrs_and_offsets.second[0]);
813  err = builder.initHashTableOnCpu(&key_handler,
814  composite_key_info,
815  join_columns,
816  join_column_types,
817  join_bucket_info,
818  str_proxy_translation_map_ptrs_and_offsets,
819  entry_count,
820  join_columns.front().num_elems,
821  hashtable_layout,
822  join_type_,
825  query_hints_);
826  hash_tables_for_device_[device_id] = builder.getHashTable();
827  ts2 = std::chrono::steady_clock::now();
828  auto hashtable_build_time =
829  std::chrono::duration_cast<std::chrono::milliseconds>(ts2 - ts1).count();
830  if (!err && allow_hashtable_recycling && hash_tables_for_device_[device_id]) {
831  // add ht-related items to cache iff we have a valid hashtable
834  hash_tables_for_device_[device_id],
836  hashtable_build_time);
837 
838  hash_table_layout_cache_->putItemToCache(
839  hashtable_cache_key_[device_id],
840  hash_tables_for_device_[device_id]->getLayout(),
843  0,
844  0,
845  {});
846  }
847  // Transfer the hash table on the GPU if we've only built it on CPU
848  // but the query runs on GPU (join on dictionary encoded columns).
849  // Don't transfer the buffer if there was an error since we'll bail anyway.
850  if (memory_level_ == Data_Namespace::GPU_LEVEL && !err) {
851 #ifdef HAVE_CUDA
852  auto cpu_hash_table = std::dynamic_pointer_cast<BaselineHashTable>(
853  hash_tables_for_device_[device_id]);
854  copyCpuHashTableToGpu(cpu_hash_table, device_id, executor_->getDataMgr());
855 #else
856  CHECK(false);
857 #endif
858  }
859  } else {
860 #ifdef HAVE_CUDA
862 
863  auto data_mgr = executor_->getDataMgr();
864  CudaAllocator allocator(
865  data_mgr, device_id, getQueryEngineCudaStreamForDevice(device_id));
866  auto join_column_types_gpu =
867  transfer_vector_of_flat_objects_to_gpu(join_column_types, allocator);
868  auto join_columns_gpu =
869  transfer_vector_of_flat_objects_to_gpu(join_columns, allocator);
870  const auto key_handler = GenericKeyHandler(key_component_count,
871  true,
872  join_columns_gpu,
873  join_column_types_gpu,
874  nullptr,
875  nullptr);
876 
877  err = builder.initHashTableOnGpu(&key_handler,
878  join_columns,
879  hashtable_layout,
880  join_type_,
883  entry_count,
884  emitted_keys_count,
885  device_id,
886  executor_,
887  query_hints_);
888  CHECK_LT(static_cast<size_t>(device_id), hash_tables_for_device_.size());
889  hash_tables_for_device_[device_id] = builder.getHashTable();
890  if (!err && allow_hashtable_recycling && hash_tables_for_device_[device_id]) {
891  // add layout to cache iff we have a valid hashtable
892  hash_table_layout_cache_->putItemToCache(
893  hashtable_cache_key_[device_id],
894  hash_tables_for_device_[device_id]->getLayout(),
897  0,
898  0,
899  {});
900  }
901 #else
902  UNREACHABLE();
903 #endif
904  }
905  return err;
906 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
void putHashTableOnCpuToCache(QueryPlanHash key, CacheItemType item_type, std::shared_ptr< HashTable > hashtable_ptr, DeviceIdentifier device_identifier, size_t hashtable_building_time)
std::vector< QueryPlanHash > hashtable_cache_key_
std::vector< std::shared_ptr< HashTable > > hash_tables_for_device_
Definition: HashJoin.h:363
#define UNREACHABLE()
Definition: Logger.h:337
int initHashTableOnGpu(KEY_HANDLER *key_handler, const std::vector< JoinColumn > &join_columns, const HashType layout, const JoinType join_type, const size_t key_component_width, const size_t key_component_count, const size_t keyspace_entry_count, const size_t emitted_keys_count, const int device_id, const Executor *executor, const RegisteredQueryHint &query_hint)
int initHashTableOnCpu(KEY_HANDLER *key_handler, const CompositeKeyInfo &composite_key_info, const std::vector< JoinColumn > &join_columns, const std::vector< JoinColumnTypeInfo > &join_column_types, const std::vector< JoinBucketInfo > &join_bucket_info, const StrProxyTranslationMapsPtrsAndOffsets &str_proxy_translation_maps_ptrs_and_offsets, const size_t keyspace_entry_count, const size_t keys_for_all_rows, const HashType layout, const JoinType join_type, const size_t key_component_width, const size_t key_component_count, const RegisteredQueryHint &query_hint)
const TableIdToNodeMap table_id_to_node_map_
RegisteredQueryHint query_hints_
std::vector< InnerOuter > inner_outer_pairs_
std::vector< InnerOuterStringOpInfos > inner_outer_string_op_infos_pairs_
#define CHECK_LT(x, y)
Definition: Logger.h:303
std::unique_ptr< BaselineHashTable > getHashTable()
CUstream getQueryEngineCudaStreamForDevice(int device_num)
Definition: QueryEngine.cpp:7
const Data_Namespace::MemoryLevel memory_level_
#define CHECK(condition)
Definition: Logger.h:291
#define DEBUG_TIMER(name)
Definition: Logger.h:411
virtual size_t getKeyComponentCount() const
void copyCpuHashTableToGpu(std::shared_ptr< BaselineHashTable > &cpu_hash_table, const int device_id, Data_Namespace::DataMgr *data_mgr)
std::vector< const StringDictionaryProxy::IdMap * > str_proxy_translation_maps_
virtual size_t getKeyComponentWidth() const
T * transfer_vector_of_flat_objects_to_gpu(const std::vector< T > &vec, DeviceAllocator &allocator)
static std::unique_ptr< HashingSchemeRecycler > hash_table_layout_cache_
static constexpr DeviceIdentifier CPU_DEVICE_IDENTIFIER
Definition: DataRecycler.h:136
StrProxyTranslationMapsPtrsAndOffsets decomposeStrDictTranslationMaps(const std::vector< const StringDictionaryProxy::IdMap * > &str_proxy_translation_maps)
shared::TableKey getInnerTableId() const noexceptoverride
HashType
Definition: HashTable.h:19
static CompositeKeyInfo getCompositeKeyInfo(const std::vector< InnerOuter > &inner_outer_pairs, const Executor *executor, const std::vector< InnerOuterStringOpInfos > &inner_outer_string_op_infos_pairs={})
Definition: HashJoin.cpp:461

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::shared_ptr< HashTable > BaselineJoinHashTable::initHashTableOnCpuFromCache ( QueryPlanHash  key,
CacheItemType  item_type,
DeviceIdentifier  device_identifier 
)
protected

Definition at line 1111 of file BaselineJoinHashTable.cpp.

References CHECK, DEBUG_TIMER, hash_table_cache_, and VLOG.

Referenced by reifyWithLayout().

1114  {
1115  auto timer = DEBUG_TIMER(__func__);
1116  VLOG(1) << "Checking CPU hash table cache.";
1118  return hash_table_cache_->getItemFromCache(key, item_type, device_identifier);
1119 }
static std::unique_ptr< HashtableRecycler > hash_table_cache_
#define CHECK(condition)
Definition: Logger.h:291
#define DEBUG_TIMER(name)
Definition: Logger.h:411
#define VLOG(n)
Definition: Logger.h:387

+ Here is the caller graph for this function:

static void BaselineJoinHashTable::invalidateCache ( )
inlinestatic

Definition at line 102 of file BaselineJoinHashTable.h.

References CHECK, hash_table_cache_, and hash_table_layout_cache_.

102  {
104  hash_table_cache_->clearCache();
105 
107  hash_table_layout_cache_->clearCache();
108  }
static std::unique_ptr< HashtableRecycler > hash_table_cache_
#define CHECK(condition)
Definition: Logger.h:291
static std::unique_ptr< HashingSchemeRecycler > hash_table_layout_cache_
bool BaselineJoinHashTable::isBitwiseEq ( ) const
overrideprotectedvirtual

Implements HashJoin.

Definition at line 1138 of file BaselineJoinHashTable.cpp.

References condition_, and kBW_EQ.

Referenced by fetchColumnsForDevice().

1138  {
1139  return condition_->get_optype() == kBW_EQ;
1140 }
Definition: sqldefs.h:30
const std::shared_ptr< Analyzer::BinOper > condition_

+ Here is the caller graph for this function:

static void BaselineJoinHashTable::markCachedItemAsDirty ( size_t  table_key)
inlinestatic

Definition at line 110 of file BaselineJoinHashTable.h.

References BASELINE_HT, CHECK, DataRecyclerUtil::CPU_DEVICE_IDENTIFIER, hash_table_cache_, hash_table_layout_cache_, and HT_HASHING_SCHEME.

110  {
113  auto candidate_table_keys =
114  hash_table_cache_->getMappedQueryPlanDagsWithTableKey(table_key);
115  if (candidate_table_keys.has_value()) {
116  hash_table_layout_cache_->markCachedItemAsDirty(
117  table_key,
118  *candidate_table_keys,
121  hash_table_cache_->markCachedItemAsDirty(table_key,
122  *candidate_table_keys,
125  }
126  }
static std::unique_ptr< HashtableRecycler > hash_table_cache_
#define CHECK(condition)
Definition: Logger.h:291
static std::unique_ptr< HashingSchemeRecycler > hash_table_layout_cache_
static constexpr DeviceIdentifier CPU_DEVICE_IDENTIFIER
Definition: DataRecycler.h:136
size_t BaselineJoinHashTable::offsetBufferOff ( ) const
overridevirtualnoexcept

Implements HashJoin.

Definition at line 976 of file BaselineJoinHashTable.cpp.

References getKeyBufferSize().

Referenced by codegenMatchingSet(), countBufferOff(), toSet(), and toString().

976  {
977  return getKeyBufferSize();
978 }
size_t getKeyBufferSize() const noexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t BaselineJoinHashTable::payloadBufferOff ( ) const
overridevirtualnoexcept

Implements HashJoin.

Definition at line 988 of file BaselineJoinHashTable.cpp.

References countBufferOff(), getComponentBufferSize(), getHashType(), getKeyBufferSize(), and HashJoin::layoutRequiresAdditionalBuffers().

Referenced by toSet(), and toString().

988  {
991  } else {
992  return getKeyBufferSize();
993  }
994 }
size_t getKeyBufferSize() const noexcept
size_t getComponentBufferSize() const noexceptoverride
HashType getHashType() const noexceptoverride
static bool layoutRequiresAdditionalBuffers(HashType layout) noexcept
Definition: HashJoin.h:161
size_t countBufferOff() const noexceptoverride

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void BaselineJoinHashTable::putHashTableOnCpuToCache ( QueryPlanHash  key,
CacheItemType  item_type,
std::shared_ptr< HashTable hashtable_ptr,
DeviceIdentifier  device_identifier,
size_t  hashtable_building_time 
)
protected

Definition at line 1121 of file BaselineJoinHashTable.cpp.

References CHECK, CPU, and hash_table_cache_.

Referenced by initHashTableForDevice().

1126  {
1128  CHECK(hashtable_ptr && !hashtable_ptr->getGpuBuffer());
1129  hash_table_cache_->putItemToCache(
1130  key,
1131  hashtable_ptr,
1132  item_type,
1133  device_identifier,
1134  hashtable_ptr->getHashTableBufferSize(ExecutorDeviceType::CPU),
1135  hashtable_building_time);
1136 }
static std::unique_ptr< HashtableRecycler > hash_table_cache_
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function:

void BaselineJoinHashTable::reify ( const HashType  preferred_layout)
protected

Definition at line 248 of file BaselineJoinHashTable.cpp.

References CHECK_EQ, CHECK_LT, HashJoin::checkHashJoinReplicationConstraint(), condition_, DEBUG_TIMER, device_count_, executor_, HashJoin::freeHashBufferMemory(), HashJoin::getCompositeKeyInfo(), getInnerTableId(), getShardCountForCondition(), inner_outer_pairs_, inner_outer_string_op_infos_pairs_, ManyToMany, needs_dict_translation_, needs_dictionary_translation(), OneToMany, reifyWithLayout(), and VLOG.

248  {
249  auto timer = DEBUG_TIMER(__func__);
251  const auto composite_key_info = HashJoin::getCompositeKeyInfo(
255 
260  executor_);
261 
262  auto layout = preferred_layout;
263  if (condition_->is_overlaps_oper()) {
264  CHECK_EQ(inner_outer_pairs_.size(), size_t(1));
265 
266  if (inner_outer_pairs_[0].second->get_type_info().is_array()) {
267  layout = HashType::ManyToMany;
268  } else {
269  layout = HashType::OneToMany;
270  }
271  try {
272  reifyWithLayout(layout);
273  return;
274  } catch (const std::exception& e) {
275  VLOG(1) << "Caught exception while building overlaps baseline hash table: "
276  << e.what();
277  throw;
278  }
279  }
280 
281  // Automatically prefer One-To-Many layouts when string operations are involved as these
282  // tend to be cardinality-reducing operations.
283  // Todo(todd): Ostensibly only string ops on the rhs/inner expression cause rhs dups and
284  // so we may be too conservative here, but validate
285 
286  for (const auto& inner_outer_string_op_infos : inner_outer_string_op_infos_pairs_) {
287  if (inner_outer_string_op_infos.first.size() ||
288  inner_outer_string_op_infos.second.size()) {
289  layout = HashType::OneToMany;
290  break;
291  }
292  }
293 
294  try {
295  reifyWithLayout(layout);
296  } catch (const std::exception& e) {
297  VLOG(1) << "Caught exception while building baseline hash table: " << e.what();
298  // In perfect hash we CHECK that the layout is not OnetoMany here, but for baseline
299  // we are catching all exceptions, so should determine if that is safe first
300  // before we would CHECK and not throw an exception here
301  if (layout == HashType::OneToMany) {
302  throw(e);
303  }
306  }
307 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
static void checkHashJoinReplicationConstraint(const shared::TableKey &table_key, const size_t shard_count, const Executor *executor)
Definition: HashJoin.cpp:779
bool needs_dictionary_translation(const std::vector< InnerOuter > &inner_outer_pairs, const std::vector< InnerOuterStringOpInfos > &inner_outer_string_op_infos_pairs, const Executor *executor)
void freeHashBufferMemory()
Definition: HashJoin.h:323
std::vector< InnerOuter > inner_outer_pairs_
std::vector< InnerOuterStringOpInfos > inner_outer_string_op_infos_pairs_
virtual void reifyWithLayout(const HashType layout)
#define CHECK_LT(x, y)
Definition: Logger.h:303
#define DEBUG_TIMER(name)
Definition: Logger.h:411
static size_t getShardCountForCondition(const Analyzer::BinOper *condition, const Executor *executor, const std::vector< InnerOuter > &inner_outer_pairs)
shared::TableKey getInnerTableId() const noexceptoverride
#define VLOG(n)
Definition: Logger.h:387
const std::shared_ptr< Analyzer::BinOper > condition_
static CompositeKeyInfo getCompositeKeyInfo(const std::vector< InnerOuter > &inner_outer_pairs, const Executor *executor, const std::vector< InnerOuterStringOpInfos > &inner_outer_string_op_infos_pairs={})
Definition: HashJoin.cpp:461

+ Here is the call graph for this function:

void BaselineJoinHashTable::reifyForDevice ( const ColumnsForDevice columns_for_device,
const HashType  layout,
const int  device_id,
const size_t  entry_count,
const size_t  emitted_keys_count,
const logger::ThreadLocalIds  parent_thread_local_ids 
)
protectedvirtual

Definition at line 658 of file BaselineJoinHashTable.cpp.

References DEBUG_TIMER_NEW_THREAD, get_effective_memory_level(), initHashTableForDevice(), ColumnsForDevice::join_buckets, ColumnsForDevice::join_column_types, ColumnsForDevice::join_columns, memory_level_, needs_dict_translation_, logger::ThreadLocalIds::setNewThreadId(), logger::ThreadLocalIds::thread_id_, and to_string().

Referenced by reifyWithLayout().

664  {
665  logger::LocalIdsScopeGuard lisg = parent_thread_local_ids.setNewThreadId();
666  DEBUG_TIMER_NEW_THREAD(parent_thread_local_ids.thread_id_);
667  const auto effective_memory_level =
669  const auto err = initHashTableForDevice(columns_for_device.join_columns,
670  columns_for_device.join_column_types,
671  columns_for_device.join_buckets,
672  layout,
673  effective_memory_level,
674  entry_count,
675  emitted_keys_count,
676  device_id);
677  if (err) {
678  throw HashJoinFail(
679  std::string("Unrecognized error when initializing baseline hash table (") +
680  std::to_string(err) + std::string(")"));
681  }
682 }
Data_Namespace::MemoryLevel get_effective_memory_level(const Data_Namespace::MemoryLevel memory_level, const bool needs_dict_translation)
#define DEBUG_TIMER_NEW_THREAD(parent_thread_id)
Definition: Logger.h:416
std::string to_string(char const *&&v)
const std::vector< JoinColumnTypeInfo > join_column_types
Definition: HashJoin.h:112
LocalIdsScopeGuard setNewThreadId() const
Definition: Logger.cpp:532
const Data_Namespace::MemoryLevel memory_level_
virtual int initHashTableForDevice(const std::vector< JoinColumn > &join_columns, const std::vector< JoinColumnTypeInfo > &join_column_types, const std::vector< JoinBucketInfo > &join_buckets, const HashType layout, const Data_Namespace::MemoryLevel effective_memory_level, const size_t entry_count, const size_t emitted_keys_count, const int device_id)
ThreadId thread_id_
Definition: Logger.h:138
std::vector< JoinBucketInfo > join_buckets
Definition: HashJoin.h:114
const std::vector< JoinColumn > join_columns
Definition: HashJoin.h:111

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void BaselineJoinHashTable::reifyWithLayout ( const HashType  layout)
protectedvirtual

Definition at line 309 of file BaselineJoinHashTable.cpp.

References gpu_enabled::accumulate(), approximateTupleCount(), threading_serial::async(), BASELINE_HT, HashJoin::canAccessHashTable(), CHECK, CHECK_EQ, condition_, copyCpuHashTableToGpu(), DataRecyclerUtil::CPU_DEVICE_IDENTIFIER, Data_Namespace::CPU_LEVEL, device_count_, executor_, fetchColumnsForDevice(), genChunkKey(), get_entries_per_device(), get_inner_query_info(), getAlternativeCacheKey(), DataRecyclerUtil::getAlternativeTableKeys(), HashJoin::getCompositeKeyInfo(), getEffectiveMemoryLevel(), HashtableRecycler::getHashtableAccessPathInfo(), getInnerTableId(), Fragmenter_Namespace::TableInfo::getNumTuplesUpperBound(), getQueryEngineCudaStreamForDevice(), Data_Namespace::GPU_LEVEL, hash_table_cache_, HashJoin::hash_tables_for_device_, hashtable_build_dag_map_, hashtable_cache_key_, hashtable_cache_meta_info_, InputTableInfo::info, initHashTableOnCpuFromCache(), inner_outer_pairs_, inner_outer_string_op_infos_pairs_, HashtableRecycler::isInvalidHashTableCacheKey(), HashtableRecycler::isSafeToCacheHashtable(), join_type_, memory_level_, needs_dict_translation_, HashJoin::normalizeColumnPairs(), OneToMany, only_shards_for_device(), query_infos_, reifyForDevice(), shardCount(), str_proxy_translation_maps_, str_proxy_translation_mutex_, shared::TableKey::table_id, table_id_to_node_map_, table_keys_, logger::thread_local_ids(), HashJoin::translateCompositeStrDictProxies(), and UNREACHABLE.

Referenced by reify().

309  {
310  const auto& query_info = get_inner_query_info(getInnerTableId(), query_infos_).info;
311  if (query_info.fragments.empty()) {
312  return;
313  }
314 
315  const auto total_entries = 2 * query_info.getNumTuplesUpperBound();
316  if (total_entries > static_cast<size_t>(std::numeric_limits<int32_t>::max())) {
317  throw TooManyHashEntries();
318  }
319 
320  std::vector<std::unique_ptr<CudaAllocator>> dev_buff_owners;
321  std::vector<std::vector<Fragmenter_Namespace::FragmentInfo>> fragments_per_device;
322  std::vector<ColumnsForDevice> columns_per_device;
323  const auto shard_count = shardCount();
324  auto entries_per_device =
325  get_entries_per_device(total_entries, shard_count, device_count_, memory_level_);
326  auto data_mgr = executor_->getDataMgr();
327  // cached hash table lookup logic is similar with perfect join hash table
328  // first, prepare fragment lists per device
329  std::vector<ChunkKey> chunk_key_per_device;
330  for (int device_id = 0; device_id < device_count_; ++device_id) {
331  fragments_per_device.emplace_back(
332  shard_count
333  ? only_shards_for_device(query_info.fragments, device_id, device_count_)
334  : query_info.fragments);
336  dev_buff_owners.emplace_back(std::make_unique<CudaAllocator>(
337  data_mgr, device_id, getQueryEngineCudaStreamForDevice(device_id)));
338  }
339  const auto chunk_key = genChunkKey(fragments_per_device[device_id]);
340  chunk_key_per_device.emplace_back(std::move(chunk_key));
341  }
342 
343  // prepare per-device cache key
344  auto inner_outer_pairs =
345  HashJoin::normalizeColumnPairs(condition_.get(), executor_->getTemporaryTables());
346  const auto& inner_outer_cols = inner_outer_pairs.first;
347  const auto& col_pairs_string_op_infos = inner_outer_pairs.second;
348  auto hashtable_access_path_info =
350  col_pairs_string_op_infos,
351  condition_->get_optype(),
352  join_type_,
355  shard_count,
356  fragments_per_device,
357  executor_);
358  hashtable_cache_key_ = hashtable_access_path_info.hashed_query_plan_dag;
359  hashtable_cache_meta_info_ = hashtable_access_path_info.meta_info;
360  table_keys_ = hashtable_access_path_info.table_keys;
361 
362  // the actual chunks fetched per device can be different but they constitute the same
363  // table in the same db, so we can exploit this to create an alternative table key
364  if (table_keys_.empty()) {
365  const auto& inner_table_key = getInnerTableId();
366  table_keys_ =
367  DataRecyclerUtil::getAlternativeTableKeys(chunk_key_per_device, inner_table_key);
368  }
369  CHECK(!table_keys_.empty());
370 
371  if (HashtableRecycler::isInvalidHashTableCacheKey(hashtable_cache_key_) &&
372  getInnerTableId().table_id > 0) {
373  // sometimes we cannot retrieve query plan dag, so try to recycler cache
374  // with the old-passioned cache key if we deal with hashtable of non-temporary table
375  for (int device_id = 0; device_id < device_count_; ++device_id) {
376  const auto num_tuples = std::accumulate(fragments_per_device[device_id].begin(),
377  fragments_per_device[device_id].end(),
378  size_t(0),
379  [](const auto& sum, const auto& fragment) {
380  return sum + fragment.getNumTuples();
381  });
382  AlternativeCacheKeyForBaselineHashJoin cache_key{inner_outer_pairs_,
384  num_tuples,
385  condition_->get_optype(),
386  join_type_,
387  chunk_key_per_device[device_id]};
388  hashtable_cache_key_[device_id] = getAlternativeCacheKey(cache_key);
389  }
390  }
391 
392  // register a mapping between cache key and input tables of the hash table
393  const auto invalid_cache_key =
394  HashtableRecycler::isInvalidHashTableCacheKey(hashtable_cache_key_);
395  if (!invalid_cache_key) {
396  if (!shard_count) {
397  hash_table_cache_->addQueryPlanDagForTableKeys(hashtable_cache_key_.front(),
398  table_keys_);
399  } else {
400  std::for_each(hashtable_cache_key_.cbegin(),
401  hashtable_cache_key_.cend(),
402  [this](QueryPlanHash key) {
403  hash_table_cache_->addQueryPlanDagForTableKeys(key, table_keys_);
404  });
405  }
406  }
407 
408  // now, let's try to check whether we have a cached hash table for this join qual
409  const auto effective_memory_level = getEffectiveMemoryLevel(inner_outer_pairs_);
410 
411  // todo (yoonmin) : support dictionary proxy cache for join including string op(s)
412  if (effective_memory_level == Data_Namespace::CPU_LEVEL) {
413  std::unique_lock<std::mutex> str_proxy_translation_lock(str_proxy_translation_mutex_);
414  if (str_proxy_translation_maps_.empty()) {
415  const auto composite_key_info = HashJoin::getCompositeKeyInfo(
418  composite_key_info, inner_outer_string_op_infos_pairs_, executor_);
420  }
421  }
422 
423  auto allow_hashtable_recycling =
428  bool has_invalid_cached_hash_table = false;
429  if (effective_memory_level == Data_Namespace::CPU_LEVEL &&
431  allow_hashtable_recycling, invalid_cache_key, join_type_)) {
432  // build a hash table on CPU, and we have a chance to recycle the cached one if
433  // available
434  for (int device_id = 0; device_id < device_count_; ++device_id) {
435  auto hash_table =
436  initHashTableOnCpuFromCache(hashtable_cache_key_[device_id],
439  if (hash_table) {
440  hash_tables_for_device_[device_id] = hash_table;
441  } else {
442  has_invalid_cached_hash_table = true;
443  break;
444  }
445  }
446 
447  if (has_invalid_cached_hash_table) {
448  hash_tables_for_device_.clear();
449  hash_tables_for_device_.resize(device_count_);
450  } else {
452 #ifdef HAVE_CUDA
453  auto data_mgr = executor_->getDataMgr();
454  for (int device_id = 0; device_id < device_count_; ++device_id) {
455  auto cpu_hash_table = std::dynamic_pointer_cast<BaselineHashTable>(
456  hash_tables_for_device_[device_id]);
457  copyCpuHashTableToGpu(cpu_hash_table, device_id, data_mgr);
458  }
459 #else
460  UNREACHABLE();
461 #endif
462  }
463  return;
464  }
465  }
466 
467  // we have no cached hash table for this qual
468  // so, start building the hash table by fetching columns for devices
469  for (int device_id = 0; device_id < device_count_; ++device_id) {
470  const auto columns_for_device =
471  fetchColumnsForDevice(fragments_per_device[device_id],
472  device_id,
474  ? dev_buff_owners[device_id].get()
475  : nullptr);
476  columns_per_device.push_back(columns_for_device);
477  }
478 
479  auto hashtable_layout_type = layout;
480  size_t emitted_keys_count = 0;
481  if (hashtable_layout_type == HashType::OneToMany) {
482  CHECK(!columns_per_device.front().join_columns.empty());
483  emitted_keys_count = columns_per_device.front().join_columns.front().num_elems;
484  size_t tuple_count;
485  std::tie(tuple_count, std::ignore) = approximateTupleCount(columns_per_device);
486  const auto entry_count = 2 * std::max(tuple_count, size_t(1));
487 
488  // reset entries per device with one to many info
489  entries_per_device =
490  get_entries_per_device(entry_count, shard_count, device_count_, memory_level_);
491  }
492  std::vector<std::future<void>> init_threads;
493  for (int device_id = 0; device_id < device_count_; ++device_id) {
494  const auto fragments =
495  shard_count
496  ? only_shards_for_device(query_info.fragments, device_id, device_count_)
497  : query_info.fragments;
498  init_threads.push_back(std::async(std::launch::async,
500  this,
501  columns_per_device[device_id],
502  hashtable_layout_type,
503  device_id,
504  entries_per_device,
505  emitted_keys_count,
507  }
508  for (auto& init_thread : init_threads) {
509  init_thread.wait();
510  }
511  for (auto& init_thread : init_threads) {
512  init_thread.get();
513  }
514 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
Fragmenter_Namespace::TableInfo info
Definition: InputMetadata.h:35
std::vector< QueryPlanHash > hashtable_cache_key_
static bool isInvalidHashTableCacheKey(const std::vector< QueryPlanHash > &cache_keys)
Data_Namespace::MemoryLevel getEffectiveMemoryLevel(const std::vector< InnerOuter > &inner_outer_pairs) const
static bool canAccessHashTable(bool allow_hash_table_recycling, bool invalid_cache_key, JoinType join_type)
Definition: HashJoin.cpp:1030
std::vector< std::shared_ptr< HashTable > > hash_tables_for_device_
Definition: HashJoin.h:363
#define UNREACHABLE()
Definition: Logger.h:337
const InputTableInfo & get_inner_query_info(const shared::TableKey &inner_table_key, const std::vector< InputTableInfo > &query_infos)
HashTableBuildDagMap hashtable_build_dag_map_
const TableIdToNodeMap table_id_to_node_map_
std::unordered_set< size_t > table_keys_
virtual ColumnsForDevice fetchColumnsForDevice(const std::vector< Fragmenter_Namespace::FragmentInfo > &fragments, const int device_id, DeviceAllocator *dev_buff_owner)
const std::vector< InputTableInfo > & query_infos_
std::shared_ptr< HashTable > initHashTableOnCpuFromCache(QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier)
std::vector< InnerOuter > inner_outer_pairs_
future< Result > async(Fn &&fn, Args &&...args)
static QueryPlanHash getAlternativeCacheKey(AlternativeCacheKeyForBaselineHashJoin &info)
std::vector< InnerOuterStringOpInfos > inner_outer_string_op_infos_pairs_
static std::unique_ptr< HashtableRecycler > hash_table_cache_
std::vector< Fragmenter_Namespace::FragmentInfo > only_shards_for_device(const std::vector< Fragmenter_Namespace::FragmentInfo > &fragments, const int device_id, const int device_count)
DEVICE auto accumulate(ARGS &&...args)
Definition: gpu_enabled.h:42
virtual std::pair< size_t, size_t > approximateTupleCount(const std::vector< ColumnsForDevice > &) 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)
Definition: HashJoin.cpp:509
HashtableCacheMetaInfo hashtable_cache_meta_info_
static std::unordered_set< size_t > getAlternativeTableKeys(const std::vector< ChunkKey > &chunk_keys, const shared::TableKey &inner_table_key)
Definition: DataRecycler.h:154
virtual void reifyForDevice(const ColumnsForDevice &columns_for_device, const HashType layout, const int device_id, const size_t entry_count, const size_t emitted_keys_count, const logger::ThreadLocalIds parent_thread_local_ids)
size_t get_entries_per_device(const size_t total_entries, const size_t shard_count, const size_t device_count, const Data_Namespace::MemoryLevel memory_level)
size_t QueryPlanHash
CUstream getQueryEngineCudaStreamForDevice(int device_num)
Definition: QueryEngine.cpp:7
const Data_Namespace::MemoryLevel memory_level_
#define CHECK(condition)
Definition: Logger.h:291
static bool isSafeToCacheHashtable(const TableIdToNodeMap &table_id_to_node_map, bool need_dict_translation, const std::vector< InnerOuterStringOpInfos > &inner_outer_string_op_info_pairs, const shared::TableKey &table_key)
static std::pair< std::vector< InnerOuter >, std::vector< InnerOuterStringOpInfos > > normalizeColumnPairs(const Analyzer::BinOper *condition, const TemporaryTables *temporary_tables)
Definition: HashJoin.cpp:996
void copyCpuHashTableToGpu(std::shared_ptr< BaselineHashTable > &cpu_hash_table, const int device_id, Data_Namespace::DataMgr *data_mgr)
ChunkKey genChunkKey(const std::vector< Fragmenter_Namespace::FragmentInfo > &fragments) const
std::vector< const StringDictionaryProxy::IdMap * > str_proxy_translation_maps_
static constexpr DeviceIdentifier CPU_DEVICE_IDENTIFIER
Definition: DataRecycler.h:136
static HashtableAccessPathInfo getHashtableAccessPathInfo(const std::vector< InnerOuter > &inner_outer_pairs, const std::vector< InnerOuterStringOpInfos > &inner_outer_string_op_infos_pairs, const SQLOps op_type, const JoinType join_type, const HashTableBuildDagMap &hashtable_build_dag_map, int device_count, int shard_count, const std::vector< std::vector< Fragmenter_Namespace::FragmentInfo >> &frags_for_device, Executor *executor)
shared::TableKey getInnerTableId() const noexceptoverride
ThreadLocalIds thread_local_ids()
Definition: Logger.cpp:874
const std::shared_ptr< Analyzer::BinOper > condition_
static CompositeKeyInfo getCompositeKeyInfo(const std::vector< InnerOuter > &inner_outer_pairs, const Executor *executor, const std::vector< InnerOuterStringOpInfos > &inner_outer_string_op_infos_pairs={})
Definition: HashJoin.cpp:461

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t BaselineJoinHashTable::shardCount ( ) const
protected

Definition at line 684 of file BaselineJoinHashTable.cpp.

References condition_, executor_, getShardCountForCondition(), Data_Namespace::GPU_LEVEL, inner_outer_pairs_, and memory_level_.

Referenced by reifyWithLayout().

684  {
686  return 0;
687  }
690 }
std::vector< InnerOuter > inner_outer_pairs_
const Data_Namespace::MemoryLevel memory_level_
static size_t getShardCountForCondition(const Analyzer::BinOper *condition, const Executor *executor, const std::vector< InnerOuter > &inner_outer_pairs)
const std::shared_ptr< Analyzer::BinOper > condition_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::set< DecodedJoinHashBufferEntry > BaselineJoinHashTable::toSet ( const ExecutorDeviceType  device_type,
const int  device_id 
) const
overridevirtual

Implements HashJoin.

Definition at line 198 of file BaselineJoinHashTable.cpp.

References CHECK, countBufferOff(), executor_, HashJoin::getHashTableForDevice(), HashJoin::getJoinHashBuffer(), getKeyComponentCount(), getKeyComponentWidth(), getQueryEngineCudaStreamForDevice(), GPU, offsetBufferOff(), OneToOne, payloadBufferOff(), and HashTable::toSet().

200  {
201  auto buffer = getJoinHashBuffer(device_type, device_id);
202  auto hash_table = getHashTableForDevice(device_id);
203  CHECK(hash_table);
204  auto buffer_size = hash_table->getHashTableBufferSize(device_type);
205 #ifdef HAVE_CUDA
206  std::unique_ptr<int8_t[]> buffer_copy;
207  if (device_type == ExecutorDeviceType::GPU) {
208  buffer_copy = std::make_unique<int8_t[]>(buffer_size);
209  auto data_mgr = executor_->getDataMgr();
210  auto device_allocator = std::make_unique<CudaAllocator>(
211  data_mgr, device_id, getQueryEngineCudaStreamForDevice(device_id));
212  device_allocator->copyFromDevice(buffer_copy.get(), buffer, buffer_size);
213  }
214  auto ptr1 = buffer_copy ? buffer_copy.get() : buffer;
215 #else
216  auto ptr1 = buffer;
217 #endif // HAVE_CUDA
218  auto ptr2 = ptr1 + offsetBufferOff();
219  auto ptr3 = ptr1 + countBufferOff();
220  auto ptr4 = ptr1 + payloadBufferOff();
221  const auto layout = hash_table->getLayout();
222  return HashTable::toSet(getKeyComponentCount() + (layout == HashType::OneToOne ? 1 : 0),
224  hash_table->getEntryCount(),
225  ptr1,
226  ptr2,
227  ptr3,
228  ptr4,
229  buffer_size);
230 }
size_t offsetBufferOff() const noexceptoverride
size_t payloadBufferOff() const noexceptoverride
int8_t * getJoinHashBuffer(const ExecutorDeviceType device_type, const int device_id) const
Definition: HashJoin.h:300
HashTable * getHashTableForDevice(const size_t device_id) const
Definition: HashJoin.h:281
CUstream getQueryEngineCudaStreamForDevice(int device_num)
Definition: QueryEngine.cpp:7
#define CHECK(condition)
Definition: Logger.h:291
virtual size_t getKeyComponentCount() const
virtual size_t getKeyComponentWidth() const
static DecodedJoinHashBufferSet toSet(size_t key_component_count, size_t key_component_width, size_t entry_count, const int8_t *ptr1, const int8_t *ptr2, const int8_t *ptr3, const int8_t *ptr4, size_t buffer_size)
Decode hash table into a std::set for easy inspection and validation.
Definition: HashTable.cpp:139
size_t countBufferOff() const noexceptoverride

+ Here is the call graph for this function:

std::string BaselineJoinHashTable::toString ( const ExecutorDeviceType  device_type,
const int  device_id = 0,
bool  raw = false 
) const
overridevirtual

Implements HashJoin.

Definition at line 157 of file BaselineJoinHashTable.cpp.

References CHECK, CHECK_LT, countBufferOff(), executor_, getHashType(), HashJoin::getHashTypeString(), HashJoin::getJoinHashBuffer(), getKeyComponentCount(), getKeyComponentWidth(), getQueryEngineCudaStreamForDevice(), GPU, HashJoin::hash_tables_for_device_, offsetBufferOff(), OneToOne, payloadBufferOff(), and HashTable::toString().

Referenced by getAlternativeCacheKey().

159  {
160  auto buffer = getJoinHashBuffer(device_type, device_id);
161  CHECK_LT(static_cast<size_t>(device_id), hash_tables_for_device_.size());
162  auto hash_table = hash_tables_for_device_[device_id];
163  CHECK(hash_table);
164  auto buffer_size = hash_table->getHashTableBufferSize(device_type);
165 #ifdef HAVE_CUDA
166  std::unique_ptr<int8_t[]> buffer_copy;
167  if (device_type == ExecutorDeviceType::GPU) {
168  buffer_copy = std::make_unique<int8_t[]>(buffer_size);
169 
170  auto data_mgr = executor_->getDataMgr();
171  auto device_allocator = std::make_unique<CudaAllocator>(
172  data_mgr, device_id, getQueryEngineCudaStreamForDevice(device_id));
173  device_allocator->copyFromDevice(buffer_copy.get(), buffer, buffer_size);
174  }
175  auto ptr1 = buffer_copy ? buffer_copy.get() : buffer;
176 #else
177  auto ptr1 = buffer;
178 #endif // HAVE_CUDA
179  auto ptr2 = ptr1 + offsetBufferOff();
180  auto ptr3 = ptr1 + countBufferOff();
181  auto ptr4 = ptr1 + payloadBufferOff();
182  CHECK(hash_table);
183  const auto layout = getHashType();
184  return HashTable::toString(
185  "keyed",
186  getHashTypeString(layout),
187  getKeyComponentCount() + (layout == HashType::OneToOne ? 1 : 0),
189  hash_table->getEntryCount(),
190  ptr1,
191  ptr2,
192  ptr3,
193  ptr4,
194  buffer_size,
195  raw);
196 }
size_t offsetBufferOff() const noexceptoverride
std::vector< std::shared_ptr< HashTable > > hash_tables_for_device_
Definition: HashJoin.h:363
size_t payloadBufferOff() const noexceptoverride
HashType getHashType() const noexceptoverride
int8_t * getJoinHashBuffer(const ExecutorDeviceType device_type, const int device_id) const
Definition: HashJoin.h:300
#define CHECK_LT(x, y)
Definition: Logger.h:303
static std::string getHashTypeString(HashType ht) noexcept
Definition: HashJoin.h:165
static std::string toString(const std::string &type, const std::string &layout_type, size_t key_component_count, size_t key_component_width, size_t entry_count, const int8_t *ptr1, const int8_t *ptr2, const int8_t *ptr3, const int8_t *ptr4, size_t buffer_size, bool raw=false)
Decode hash table into a human-readable string.
Definition: HashTable.cpp:226
CUstream getQueryEngineCudaStreamForDevice(int device_num)
Definition: QueryEngine.cpp:7
#define CHECK(condition)
Definition: Logger.h:291
virtual size_t getKeyComponentCount() const
virtual size_t getKeyComponentWidth() const
size_t countBufferOff() const noexceptoverride

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

ColumnCacheMap& BaselineJoinHashTable::column_cache_
protected

Definition at line 259 of file BaselineJoinHashTable.h.

Referenced by fetchColumnsForDevice().

const std::shared_ptr<Analyzer::BinOper> BaselineJoinHashTable::condition_
protected

Definition at line 254 of file BaselineJoinHashTable.h.

Referenced by isBitwiseEq(), reify(), reifyWithLayout(), and shardCount().

std::mutex BaselineJoinHashTable::cpu_hash_table_buff_mutex_
protected

Definition at line 260 of file BaselineJoinHashTable.h.

Referenced by initHashTableForDevice().

const int BaselineJoinHashTable::device_count_
protected
std::unique_ptr< HashtableRecycler > BaselineJoinHashTable::hash_table_cache_
staticprotected
std::unique_ptr< HashingSchemeRecycler > BaselineJoinHashTable::hash_table_layout_cache_
staticprotected
Initial value:
=
std::make_unique<HashingSchemeRecycler>()

Definition at line 280 of file BaselineJoinHashTable.h.

Referenced by getHashingSchemeCache(), initHashTableForDevice(), invalidateCache(), and markCachedItemAsDirty().

HashTableBuildDagMap BaselineJoinHashTable::hashtable_build_dag_map_
protected

Definition at line 272 of file BaselineJoinHashTable.h.

Referenced by reifyWithLayout().

std::vector<QueryPlanHash> BaselineJoinHashTable::hashtable_cache_key_
protected

Definition at line 274 of file BaselineJoinHashTable.h.

Referenced by initHashTableForDevice(), and reifyWithLayout().

HashtableCacheMetaInfo BaselineJoinHashTable::hashtable_cache_meta_info_
protected

Definition at line 275 of file BaselineJoinHashTable.h.

Referenced by reifyWithLayout().

std::vector<InnerOuterStringOpInfos> BaselineJoinHashTable::inner_outer_string_op_infos_pairs_
protected
const JoinType BaselineJoinHashTable::join_type_
protected

Definition at line 255 of file BaselineJoinHashTable.h.

Referenced by initHashTableForDevice(), and reifyWithLayout().

std::optional<HashType> BaselineJoinHashTable::layout_override_
protected

Definition at line 270 of file BaselineJoinHashTable.h.

Referenced by getHashType().

bool BaselineJoinHashTable::needs_dict_translation_
mutableprotected
RegisteredQueryHint BaselineJoinHashTable::query_hints_
protected
const std::vector<InputTableInfo>& BaselineJoinHashTable::query_infos_
protected

Definition at line 256 of file BaselineJoinHashTable.h.

Referenced by reifyWithLayout().

std::vector<const StringDictionaryProxy::IdMap*> BaselineJoinHashTable::str_proxy_translation_maps_
protected

Definition at line 262 of file BaselineJoinHashTable.h.

Referenced by initHashTableForDevice(), and reifyWithLayout().

std::mutex BaselineJoinHashTable::str_proxy_translation_mutex_
protected

Definition at line 261 of file BaselineJoinHashTable.h.

Referenced by reifyWithLayout().

const TableIdToNodeMap BaselineJoinHashTable::table_id_to_node_map_
protected

Definition at line 277 of file BaselineJoinHashTable.h.

Referenced by initHashTableForDevice(), and reifyWithLayout().

std::unordered_set<size_t> BaselineJoinHashTable::table_keys_
protected

Definition at line 276 of file BaselineJoinHashTable.h.

Referenced by reifyWithLayout().


The documentation for this class was generated from the following files: