OmniSciDB  c0231cc57d
 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
 
int 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
 
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 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, std::string_view table2, std::string_view column2, const Data_Namespace::MemoryLevel memory_level, const HashType preferred_hash_type, const int device_count, ColumnCacheMap &column_cache, Executor *executor)
 Make hash table from named tables and columns (such as for testing). 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 int 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 int table_id, const size_t shard_count, const Executor *executor)
 
static std::pair< InnerOuter,
InnerOuterStringOpInfos
normalizeColumnPair (const Analyzer::Expr *lhs, const Analyzer::Expr *rhs, const Catalog_Namespace::Catalog &cat, const TemporaryTables *temporary_tables, const bool is_overlaps_join=false)
 
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 Catalog_Namespace::Catalog &cat, 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 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::ThreadId parent_thread_id)
 
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 int 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 Catalog_Namespace::Catalogcatalog_
 
const int device_count_
 
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 136 of file BaselineJoinHashTable.h.

136 {}
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 HashTableBuildDagMap hashtable_build_dag_map,
const TableIdToNodeMap table_id_to_node_map 
)
protected

Definition at line 111 of file BaselineJoinHashTable.cpp.

References CHECK_GT, device_count_, and HashJoin::hash_tables_for_device_.

Referenced by getInstance().

123  : condition_(condition)
124  , join_type_(join_type)
125  , query_infos_(query_infos)
126  , memory_level_(memory_level)
127  , executor_(executor)
128  , column_cache_(column_cache)
129  , inner_outer_pairs_(inner_outer_pairs)
130  , inner_outer_string_op_infos_pairs_(col_pairs_string_op_infos)
131  , catalog_(executor->getCatalog())
132  , device_count_(device_count)
133  , needs_dict_translation_(false)
134  , hashtable_build_dag_map_(hashtable_build_dag_map)
135  , table_id_to_node_map_(table_id_to_node_map) {
137  hash_tables_for_device_.resize(std::max(device_count_, 1));
138 }
std::vector< std::shared_ptr< HashTable > > hash_tables_for_device_
Definition: HashJoin.h:351
HashTableBuildDagMap hashtable_build_dag_map_
const TableIdToNodeMap table_id_to_node_map_
#define CHECK_GT(x, y)
Definition: Logger.h:234
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 Catalog_Namespace::Catalog * catalog_
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 513 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().

514  {
515  const auto effective_memory_level = getEffectiveMemoryLevel(inner_outer_pairs_);
516  CountDistinctDescriptor count_distinct_desc{
518  0,
519  11,
520  true,
521  effective_memory_level == Data_Namespace::MemoryLevel::GPU_LEVEL
524  1};
525  const auto padded_size_bytes = count_distinct_desc.bitmapPaddedSizeBytes();
526 
527  CHECK(!columns_per_device.empty() && !columns_per_device.front().join_columns.empty());
528 
529  if (effective_memory_level == Data_Namespace::MemoryLevel::CPU_LEVEL) {
530  int thread_count = cpu_threads();
531  std::vector<uint8_t> hll_buffer_all_cpus(thread_count * padded_size_bytes);
532  auto hll_result = &hll_buffer_all_cpus[0];
533 
534  approximate_distinct_tuples(hll_result,
535  count_distinct_desc.bitmap_sz_bits,
536  padded_size_bytes,
537  columns_per_device.front().join_columns,
538  columns_per_device.front().join_column_types,
539  thread_count);
540  for (int i = 1; i < thread_count; ++i) {
541  hll_unify(hll_result,
542  hll_result + i * padded_size_bytes,
543  1 << count_distinct_desc.bitmap_sz_bits);
544  }
545  return std::make_pair(hll_size(hll_result, count_distinct_desc.bitmap_sz_bits), 0);
546  }
547 #ifdef HAVE_CUDA
548  auto data_mgr = executor_->getDataMgr();
549  std::vector<std::vector<uint8_t>> host_hll_buffers(device_count_);
550  for (auto& host_hll_buffer : host_hll_buffers) {
551  host_hll_buffer.resize(count_distinct_desc.bitmapPaddedSizeBytes());
552  }
553  std::vector<std::future<void>> approximate_distinct_device_threads;
554  for (int device_id = 0; device_id < device_count_; ++device_id) {
555  approximate_distinct_device_threads.emplace_back(std::async(
557  [device_id,
558  &columns_per_device,
559  &count_distinct_desc,
560  data_mgr,
561  &host_hll_buffers] {
562  auto allocator = std::make_unique<CudaAllocator>(
563  data_mgr, device_id, getQueryEngineCudaStreamForDevice(device_id));
564  auto device_hll_buffer =
565  allocator->alloc(count_distinct_desc.bitmapPaddedSizeBytes());
566  data_mgr->getCudaMgr()->zeroDeviceMem(
567  device_hll_buffer,
568  count_distinct_desc.bitmapPaddedSizeBytes(),
569  device_id,
571  const auto& columns_for_device = columns_per_device[device_id];
572  auto join_columns_gpu = transfer_vector_of_flat_objects_to_gpu(
573  columns_for_device.join_columns, *allocator);
574  auto join_column_types_gpu = transfer_vector_of_flat_objects_to_gpu(
575  columns_for_device.join_column_types, *allocator);
576  const auto key_handler =
577  GenericKeyHandler(columns_for_device.join_columns.size(),
578  true,
579  join_columns_gpu,
580  join_column_types_gpu,
581  nullptr,
582  nullptr);
583  const auto key_handler_gpu =
584  transfer_flat_object_to_gpu(key_handler, *allocator);
586  reinterpret_cast<uint8_t*>(device_hll_buffer),
587  count_distinct_desc.bitmap_sz_bits,
588  key_handler_gpu,
589  columns_for_device.join_columns[0].num_elems);
590 
591  auto& host_hll_buffer = host_hll_buffers[device_id];
592  allocator->copyFromDevice(&host_hll_buffer[0],
593  device_hll_buffer,
594  count_distinct_desc.bitmapPaddedSizeBytes());
595  }));
596  }
597  for (auto& child : approximate_distinct_device_threads) {
598  child.get();
599  }
600  CHECK_EQ(Data_Namespace::MemoryLevel::GPU_LEVEL, effective_memory_level);
601  auto& result_hll_buffer = host_hll_buffers.front();
602  auto hll_result = reinterpret_cast<int32_t*>(&result_hll_buffer[0]);
603  for (int device_id = 1; device_id < device_count_; ++device_id) {
604  auto& host_hll_buffer = host_hll_buffers[device_id];
605  hll_unify(hll_result,
606  reinterpret_cast<int32_t*>(&host_hll_buffer[0]),
607  1 << count_distinct_desc.bitmap_sz_bits);
608  }
609  return std::make_pair(hll_size(hll_result, count_distinct_desc.bitmap_sz_bits), 0);
610 #else
611  UNREACHABLE();
612  return {0, 0};
613 #endif // HAVE_CUDA
614 }
#define CHECK_EQ(x, y)
Definition: Logger.h:230
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:266
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:222
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 1007 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().

1007  {
1008  AUTOMATIC_IR_METADATA(executor_->cgen_state_.get());
1009  const auto key_component_width = getKeyComponentWidth();
1010  CHECK(key_component_width == 4 || key_component_width == 8);
1011  const auto key_size_lv = LL_INT(getKeyComponentCount() * key_component_width);
1012  llvm::Value* key_buff_lv{nullptr};
1013  switch (key_component_width) {
1014  case 4:
1015  key_buff_lv =
1016  LL_BUILDER.CreateAlloca(llvm::Type::getInt32Ty(LL_CONTEXT), key_size_lv);
1017  break;
1018  case 8:
1019  key_buff_lv =
1020  LL_BUILDER.CreateAlloca(llvm::Type::getInt64Ty(LL_CONTEXT), key_size_lv);
1021  break;
1022  default:
1023  CHECK(false);
1024  }
1025 
1026  CodeGenerator code_generator(executor_);
1027  for (size_t i = 0; i < getKeyComponentCount(); ++i) {
1028  const auto key_comp_dest_lv = LL_BUILDER.CreateGEP(
1029  key_buff_lv->getType()->getScalarType()->getPointerElementType(),
1030  key_buff_lv,
1031  LL_INT(i));
1032  const auto& inner_outer_pair = inner_outer_pairs_[i];
1033  const auto outer_col = inner_outer_pair.second;
1034  const auto key_col_var = dynamic_cast<const Analyzer::ColumnVar*>(outer_col);
1035  const auto val_col_var =
1036  dynamic_cast<const Analyzer::ColumnVar*>(inner_outer_pair.first);
1037  if (key_col_var && val_col_var &&
1039  key_col_var,
1040  val_col_var,
1041  get_max_rte_scan_table(executor_->cgen_state_->scan_idx_to_hash_pos_))) {
1042  throw std::runtime_error(
1043  "Query execution fails because the query contains not supported self-join "
1044  "pattern. We suspect the query requires multiple left-deep join tree due to "
1045  "the join condition of the self-join and is not supported for now. Please "
1046  "consider rewriting table order in "
1047  "FROM clause.");
1048  }
1049  auto key_lv = HashJoin::codegenColOrStringOper(
1050  outer_col, inner_outer_string_op_infos_pairs_[i].second, code_generator, co);
1051  const auto key_lv_ext =
1052  LL_BUILDER.CreateSExt(key_lv, get_int_type(key_component_width * 8, LL_CONTEXT));
1053  LL_BUILDER.CreateStore(key_lv_ext, key_comp_dest_lv);
1054  }
1055  return key_buff_lv;
1056 }
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:539
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:222
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 925 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().

927  {
928  AUTOMATIC_IR_METADATA(executor_->cgen_state_.get());
929  const auto hash_table = getHashTableForDevice(size_t(0));
930  CHECK(hash_table);
931  const auto key_component_width = getKeyComponentWidth();
932  CHECK(key_component_width == 4 || key_component_width == 8);
933  auto key_buff_lv = codegenKey(co);
935  auto hash_ptr = HashJoin::codegenHashTableLoad(index, executor_);
936  const auto composite_dict_ptr_type =
937  llvm::Type::getIntNPtrTy(LL_CONTEXT, key_component_width * 8);
938  const auto composite_key_dict =
939  hash_ptr->getType()->isPointerTy()
940  ? LL_BUILDER.CreatePointerCast(hash_ptr, composite_dict_ptr_type)
941  : LL_BUILDER.CreateIntToPtr(hash_ptr, composite_dict_ptr_type);
942  const auto key_component_count = getKeyComponentCount();
943  const auto key = executor_->cgen_state_->emitExternalCall(
944  "get_composite_key_index_" + std::to_string(key_component_width * 8),
946  {key_buff_lv,
947  LL_INT(key_component_count),
948  composite_key_dict,
949  LL_INT(hash_table->getEntryCount())});
950  auto one_to_many_ptr = hash_ptr;
951  if (one_to_many_ptr->getType()->isPointerTy()) {
952  one_to_many_ptr =
953  LL_BUILDER.CreatePtrToInt(hash_ptr, llvm::Type::getInt64Ty(LL_CONTEXT));
954  } else {
955  CHECK(one_to_many_ptr->getType()->isIntegerTy(64));
956  }
957  const auto composite_key_dict_size = offsetBufferOff();
958  one_to_many_ptr =
959  LL_BUILDER.CreateAdd(one_to_many_ptr, LL_INT(composite_key_dict_size));
961  {one_to_many_ptr, key, LL_INT(int64_t(0)), LL_INT(hash_table->getEntryCount() - 1)},
962  false,
963  false,
964  false,
966  executor_);
967 }
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:269
#define LL_BUILDER
#define CHECK(condition)
Definition: Logger.h:222
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 907 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().

908  {
909  AUTOMATIC_IR_METADATA(executor_->cgen_state_.get());
911  const auto key_component_width = getKeyComponentWidth();
912  CHECK(key_component_width == 4 || key_component_width == 8);
913  auto key_buff_lv = codegenKey(co);
914  const auto hash_ptr = hashPtr(index);
915  const auto key_ptr_lv =
916  LL_BUILDER.CreatePointerCast(key_buff_lv, llvm::Type::getInt8PtrTy(LL_CONTEXT));
917  const auto key_size_lv = LL_INT(getKeyComponentCount() * key_component_width);
918  const auto hash_table = getHashTableForDevice(size_t(0));
919  return executor_->cgen_state_->emitExternalCall(
920  "baseline_hash_join_idx_" + std::to_string(key_component_width * 8),
922  {hash_ptr, key_ptr_lv, key_size_lv, LL_INT(hash_table->getEntryCount())});
923 }
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:269
#define LL_BUILDER
llvm::Value * hashPtr(const size_t index)
#define CHECK(condition)
Definition: Logger.h:222
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 714 of file BaselineJoinHashTable.cpp.

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

Referenced by initHashTableForDevice(), and reifyWithLayout().

717  {
719 
720  builder.allocateDeviceMemory(cpu_hash_table->getLayout(),
723  cpu_hash_table->getEntryCount(),
724  cpu_hash_table->getEmittedKeysCount(),
725  device_id,
726  executor_);
727  auto gpu_target_hash_table = builder.getHashTable();
728  CHECK(gpu_target_hash_table);
729 
730  const auto gpu_buff = gpu_target_hash_table->getGpuBuffer();
731  CHECK(gpu_buff);
732  auto allocator = std::make_unique<CudaAllocator>(
733  data_mgr, device_id, getQueryEngineCudaStreamForDevice(device_id));
734  allocator->copyToDevice(
735  gpu_buff,
736  cpu_hash_table->getCpuBuffer(),
737  cpu_hash_table->getHashTableBufferSize(ExecutorDeviceType::CPU));
738  hash_tables_for_device_[device_id] = std::move(gpu_target_hash_table);
739 }
std::vector< std::shared_ptr< HashTable > > hash_tables_for_device_
Definition: HashJoin.h:351
std::unique_ptr< BaselineHashTable > getHashTable()
CUstream getQueryEngineCudaStreamForDevice(int device_num)
Definition: QueryEngine.cpp:7
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)
#define CHECK(condition)
Definition: Logger.h:222
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 973 of file BaselineJoinHashTable.cpp.

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

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

973  {
976  } else {
977  return getKeyBufferSize();
978  }
979 }
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:150

+ 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 616 of file BaselineJoinHashTable.cpp.

References catalog_, 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().

619  {
620  const auto effective_memory_level =
622 
623  std::vector<JoinColumn> join_columns;
624  std::vector<std::shared_ptr<Chunk_NS::Chunk>> chunks_owner;
625  std::vector<JoinColumnTypeInfo> join_column_types;
626  std::vector<JoinBucketInfo> join_bucket_info;
627  std::vector<std::shared_ptr<void>> malloc_owner;
628  for (const auto& inner_outer_pair : inner_outer_pairs_) {
629  const auto inner_col = inner_outer_pair.first;
630  const auto inner_cd = get_column_descriptor_maybe(
631  inner_col->get_column_id(), inner_col->get_table_id(), *catalog_);
632  if (inner_cd && inner_cd->isVirtualCol) {
634  }
635  join_columns.emplace_back(fetchJoinColumn(inner_col,
636  fragments,
637  effective_memory_level,
638  device_id,
639  chunks_owner,
640  dev_buff_owner,
641  malloc_owner,
642  executor_,
643  &column_cache_));
644  const auto& ti = inner_col->get_type_info();
645  join_column_types.emplace_back(JoinColumnTypeInfo{static_cast<size_t>(ti.get_size()),
646  0,
647  0,
649  isBitwiseEq(),
650  0,
652  }
653  return {join_columns, join_column_types, chunks_owner, join_bucket_info, malloc_owner};
654 }
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 int col_id, const int table_id, const Catalog_Namespace::Catalog &cat)
Definition: Execute.h:220
ColumnCacheMap & column_cache_
const Catalog_Namespace::Catalog * catalog_
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 1135 of file BaselineJoinHashTable.cpp.

Referenced by reifyWithLayout().

1136  {
1137  std::vector<int> fragment_ids;
1138  std::for_each(
1139  fragments.cbegin(), fragments.cend(), [&fragment_ids](const auto& fragment) {
1140  fragment_ids.push_back(fragment.fragmentId);
1141  });
1142  return fragment_ids;
1143 }

+ Here is the caller graph for this function:

static QueryPlanHash BaselineJoinHashTable::getAlternativeCacheKey ( AlternativeCacheKeyForBaselineHashJoin info)
inlinestaticprotected

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

230  {
231  auto hash = boost::hash_value(::toString(info.optype));
232  for (InnerOuter inner_outer : info.inner_outer_pairs) {
233  auto inner_col = inner_outer.first;
234  auto rhs_col_var = dynamic_cast<const Analyzer::ColumnVar*>(inner_outer.second);
235  auto outer_col = rhs_col_var ? rhs_col_var : inner_col;
236  boost::hash_combine(hash, inner_col->toString());
237  if (inner_col->get_type_info().is_string()) {
238  boost::hash_combine(hash, outer_col->toString());
239  }
240  }
241  if (info.inner_outer_string_op_infos_pairs.size()) {
242  boost::hash_combine(hash, ::toString(info.inner_outer_string_op_infos_pairs));
243  }
244  boost::hash_combine(hash, info.num_elements);
245  boost::hash_combine(hash, info.join_type);
246  return hash;
247  }
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:95

+ 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 1002 of file BaselineJoinHashTable.cpp.

References HashJoin::getHashTableForDevice().

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

1002  {
1003  const auto hash_table = getHashTableForDevice(size_t(0));
1004  return hash_table->getEntryCount() * sizeof(int32_t);
1005 }
HashTable * getHashTableForDevice(const size_t device_id) const
Definition: HashJoin.h:269

+ 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 91 of file BaselineJoinHashTable.h.

References device_count_.

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

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

705  {
707  inner_outer_pairs, inner_outer_string_op_infos_pairs_, executor_)) {
710  }
711  return memory_level_;
712 }
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 131 of file BaselineJoinHashTable.h.

References CHECK, and hash_table_layout_cache_.

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

Implements HashJoin.

Definition at line 99 of file BaselineJoinHashTable.h.

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

Definition at line 127 of file BaselineJoinHashTable.h.

References CHECK, and hash_table_cache_.

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

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

+ Here is the caller graph for this function:

HashType BaselineJoinHashTable::getHashType ( ) const
overridevirtualnoexcept

Implements HashJoin.

Definition at line 1087 of file BaselineJoinHashTable.cpp.

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

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

1087  {
1088  auto hash_table = getHashTableForDevice(size_t(0));
1089  CHECK(hash_table);
1090  if (layout_override_) {
1091  return *layout_override_;
1092  } else {
1093  return hash_table->getLayout();
1094  }
1095 }
HashTable * getHashTableForDevice(const size_t device_id) const
Definition: HashJoin.h:269
std::optional< HashType > layout_override_
#define CHECK(condition)
Definition: Logger.h:222

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int BaselineJoinHashTable::getInnerTableId ( ) const
overridevirtualnoexcept

Implements HashJoin.

Definition at line 1072 of file BaselineJoinHashTable.cpp.

References CHECK, and inner_outer_pairs_.

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

1072  {
1073  try {
1075  } catch (...) {
1076  CHECK(false);
1077  }
1078  return 0;
1079 }
std::vector< InnerOuter > inner_outer_pairs_
int getInnerTableId() const noexceptoverride
#define CHECK(condition)
Definition: Logger.h:222

+ Here is the caller graph for this function:

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

Definition at line 1097 of file BaselineJoinHashTable.cpp.

References CHECK.

1098  {
1099  CHECK(!inner_outer_pairs.empty());
1100  const auto first_inner_col = inner_outer_pairs.front().first;
1101  return first_inner_col->get_table_id();
1102 }
#define CHECK(condition)
Definition: Logger.h:222
int BaselineJoinHashTable::getInnerTableRteIdx ( ) const
overridevirtualnoexcept

Implements HashJoin.

Definition at line 1081 of file BaselineJoinHashTable.cpp.

References CHECK, and inner_outer_pairs_.

1081  {
1082  CHECK(!inner_outer_pairs_.empty());
1083  const auto first_inner_col = inner_outer_pairs_.front().first;
1084  return first_inner_col->get_rte_idx();
1085 }
std::vector< InnerOuter > inner_outer_pairs_
#define CHECK(condition)
Definition: Logger.h:222
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 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().

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

+ 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 989 of file BaselineJoinHashTable.cpp.

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

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

989  {
990  const auto key_component_width = getKeyComponentWidth();
991  CHECK(key_component_width == 4 || key_component_width == 8);
992  const auto key_component_count = getKeyComponentCount();
993  auto hash_table = getHashTableForDevice(size_t(0));
994  CHECK(hash_table);
995  if (layoutRequiresAdditionalBuffers(hash_table->getLayout())) {
996  return hash_table->getEntryCount() * key_component_count * key_component_width;
997  } else {
998  return hash_table->getEntryCount() * (key_component_count + 1) * key_component_width;
999  }
1000 }
HashTable * getHashTableForDevice(const size_t device_id) const
Definition: HashJoin.h:269
#define CHECK(condition)
Definition: Logger.h:222
virtual size_t getKeyComponentCount() const
virtual size_t getKeyComponentWidth() const
static bool layoutRequiresAdditionalBuffers(HashType layout) noexcept
Definition: HashJoin.h:150

+ 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 700 of file BaselineJoinHashTable.cpp.

References inner_outer_pairs_.

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

700  {
701  return inner_outer_pairs_.size();
702 }
std::vector< InnerOuter > inner_outer_pairs_

+ Here is the caller graph for this function:

size_t BaselineJoinHashTable::getKeyComponentWidth ( ) const
protectedvirtual

Definition at line 688 of file BaselineJoinHashTable.cpp.

References CHECK_EQ, and inner_outer_pairs_.

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

688  {
689  for (const auto& inner_outer_pair : inner_outer_pairs_) {
690  const auto inner_col = inner_outer_pair.first;
691  const auto& inner_col_ti = inner_col->get_type_info();
692  if (inner_col_ti.get_logical_size() > 4) {
693  CHECK_EQ(8, inner_col_ti.get_logical_size());
694  return 8;
695  }
696  }
697  return 4;
698 }
#define CHECK_EQ(x, y)
Definition: Logger.h:230
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 87 of file BaselineJoinHashTable.h.

References memory_level_.

87  {
88  return memory_level_;
89  };
const Data_Namespace::MemoryLevel memory_level_
size_t BaselineJoinHashTable::getShardCountForCondition ( const Analyzer::BinOper condition,
const Executor executor,
const std::vector< InnerOuter > &  inner_outer_pairs 
)
static

Definition at line 140 of file BaselineJoinHashTable.cpp.

References get_shard_count().

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

143  {
144  for (const auto& inner_outer_pair : inner_outer_pairs) {
145  const auto pair_shard_count = get_shard_count(inner_outer_pair, executor);
146  if (pair_shard_count) {
147  return pair_shard_count;
148  }
149  }
150  return 0;
151 }
size_t get_shard_count(const Analyzer::BinOper *join_condition, const Executor *executor)
Definition: HashJoin.cpp:1045

+ 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 1058 of file BaselineJoinHashTable.cpp.

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

Referenced by codegenSlot().

1058  {
1059  AUTOMATIC_IR_METADATA(executor_->cgen_state_.get());
1060  auto hash_ptr = HashJoin::codegenHashTableLoad(index, executor_);
1061  const auto pi8_type = llvm::Type::getInt8PtrTy(LL_CONTEXT);
1062  return hash_ptr->getType()->isPointerTy()
1063  ? LL_BUILDER.CreatePointerCast(hash_ptr, pi8_type)
1064  : LL_BUILDER.CreateIntToPtr(hash_ptr, pi8_type);
1065 }
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 764 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(), str_proxy_translation_maps_, table_id_to_node_map_, transfer_vector_of_flat_objects_to_gpu(), and UNREACHABLE.

Referenced by reifyForDevice().

772  {
773  auto timer = DEBUG_TIMER(__func__);
774  const auto key_component_count = getKeyComponentCount();
775  int err = 0;
776  decltype(std::chrono::steady_clock::now()) ts1, ts2;
777  ts1 = std::chrono::steady_clock::now();
778  auto allow_hashtable_recycling =
779  HashtableRecycler::isSafeToCacheHashtable(table_id_to_node_map_,
783  HashType hashtable_layout = layout;
784  if (effective_memory_level == Data_Namespace::CPU_LEVEL) {
785  std::lock_guard<std::mutex> cpu_hash_table_buff_lock(cpu_hash_table_buff_mutex_);
786 
787  const auto composite_key_info = HashJoin::getCompositeKeyInfo(
788  inner_outer_pairs_, executor_, inner_outer_string_op_infos_pairs_);
789 
790  CHECK(!join_columns.empty());
791 
793  CHECK_EQ(device_id, 0);
794  }
795  CHECK_LT(static_cast<size_t>(device_id), hash_tables_for_device_.size());
796  std::shared_ptr<HashTable> hash_table{nullptr};
797  const auto str_proxy_translation_map_ptrs_and_offsets =
800 
801  const auto key_handler =
802  GenericKeyHandler(key_component_count,
803  true,
804  &join_columns[0],
805  &join_column_types[0],
806  &str_proxy_translation_map_ptrs_and_offsets.first[0],
807  &str_proxy_translation_map_ptrs_and_offsets.second[0]);
808  err = builder.initHashTableOnCpu(&key_handler,
809  composite_key_info,
810  join_columns,
811  join_column_types,
812  join_bucket_info,
813  str_proxy_translation_map_ptrs_and_offsets,
814  entry_count,
815  join_columns.front().num_elems,
816  hashtable_layout,
817  join_type_,
820  hash_tables_for_device_[device_id] = builder.getHashTable();
821  ts2 = std::chrono::steady_clock::now();
822  auto hashtable_build_time =
823  std::chrono::duration_cast<std::chrono::milliseconds>(ts2 - ts1).count();
824  if (!err && allow_hashtable_recycling && hash_tables_for_device_[device_id]) {
825  // add ht-related items to cache iff we have a valid hashtable
828  hash_tables_for_device_[device_id],
830  hashtable_build_time);
831 
832  hash_table_layout_cache_->putItemToCache(
833  hashtable_cache_key_[device_id],
834  hash_tables_for_device_[device_id]->getLayout(),
837  0,
838  0,
839  {});
840  }
841  // Transfer the hash table on the GPU if we've only built it on CPU
842  // but the query runs on GPU (join on dictionary encoded columns).
843  // Don't transfer the buffer if there was an error since we'll bail anyway.
844  if (memory_level_ == Data_Namespace::GPU_LEVEL && !err) {
845 #ifdef HAVE_CUDA
846  auto cpu_hash_table = std::dynamic_pointer_cast<BaselineHashTable>(
847  hash_tables_for_device_[device_id]);
848  copyCpuHashTableToGpu(cpu_hash_table, device_id, executor_->getDataMgr());
849 #else
850  CHECK(false);
851 #endif
852  }
853  } else {
854 #ifdef HAVE_CUDA
856 
857  auto data_mgr = executor_->getDataMgr();
858  CudaAllocator allocator(
859  data_mgr, device_id, getQueryEngineCudaStreamForDevice(device_id));
860  auto join_column_types_gpu =
861  transfer_vector_of_flat_objects_to_gpu(join_column_types, allocator);
862  auto join_columns_gpu =
863  transfer_vector_of_flat_objects_to_gpu(join_columns, allocator);
864  const auto key_handler = GenericKeyHandler(key_component_count,
865  true,
866  join_columns_gpu,
867  join_column_types_gpu,
868  nullptr,
869  nullptr);
870 
871  err = builder.initHashTableOnGpu(&key_handler,
872  join_columns,
873  hashtable_layout,
874  join_type_,
877  entry_count,
878  emitted_keys_count,
879  device_id,
880  executor_);
881  CHECK_LT(static_cast<size_t>(device_id), hash_tables_for_device_.size());
882  hash_tables_for_device_[device_id] = builder.getHashTable();
883  if (!err && allow_hashtable_recycling && hash_tables_for_device_[device_id]) {
884  // add layout to cache iff we have a valid hashtable
885  hash_table_layout_cache_->putItemToCache(
886  hashtable_cache_key_[device_id],
887  hash_tables_for_device_[device_id]->getLayout(),
890  0,
891  0,
892  {});
893  }
894 #else
895  UNREACHABLE();
896 #endif
897  }
898  return err;
899 }
#define CHECK_EQ(x, y)
Definition: Logger.h:230
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_
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)
std::vector< std::shared_ptr< HashTable > > hash_tables_for_device_
Definition: HashJoin.h:351
#define UNREACHABLE()
Definition: Logger.h:266
const TableIdToNodeMap table_id_to_node_map_
std::vector< InnerOuter > inner_outer_pairs_
std::vector< InnerOuterStringOpInfos > inner_outer_string_op_infos_pairs_
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)
#define CHECK_LT(x, y)
Definition: Logger.h:232
int getInnerTableId() const noexceptoverride
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:222
#define DEBUG_TIMER(name)
Definition: Logger.h:371
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)
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:455

+ 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 1104 of file BaselineJoinHashTable.cpp.

References CHECK, DEBUG_TIMER, hash_table_cache_, and VLOG.

Referenced by reifyWithLayout().

1107  {
1108  auto timer = DEBUG_TIMER(__func__);
1109  VLOG(1) << "Checking CPU hash table cache.";
1111  return hash_table_cache_->getItemFromCache(key, item_type, device_identifier);
1112 }
static std::unique_ptr< HashtableRecycler > hash_table_cache_
#define CHECK(condition)
Definition: Logger.h:222
#define DEBUG_TIMER(name)
Definition: Logger.h:371
#define VLOG(n)
Definition: Logger.h:316

+ Here is the caller graph for this function:

static void BaselineJoinHashTable::invalidateCache ( )
inlinestatic

Definition at line 101 of file BaselineJoinHashTable.h.

References CHECK, hash_table_cache_, and hash_table_layout_cache_.

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

Implements HashJoin.

Definition at line 1131 of file BaselineJoinHashTable.cpp.

References condition_, and kBW_EQ.

Referenced by fetchColumnsForDevice().

1131  {
1132  return condition_->get_optype() == kBW_EQ;
1133 }
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 109 of file BaselineJoinHashTable.h.

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

109  {
112  auto candidate_table_keys =
113  hash_table_cache_->getMappedQueryPlanDagsWithTableKey(table_key);
114  if (candidate_table_keys.has_value()) {
115  hash_table_layout_cache_->markCachedItemAsDirty(
116  table_key,
117  *candidate_table_keys,
120  hash_table_cache_->markCachedItemAsDirty(table_key,
121  *candidate_table_keys,
124  }
125  }
static std::unique_ptr< HashtableRecycler > hash_table_cache_
#define CHECK(condition)
Definition: Logger.h:222
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 969 of file BaselineJoinHashTable.cpp.

References getKeyBufferSize().

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

969  {
970  return getKeyBufferSize();
971 }
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 981 of file BaselineJoinHashTable.cpp.

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

Referenced by toSet(), and toString().

981  {
984  } else {
985  return getKeyBufferSize();
986  }
987 }
size_t getKeyBufferSize() const noexcept
size_t getComponentBufferSize() const noexceptoverride
HashType getHashType() const noexceptoverride
static bool layoutRequiresAdditionalBuffers(HashType layout) noexcept
Definition: HashJoin.h:150
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 1114 of file BaselineJoinHashTable.cpp.

References CHECK, CPU, and hash_table_cache_.

Referenced by initHashTableForDevice().

1119  {
1121  CHECK(hashtable_ptr && !hashtable_ptr->getGpuBuffer());
1122  hash_table_cache_->putItemToCache(
1123  key,
1124  hashtable_ptr,
1125  item_type,
1126  device_identifier,
1127  hashtable_ptr->getHashTableBufferSize(ExecutorDeviceType::CPU),
1128  hashtable_building_time);
1129 }
static std::unique_ptr< HashtableRecycler > hash_table_cache_
#define CHECK(condition)
Definition: Logger.h:222

+ Here is the caller graph for this function:

void BaselineJoinHashTable::reify ( const HashType  preferred_layout)
protected

Definition at line 244 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.

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

+ 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::ThreadId  parent_thread_id 
)
protectedvirtual

Definition at line 656 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_, and to_string().

Referenced by reifyWithLayout().

661  {
662  DEBUG_TIMER_NEW_THREAD(parent_thread_id);
663  const auto effective_memory_level =
665  const auto err = initHashTableForDevice(columns_for_device.join_columns,
666  columns_for_device.join_column_types,
667  columns_for_device.join_buckets,
668  layout,
669  effective_memory_level,
670  entry_count,
671  emitted_keys_count,
672  device_id);
673  if (err) {
674  throw HashJoinFail(
675  std::string("Unrecognized error when initializing baseline hash table (") +
676  std::to_string(err) + std::string(")"));
677  }
678 }
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:376
std::string to_string(char const *&&v)
const std::vector< JoinColumnTypeInfo > join_column_types
Definition: HashJoin.h:101
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)
std::vector< JoinBucketInfo > join_buckets
Definition: HashJoin.h:103
const std::vector< JoinColumn > join_columns
Definition: HashJoin.h:100

+ 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 305 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_, table_id_to_node_map_, table_keys_, logger::thread_id(), HashJoin::translateCompositeStrDictProxies(), and UNREACHABLE.

Referenced by reify().

305  {
306  const auto& query_info = get_inner_query_info(getInnerTableId(), query_infos_).info;
307  if (query_info.fragments.empty()) {
308  return;
309  }
310 
311  const auto total_entries = 2 * query_info.getNumTuplesUpperBound();
312  if (total_entries > static_cast<size_t>(std::numeric_limits<int32_t>::max())) {
313  throw TooManyHashEntries();
314  }
315 
316  std::vector<std::unique_ptr<CudaAllocator>> dev_buff_owners;
317  std::vector<std::vector<Fragmenter_Namespace::FragmentInfo>> fragments_per_device;
318  std::vector<ColumnsForDevice> columns_per_device;
319  const auto shard_count = shardCount();
320  auto entries_per_device =
321  get_entries_per_device(total_entries, shard_count, device_count_, memory_level_);
322  auto data_mgr = executor_->getDataMgr();
323  // cached hash table lookup logic is similar with perfect join hash table
324  // first, prepare fragment lists per device
325  std::vector<ChunkKey> chunk_key_per_device;
326  for (int device_id = 0; device_id < device_count_; ++device_id) {
327  fragments_per_device.emplace_back(
328  shard_count
329  ? only_shards_for_device(query_info.fragments, device_id, device_count_)
330  : query_info.fragments);
332  dev_buff_owners.emplace_back(std::make_unique<CudaAllocator>(
333  data_mgr, device_id, getQueryEngineCudaStreamForDevice(device_id)));
334  }
335  const auto chunk_key = genChunkKey(fragments_per_device[device_id]);
336  chunk_key_per_device.emplace_back(std::move(chunk_key));
337  }
338 
339  // prepare per-device cache key
340  auto inner_outer_pairs = HashJoin::normalizeColumnPairs(
341  condition_.get(), *executor_->getCatalog(), executor_->getTemporaryTables());
342  const auto& inner_outer_cols = inner_outer_pairs.first;
343  const auto& col_pairs_string_op_infos = inner_outer_pairs.second;
344  auto hashtable_access_path_info =
346  col_pairs_string_op_infos,
347  condition_->get_optype(),
348  join_type_,
351  shard_count,
352  fragments_per_device,
353  executor_);
354  hashtable_cache_key_ = hashtable_access_path_info.hashed_query_plan_dag;
355  hashtable_cache_meta_info_ = hashtable_access_path_info.meta_info;
356  table_keys_ = hashtable_access_path_info.table_keys;
357 
358  // the actual chunks fetched per device can be different but they constitute the same
359  // table in the same db, so we can exploit this to create an alternative table key
360  if (table_keys_.empty()) {
362  chunk_key_per_device,
363  executor_->getCatalog()->getDatabaseId(),
364  getInnerTableId());
365  }
366  CHECK(!table_keys_.empty());
367 
368  if (HashtableRecycler::isInvalidHashTableCacheKey(hashtable_cache_key_) &&
369  getInnerTableId() > 0) {
370  // sometimes we cannot retrieve query plan dag, so try to recycler cache
371  // with the old-passioned cache key if we deal with hashtable of non-temporary table
372  for (int device_id = 0; device_id < device_count_; ++device_id) {
373  const auto num_tuples = std::accumulate(fragments_per_device[device_id].begin(),
374  fragments_per_device[device_id].end(),
375  size_t(0),
376  [](const auto& sum, const auto& fragment) {
377  return sum + fragment.getNumTuples();
378  });
379  AlternativeCacheKeyForBaselineHashJoin cache_key{inner_outer_pairs_,
381  num_tuples,
382  condition_->get_optype(),
383  join_type_,
384  chunk_key_per_device[device_id]};
385  hashtable_cache_key_[device_id] = getAlternativeCacheKey(cache_key);
386  }
387  }
388 
389  // register a mapping between cache key and input tables of the hash table
390  const auto invalid_cache_key =
391  HashtableRecycler::isInvalidHashTableCacheKey(hashtable_cache_key_);
392  if (!invalid_cache_key) {
393  if (!shard_count) {
394  hash_table_cache_->addQueryPlanDagForTableKeys(hashtable_cache_key_.front(),
395  table_keys_);
396  } else {
397  std::for_each(hashtable_cache_key_.cbegin(),
398  hashtable_cache_key_.cend(),
399  [this](QueryPlanHash key) {
400  hash_table_cache_->addQueryPlanDagForTableKeys(key, table_keys_);
401  });
402  }
403  }
404 
405  // now, let's try to check whether we have a cached hash table for this join qual
406  const auto effective_memory_level = getEffectiveMemoryLevel(inner_outer_pairs_);
407 
408  // todo (yoonmin) : support dictionary proxy cache for join including string op(s)
409  if (effective_memory_level == Data_Namespace::CPU_LEVEL) {
410  std::unique_lock<std::mutex> str_proxy_translation_lock(str_proxy_translation_mutex_);
411  if (str_proxy_translation_maps_.empty()) {
412  const auto composite_key_info = HashJoin::getCompositeKeyInfo(
415  composite_key_info, inner_outer_string_op_infos_pairs_, executor_);
417  }
418  }
419 
420  auto allow_hashtable_recycling =
425  bool has_invalid_cached_hash_table = false;
426  if (effective_memory_level == Data_Namespace::CPU_LEVEL &&
428  allow_hashtable_recycling, invalid_cache_key, join_type_)) {
429  // build a hash table on CPU, and we have a chance to recycle the cached one if
430  // available
431  for (int device_id = 0; device_id < device_count_; ++device_id) {
432  auto hash_table =
433  initHashTableOnCpuFromCache(hashtable_cache_key_[device_id],
436  if (hash_table) {
437  hash_tables_for_device_[device_id] = hash_table;
438  } else {
439  has_invalid_cached_hash_table = true;
440  break;
441  }
442  }
443 
444  if (has_invalid_cached_hash_table) {
445  hash_tables_for_device_.clear();
446  hash_tables_for_device_.resize(device_count_);
447  } else {
449 #ifdef HAVE_CUDA
450  auto data_mgr = executor_->getDataMgr();
451  for (int device_id = 0; device_id < device_count_; ++device_id) {
452  auto cpu_hash_table = std::dynamic_pointer_cast<BaselineHashTable>(
453  hash_tables_for_device_[device_id]);
454  copyCpuHashTableToGpu(cpu_hash_table, device_id, data_mgr);
455  }
456 #else
457  UNREACHABLE();
458 #endif
459  }
460  return;
461  }
462  }
463 
464  // we have no cached hash table for this qual
465  // so, start building the hash table by fetching columns for devices
466  for (int device_id = 0; device_id < device_count_; ++device_id) {
467  const auto columns_for_device =
468  fetchColumnsForDevice(fragments_per_device[device_id],
469  device_id,
471  ? dev_buff_owners[device_id].get()
472  : nullptr);
473  columns_per_device.push_back(columns_for_device);
474  }
475 
476  auto hashtable_layout_type = layout;
477  size_t emitted_keys_count = 0;
478  if (hashtable_layout_type == HashType::OneToMany) {
479  CHECK(!columns_per_device.front().join_columns.empty());
480  emitted_keys_count = columns_per_device.front().join_columns.front().num_elems;
481  size_t tuple_count;
482  std::tie(tuple_count, std::ignore) = approximateTupleCount(columns_per_device);
483  const auto entry_count = 2 * std::max(tuple_count, size_t(1));
484 
485  // reset entries per device with one to many info
486  entries_per_device =
487  get_entries_per_device(entry_count, shard_count, device_count_, memory_level_);
488  }
489  std::vector<std::future<void>> init_threads;
490  for (int device_id = 0; device_id < device_count_; ++device_id) {
491  const auto fragments =
492  shard_count
493  ? only_shards_for_device(query_info.fragments, device_id, device_count_)
494  : query_info.fragments;
495  init_threads.push_back(std::async(std::launch::async,
497  this,
498  columns_per_device[device_id],
499  hashtable_layout_type,
500  device_id,
501  entries_per_device,
502  emitted_keys_count,
503  logger::thread_id()));
504  }
505  for (auto& init_thread : init_threads) {
506  init_thread.wait();
507  }
508  for (auto& init_thread : init_threads) {
509  init_thread.get();
510  }
511 }
#define CHECK_EQ(x, y)
Definition: Logger.h:230
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:1026
static std::pair< std::vector< InnerOuter >, std::vector< InnerOuterStringOpInfos > > normalizeColumnPairs(const Analyzer::BinOper *condition, const Catalog_Namespace::Catalog &cat, const TemporaryTables *temporary_tables)
Definition: HashJoin.cpp:989
std::vector< std::shared_ptr< HashTable > > hash_tables_for_device_
Definition: HashJoin.h:351
#define UNREACHABLE()
Definition: Logger.h:266
HashTableBuildDagMap hashtable_build_dag_map_
const TableIdToNodeMap table_id_to_node_map_
std::unordered_set< size_t > table_keys_
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::ThreadId parent_thread_id)
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:503
HashtableCacheMetaInfo hashtable_cache_meta_info_
const InputTableInfo & get_inner_query_info(const int inner_table_id, const std::vector< InputTableInfo > &query_infos)
int getInnerTableId() const noexceptoverride
static std::unordered_set< size_t > getAlternativeTableKeys(const std::vector< ChunkKey > &chunk_keys, int db_id, int inner_table_id)
Definition: DataRecycler.h:154
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_
ThreadId thread_id()
Definition: Logger.cpp:820
#define CHECK(condition)
Definition: Logger.h:222
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)
const std::shared_ptr< Analyzer::BinOper > condition_
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 int table_id)
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:455

+ 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 680 of file BaselineJoinHashTable.cpp.

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

Referenced by reifyWithLayout().

680  {
682  return 0;
683  }
686 }
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 194 of file BaselineJoinHashTable.cpp.

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

196  {
197  auto buffer = getJoinHashBuffer(device_type, device_id);
198  auto hash_table = getHashTableForDevice(device_id);
199  CHECK(hash_table);
200  auto buffer_size = hash_table->getHashTableBufferSize(device_type);
201 #ifdef HAVE_CUDA
202  std::unique_ptr<int8_t[]> buffer_copy;
203  if (device_type == ExecutorDeviceType::GPU) {
204  buffer_copy = std::make_unique<int8_t[]>(buffer_size);
205  auto& data_mgr = catalog_->getDataMgr();
206  auto device_allocator = std::make_unique<CudaAllocator>(
207  &data_mgr, device_id, getQueryEngineCudaStreamForDevice(device_id));
208  device_allocator->copyFromDevice(buffer_copy.get(), buffer, buffer_size);
209  }
210  auto ptr1 = buffer_copy ? buffer_copy.get() : buffer;
211 #else
212  auto ptr1 = buffer;
213 #endif // HAVE_CUDA
214  auto ptr2 = ptr1 + offsetBufferOff();
215  auto ptr3 = ptr1 + countBufferOff();
216  auto ptr4 = ptr1 + payloadBufferOff();
217  const auto layout = hash_table->getLayout();
218  return HashTable::toSet(getKeyComponentCount() + (layout == HashType::OneToOne ? 1 : 0),
220  hash_table->getEntryCount(),
221  ptr1,
222  ptr2,
223  ptr3,
224  ptr4,
225  buffer_size);
226 }
size_t offsetBufferOff() const noexceptoverride
Data_Namespace::DataMgr & getDataMgr() const
Definition: Catalog.h:243
size_t payloadBufferOff() const noexceptoverride
int8_t * getJoinHashBuffer(const ExecutorDeviceType device_type, const int device_id) const
Definition: HashJoin.h:288
HashTable * getHashTableForDevice(const size_t device_id) const
Definition: HashJoin.h:269
const Catalog_Namespace::Catalog * catalog_
CUstream getQueryEngineCudaStreamForDevice(int device_num)
Definition: QueryEngine.cpp:7
#define CHECK(condition)
Definition: Logger.h:222
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 153 of file BaselineJoinHashTable.cpp.

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

Referenced by getAlternativeCacheKey().

155  {
156  auto buffer = getJoinHashBuffer(device_type, device_id);
157  CHECK_LT(static_cast<size_t>(device_id), hash_tables_for_device_.size());
158  auto hash_table = hash_tables_for_device_[device_id];
159  CHECK(hash_table);
160  auto buffer_size = hash_table->getHashTableBufferSize(device_type);
161 #ifdef HAVE_CUDA
162  std::unique_ptr<int8_t[]> buffer_copy;
163  if (device_type == ExecutorDeviceType::GPU) {
164  buffer_copy = std::make_unique<int8_t[]>(buffer_size);
165 
166  auto& data_mgr = catalog_->getDataMgr();
167  auto device_allocator = std::make_unique<CudaAllocator>(
168  &data_mgr, device_id, getQueryEngineCudaStreamForDevice(device_id));
169  device_allocator->copyFromDevice(buffer_copy.get(), buffer, buffer_size);
170  }
171  auto ptr1 = buffer_copy ? buffer_copy.get() : buffer;
172 #else
173  auto ptr1 = buffer;
174 #endif // HAVE_CUDA
175  auto ptr2 = ptr1 + offsetBufferOff();
176  auto ptr3 = ptr1 + countBufferOff();
177  auto ptr4 = ptr1 + payloadBufferOff();
178  CHECK(hash_table);
179  const auto layout = getHashType();
180  return HashTable::toString(
181  "keyed",
182  getHashTypeString(layout),
183  getKeyComponentCount() + (layout == HashType::OneToOne ? 1 : 0),
185  hash_table->getEntryCount(),
186  ptr1,
187  ptr2,
188  ptr3,
189  ptr4,
190  buffer_size,
191  raw);
192 }
size_t offsetBufferOff() const noexceptoverride
Data_Namespace::DataMgr & getDataMgr() const
Definition: Catalog.h:243
std::vector< std::shared_ptr< HashTable > > hash_tables_for_device_
Definition: HashJoin.h:351
size_t payloadBufferOff() const noexceptoverride
HashType getHashType() const noexceptoverride
int8_t * getJoinHashBuffer(const ExecutorDeviceType device_type, const int device_id) const
Definition: HashJoin.h:288
#define CHECK_LT(x, y)
Definition: Logger.h:232
static std::string getHashTypeString(HashType ht) noexcept
Definition: HashJoin.h:154
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
const Catalog_Namespace::Catalog * catalog_
CUstream getQueryEngineCudaStreamForDevice(int device_num)
Definition: QueryEngine.cpp:7
#define CHECK(condition)
Definition: Logger.h:222
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

const Catalog_Namespace::Catalog* BaselineJoinHashTable::catalog_
protected

Definition at line 261 of file BaselineJoinHashTable.h.

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

ColumnCacheMap& BaselineJoinHashTable::column_cache_
protected

Definition at line 254 of file BaselineJoinHashTable.h.

Referenced by fetchColumnsForDevice().

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

Definition at line 249 of file BaselineJoinHashTable.h.

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

std::mutex BaselineJoinHashTable::cpu_hash_table_buff_mutex_
protected

Definition at line 255 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 275 of file BaselineJoinHashTable.h.

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

HashTableBuildDagMap BaselineJoinHashTable::hashtable_build_dag_map_
protected

Definition at line 267 of file BaselineJoinHashTable.h.

Referenced by reifyWithLayout().

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

Definition at line 269 of file BaselineJoinHashTable.h.

Referenced by initHashTableForDevice(), and reifyWithLayout().

HashtableCacheMetaInfo BaselineJoinHashTable::hashtable_cache_meta_info_
protected

Definition at line 270 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 250 of file BaselineJoinHashTable.h.

Referenced by initHashTableForDevice(), and reifyWithLayout().

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

Definition at line 265 of file BaselineJoinHashTable.h.

Referenced by getHashType().

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

Definition at line 251 of file BaselineJoinHashTable.h.

Referenced by reifyWithLayout().

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

Definition at line 257 of file BaselineJoinHashTable.h.

Referenced by initHashTableForDevice(), and reifyWithLayout().

std::mutex BaselineJoinHashTable::str_proxy_translation_mutex_
protected

Definition at line 256 of file BaselineJoinHashTable.h.

Referenced by reifyWithLayout().

const TableIdToNodeMap BaselineJoinHashTable::table_id_to_node_map_
protected

Definition at line 272 of file BaselineJoinHashTable.h.

Referenced by initHashTableForDevice(), and reifyWithLayout().

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

Definition at line 271 of file BaselineJoinHashTable.h.

Referenced by reifyWithLayout().


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