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

#include <PerfectJoinHashTable.h>

+ Inheritance diagram for PerfectJoinHashTable:
+ Collaboration diagram for PerfectJoinHashTable:

Classes

struct  AlternativeCacheKeyForPerfectHashJoin
 

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 ~PerfectJoinHashTable ()
 
- 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
< PerfectJoinHashTable
getInstance (const std::shared_ptr< Analyzer::BinOper > qual_bin_oper, const std::vector< InputTableInfo > &query_infos, const Data_Namespace::MemoryLevel memory_level, const JoinType join_type, const HashType preferred_hash_type, const int device_count, ColumnCacheMap &column_cache, Executor *executor, const HashTableBuildDagMap &hashtable_build_dag_map, const TableIdToNodeMap &table_id_to_node_map)
 Make hash table from an in-flight SQL query's parse tree etc. More...
 
static HashtableRecyclergetHashTableCache ()
 
static HashingSchemeRecyclergetHashingSchemeCache ()
 
static void invalidateCache ()
 
static void markCachedItemAsDirty (size_t table_key)
 
- 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)
 

Private Member Functions

bool isOneToOneHashPossible (const std::vector< ColumnsForDevice > &columns_per_device) const
 
ColumnsForDevice fetchColumnsForDevice (const std::vector< Fragmenter_Namespace::FragmentInfo > &fragments, const int device_id, DeviceAllocator *dev_buff_owner, const Catalog_Namespace::Catalog &catalog)
 
void reifyForDevice (const ChunkKey &hash_table_key, const ColumnsForDevice &columns_for_device, const HashType layout, const int device_id, const logger::ThreadId parent_thread_id)
 
int initHashTableForDevice (const ChunkKey &chunk_key, const JoinColumn &join_column, const InnerOuter &cols, const HashType layout, const Data_Namespace::MemoryLevel effective_memory_level, const int device_id)
 
Data_Namespace::MemoryLevel getEffectiveMemoryLevel (const std::vector< InnerOuter > &inner_outer_pairs) const
 
 PerfectJoinHashTable (const std::shared_ptr< Analyzer::BinOper > qual_bin_oper, const Analyzer::ColumnVar *col_var, const std::vector< InputTableInfo > &query_infos, const Data_Namespace::MemoryLevel memory_level, const JoinType join_type, const HashType preferred_hash_type, const ExpressionRange &col_range, const ExpressionRange &rhs_source_col_range, ColumnCacheMap &column_cache, Executor *executor, const int device_count, const HashTableBuildDagMap &hashtable_build_dag_map, const TableIdToNodeMap &table_id_to_node_map, const InnerOuterStringOpInfos &inner_outer_string_op_infos={})
 
ChunkKey genChunkKey (const std::vector< Fragmenter_Namespace::FragmentInfo > &fragments, const Analyzer::Expr *outer_col, const Analyzer::ColumnVar *inner_col) const
 
void reify ()
 
std::shared_ptr< PerfectHashTableinitHashTableOnCpuFromCache (QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier)
 
void putHashTableOnCpuToCache (QueryPlanHash key, CacheItemType item_type, std::shared_ptr< PerfectHashTable > hashtable_ptr, DeviceIdentifier device_identifier, size_t hashtable_building_time)
 
const InputTableInfogetInnerQueryInfo (const Analyzer::ColumnVar *inner_col) const
 
size_t shardCount () const
 
llvm::Value * codegenHashTableLoad (const size_t table_idx)
 
std::vector< llvm::Value * > getHashJoinArgs (llvm::Value *hash_ptr, llvm::Value *key_lvs, const Analyzer::Expr *key_col, const int shard_count, const CompilationOptions &co)
 
bool isBitwiseEq () const override
 
size_t getComponentBufferSize () const noexceptoverride
 
HashTablegetHashTableForDevice (const size_t device_id) const
 
void copyCpuHashTableToGpu (std::shared_ptr< PerfectHashTable > &cpu_hash_table, const int device_id, Data_Namespace::DataMgr *data_mgr)
 

Static Private Member Functions

static QueryPlanHash getAlternativeCacheKey (AlternativeCacheKeyForPerfectHashJoin &info)
 

Private Attributes

std::vector< InnerOuterinner_outer_pairs_
 
std::shared_ptr
< Analyzer::BinOper
qual_bin_oper_
 
const JoinType join_type_
 
std::shared_ptr
< Analyzer::ColumnVar
col_var_
 
const std::vector
< InputTableInfo > & 
query_infos_
 
const Data_Namespace::MemoryLevel memory_level_
 
HashType hash_type_
 
std::mutex cpu_hash_table_buff_mutex_
 
std::mutex str_proxy_translation_mutex_
 
const
StringDictionaryProxy::IdMap
str_proxy_translation_map_ {nullptr}
 
ExpressionRange col_range_
 
ExpressionRange rhs_source_col_range_
 
Executorexecutor_
 
ColumnCacheMapcolumn_cache_
 
const int device_count_
 
bool needs_dict_translation_
 
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_
 
const InnerOuterStringOpInfos inner_outer_string_op_infos_
 

Static Private Attributes

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

Additional Inherited Members

- 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 inherited from HashJoin
std::vector< std::shared_ptr
< HashTable > > 
hash_tables_for_device_
 

Detailed Description

Definition at line 50 of file PerfectJoinHashTable.h.

Constructor & Destructor Documentation

virtual PerfectJoinHashTable::~PerfectJoinHashTable ( )
inlinevirtual

Definition at line 136 of file PerfectJoinHashTable.h.

136 {}
PerfectJoinHashTable::PerfectJoinHashTable ( const std::shared_ptr< Analyzer::BinOper qual_bin_oper,
const Analyzer::ColumnVar col_var,
const std::vector< InputTableInfo > &  query_infos,
const Data_Namespace::MemoryLevel  memory_level,
const JoinType  join_type,
const HashType  preferred_hash_type,
const ExpressionRange col_range,
const ExpressionRange rhs_source_col_range,
ColumnCacheMap column_cache,
Executor executor,
const int  device_count,
const HashTableBuildDagMap hashtable_build_dag_map,
const TableIdToNodeMap table_id_to_node_map,
const InnerOuterStringOpInfos inner_outer_string_op_infos = {} 
)
inlineprivate

Definition at line 167 of file PerfectJoinHashTable.h.

Referenced by getInstance().

180  {})
181  : qual_bin_oper_(qual_bin_oper)
182  , join_type_(join_type)
183  , col_var_(std::dynamic_pointer_cast<Analyzer::ColumnVar>(col_var->deep_copy()))
184  , query_infos_(query_infos)
185  , memory_level_(memory_level)
186  , hash_type_(preferred_hash_type)
187  , col_range_(col_range)
188  , rhs_source_col_range_(rhs_source_col_range)
189  , executor_(executor)
190  , column_cache_(column_cache)
191  , device_count_(device_count)
192  , needs_dict_translation_(false)
193  , hashtable_build_dag_map_(hashtable_build_dag_map)
194  , table_id_to_node_map_(table_id_to_node_map)
195  , inner_outer_string_op_infos_(inner_outer_string_op_infos) {
199  }
ExpressionRange rhs_source_col_range_
const Data_Namespace::MemoryLevel memory_level_
std::shared_ptr< Analyzer::BinOper > qual_bin_oper_
const TableIdToNodeMap table_id_to_node_map_
std::vector< std::shared_ptr< HashTable > > hash_tables_for_device_
Definition: HashJoin.h:351
HashTableBuildDagMap hashtable_build_dag_map_
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:66
#define CHECK_GT(x, y)
Definition: Logger.h:234
const std::vector< InputTableInfo > & query_infos_
ColumnCacheMap & column_cache_
std::shared_ptr< Analyzer::ColumnVar > col_var_
const InnerOuterStringOpInfos inner_outer_string_op_infos_
ExpressionRangeType getType() const
#define CHECK(condition)
Definition: Logger.h:222

+ Here is the caller graph for this function:

Member Function Documentation

llvm::Value * PerfectJoinHashTable::codegenHashTableLoad ( const size_t  table_idx)
private

Definition at line 935 of file PerfectJoinHashTable.cpp.

References AUTOMATIC_IR_METADATA, CHECK, HashJoin::codegenHashTableLoad(), executor_, and get_arg_by_name().

Referenced by codegenMatchingSet(), and codegenSlot().

935  {
936  AUTOMATIC_IR_METADATA(executor_->cgen_state_.get());
937  const auto hash_ptr = HashJoin::codegenHashTableLoad(table_idx, executor_);
938  if (hash_ptr->getType()->isIntegerTy(64)) {
939  return hash_ptr;
940  }
941  CHECK(hash_ptr->getType()->isPointerTy());
942  return executor_->cgen_state_->ir_builder_.CreatePtrToInt(
943  get_arg_by_name(executor_->cgen_state_->row_func_, "join_hash_tables"),
944  llvm::Type::getInt64Ty(executor_->cgen_state_->context_));
945 }
static llvm::Value * codegenHashTableLoad(const size_t table_idx, Executor *executor)
Definition: HashJoin.cpp:257
llvm::Value * get_arg_by_name(llvm::Function *func, const std::string &name)
Definition: Execute.h:166
#define AUTOMATIC_IR_METADATA(CGENSTATE)
#define CHECK(condition)
Definition: Logger.h:222

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Implements HashJoin.

Definition at line 1003 of file PerfectJoinHashTable.cpp.

References AUTOMATIC_IR_METADATA, CHECK, HashJoin::codegenColOrStringOper(), codegenHashTableLoad(), HashJoin::codegenMatchingSet(), executor_, anonymous_namespace{HashJoin.cpp}::get_cols(), get_max_rte_scan_table(), getComponentBufferSize(), getHashJoinArgs(), inner_outer_string_op_infos_, isBitwiseEq(), kDATE, qual_bin_oper_, self_join_not_covered_by_left_deep_tree(), and shardCount().

1004  {
1005  AUTOMATIC_IR_METADATA(executor_->cgen_state_.get());
1006  const auto cols =
1007  get_cols(
1008  qual_bin_oper_.get(), *executor_->getCatalog(), executor_->temporary_tables_)
1009  .first;
1010  auto key_col = cols.second;
1011  CHECK(key_col);
1012  auto val_col = cols.first;
1013  CHECK(val_col);
1014  auto pos_ptr = codegenHashTableLoad(index);
1015  CHECK(pos_ptr);
1016  const int shard_count = shardCount();
1017  const auto key_col_var = dynamic_cast<const Analyzer::ColumnVar*>(key_col);
1018  const auto val_col_var = dynamic_cast<const Analyzer::ColumnVar*>(val_col);
1019  if (key_col_var && val_col_var &&
1021  key_col_var,
1022  val_col_var,
1023  get_max_rte_scan_table(executor_->cgen_state_->scan_idx_to_hash_pos_))) {
1024  throw std::runtime_error(
1025  "Query execution fails because the query contains not supported self-join "
1026  "pattern. We suspect the query requires multiple left-deep join tree due to "
1027  "the "
1028  "join condition of the self-join and is not supported for now. Please consider "
1029  "rewriting table order in "
1030  "FROM clause.");
1031  }
1032  CodeGenerator code_generator(executor_);
1033 
1034  auto key_lv = HashJoin::codegenColOrStringOper(
1035  key_col, inner_outer_string_op_infos_.second, code_generator, co);
1036 
1037  auto hash_join_idx_args = getHashJoinArgs(pos_ptr, key_lv, key_col, shard_count, co);
1038  const int64_t sub_buff_size = getComponentBufferSize();
1039  const auto& key_col_ti = key_col->get_type_info();
1040 
1041  auto bucketize = (key_col_ti.get_type() == kDATE);
1042  return HashJoin::codegenMatchingSet(hash_join_idx_args,
1043  shard_count,
1044  !key_col_ti.get_notnull(),
1045  isBitwiseEq(),
1046  sub_buff_size,
1047  executor_,
1048  bucketize);
1049 }
llvm::Value * codegenHashTableLoad(const size_t table_idx)
virtual HashJoinMatchingSet codegenMatchingSet(const CompilationOptions &, const size_t)=0
bool self_join_not_covered_by_left_deep_tree(const Analyzer::ColumnVar *key_side, const Analyzer::ColumnVar *val_side, const int max_rte_covered)
size_t getComponentBufferSize() const noexceptoverride
std::shared_ptr< Analyzer::BinOper > qual_bin_oper_
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
const int get_max_rte_scan_table(std::unordered_map< int, llvm::Value * > &scan_idx_to_hash_pos)
#define AUTOMATIC_IR_METADATA(CGENSTATE)
std::vector< llvm::Value * > getHashJoinArgs(llvm::Value *hash_ptr, llvm::Value *key_lvs, const Analyzer::Expr *key_col, const int shard_count, const CompilationOptions &co)
Definition: sqltypes.h:67
const InnerOuterStringOpInfos inner_outer_string_op_infos_
#define CHECK(condition)
Definition: Logger.h:222
InnerOuter get_cols(const Analyzer::BinOper *qual_bin_oper, const Catalog_Namespace::Catalog &cat, const TemporaryTables *temporary_tables)
Definition: HashJoin.cpp:1035
bool isBitwiseEq() const override

+ Here is the call graph for this function:

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

Implements HashJoin.

Definition at line 1185 of file PerfectJoinHashTable.cpp.

References AUTOMATIC_IR_METADATA, CHECK, HashJoin::codegenColOrStringOper(), codegenHashTableLoad(), executor_, anonymous_namespace{HashJoin.cpp}::get_cols(), get_max_rte_scan_table(), Analyzer::Expr::get_type_info(), getHashJoinArgs(), getHashType(), isBitwiseEq(), kDATE, OneToOne, qual_bin_oper_, self_join_not_covered_by_left_deep_tree(), and shardCount().

1186  {
1187  AUTOMATIC_IR_METADATA(executor_->cgen_state_.get());
1188  using namespace std::string_literals;
1189 
1191  const auto cols_and_string_op_infos = get_cols(
1192  qual_bin_oper_.get(), *executor_->getCatalog(), executor_->temporary_tables_);
1193  const auto& cols = cols_and_string_op_infos.first;
1194  const auto& inner_outer_string_op_infos = cols_and_string_op_infos.second;
1195  auto key_col = cols.second;
1196  CHECK(key_col);
1197  auto val_col = cols.first;
1198  CHECK(val_col);
1199  CodeGenerator code_generator(executor_);
1200  const auto key_col_var = dynamic_cast<const Analyzer::ColumnVar*>(key_col);
1201  const auto val_col_var = dynamic_cast<const Analyzer::ColumnVar*>(val_col);
1202  if (key_col_var && val_col_var &&
1204  key_col_var,
1205  val_col_var,
1206  get_max_rte_scan_table(executor_->cgen_state_->scan_idx_to_hash_pos_))) {
1207  throw std::runtime_error(
1208  "Query execution failed because the query contains not supported self-join "
1209  "pattern. We suspect the query requires multiple left-deep join tree due to "
1210  "the join condition of the self-join and is not supported for now. Please "
1211  "consider chaning the table order in the FROM clause.");
1212  }
1213 
1214  auto key_lv = HashJoin::codegenColOrStringOper(
1215  key_col, inner_outer_string_op_infos.second, code_generator, co);
1216 
1217  // CHECK_EQ(size_t(1), key_lvs.size());
1218  auto hash_ptr = codegenHashTableLoad(index);
1219  CHECK(hash_ptr);
1220  const int shard_count = shardCount();
1221  const auto hash_join_idx_args =
1222  getHashJoinArgs(hash_ptr, key_lv, key_col, shard_count, co);
1223 
1224  const auto& key_col_ti = key_col->get_type_info();
1225  std::string fname((key_col_ti.get_type() == kDATE) ? "bucketized_hash_join_idx"s
1226  : "hash_join_idx"s);
1227 
1228  if (isBitwiseEq()) {
1229  fname += "_bitwise";
1230  }
1231  if (shard_count) {
1232  fname += "_sharded";
1233  }
1234 
1235  if (!isBitwiseEq() && !key_col_ti.get_notnull()) {
1236  fname += "_nullable";
1237  }
1238  return executor_->cgen_state_->emitCall(fname, hash_join_idx_args);
1239 }
llvm::Value * codegenHashTableLoad(const size_t table_idx)
bool self_join_not_covered_by_left_deep_tree(const Analyzer::ColumnVar *key_side, const Analyzer::ColumnVar *val_side, const int max_rte_covered)
std::shared_ptr< Analyzer::BinOper > qual_bin_oper_
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
const int get_max_rte_scan_table(std::unordered_map< int, llvm::Value * > &scan_idx_to_hash_pos)
HashType getHashType() const noexceptoverride
#define AUTOMATIC_IR_METADATA(CGENSTATE)
std::vector< llvm::Value * > getHashJoinArgs(llvm::Value *hash_ptr, llvm::Value *key_lvs, const Analyzer::Expr *key_col, const int shard_count, const CompilationOptions &co)
Definition: sqltypes.h:67
#define CHECK(condition)
Definition: Logger.h:222
InnerOuter get_cols(const Analyzer::BinOper *qual_bin_oper, const Catalog_Namespace::Catalog &cat, const TemporaryTables *temporary_tables)
Definition: HashJoin.cpp:1035
bool isBitwiseEq() const override

+ Here is the call graph for this function:

void PerfectJoinHashTable::copyCpuHashTableToGpu ( std::shared_ptr< PerfectHashTable > &  cpu_hash_table,
const int  device_id,
Data_Namespace::DataMgr data_mgr 
)
private

Definition at line 1080 of file PerfectJoinHashTable.cpp.

References PerfectJoinHashTableBuilder::allocateDeviceMemory(), CHECK, CHECK_EQ, CHECK_LE, CHECK_LT, CPU, cpu_hash_table_buff_mutex_, device_count_, executor_, PerfectJoinHashTableBuilder::getHashTable(), getQueryEngineCudaStreamForDevice(), GPU, Data_Namespace::GPU_LEVEL, HashJoin::hash_tables_for_device_, memory_level_, and shardCount().

Referenced by initHashTableForDevice(), and reify().

1083  {
1085  CHECK(data_mgr);
1086  CHECK(cpu_hash_table);
1087 
1088  std::lock_guard<std::mutex> cpu_hash_table_buff_lock(cpu_hash_table_buff_mutex_);
1089  PerfectJoinHashTableBuilder gpu_builder;
1090  gpu_builder.allocateDeviceMemory(cpu_hash_table->getColumnNumElems(),
1091  cpu_hash_table->getLayout(),
1092  cpu_hash_table->getHashEntryInfo(),
1093  shardCount(),
1094  device_id,
1095  device_count_,
1096  executor_);
1097 
1098  std::shared_ptr<PerfectHashTable> gpu_hash_table = gpu_builder.getHashTable();
1099  CHECK(gpu_hash_table);
1100  auto gpu_buffer_ptr = gpu_hash_table->getGpuBuffer();
1101  CHECK(gpu_buffer_ptr);
1102 
1103  CHECK_LE(cpu_hash_table->getHashTableBufferSize(ExecutorDeviceType::CPU),
1104  gpu_hash_table->getHashTableBufferSize(ExecutorDeviceType::GPU));
1105 
1106  auto device_allocator = std::make_unique<CudaAllocator>(
1107  data_mgr, device_id, getQueryEngineCudaStreamForDevice(device_id));
1108  device_allocator->copyToDevice(
1109  gpu_buffer_ptr,
1110  cpu_hash_table->getCpuBuffer(),
1111  cpu_hash_table->getHashTableBufferSize(ExecutorDeviceType::CPU));
1112  CHECK_LT(static_cast<size_t>(device_id), hash_tables_for_device_.size());
1113  hash_tables_for_device_[device_id] = std::move(gpu_hash_table);
1114 }
#define CHECK_EQ(x, y)
Definition: Logger.h:230
const Data_Namespace::MemoryLevel memory_level_
std::vector< std::shared_ptr< HashTable > > hash_tables_for_device_
Definition: HashJoin.h:351
std::unique_ptr< PerfectHashTable > getHashTable()
#define CHECK_LT(x, y)
Definition: Logger.h:232
void allocateDeviceMemory(const size_t num_column_elems, const HashType layout, HashEntryInfo hash_entry_info, const size_t shard_count, const int device_id, const int device_count, const Executor *executor)
#define CHECK_LE(x, y)
Definition: Logger.h:233
CUstream getQueryEngineCudaStreamForDevice(int device_num)
Definition: QueryEngine.cpp:7
#define CHECK(condition)
Definition: Logger.h:222

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t PerfectJoinHashTable::countBufferOff ( ) const
overridevirtualnoexcept

Implements HashJoin.

Definition at line 1055 of file PerfectJoinHashTable.cpp.

References getComponentBufferSize().

Referenced by toSet(), and toString().

1055  {
1056  return getComponentBufferSize();
1057 }
size_t getComponentBufferSize() const noexceptoverride

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ColumnsForDevice PerfectJoinHashTable::fetchColumnsForDevice ( const std::vector< Fragmenter_Namespace::FragmentInfo > &  fragments,
const int  device_id,
DeviceAllocator dev_buff_owner,
const Catalog_Namespace::Catalog catalog 
)
private

Definition at line 643 of file PerfectJoinHashTable.cpp.

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

Referenced by reify().

647  {
648  std::vector<JoinColumn> join_columns;
649  std::vector<std::shared_ptr<Chunk_NS::Chunk>> chunks_owner;
650  std::vector<JoinColumnTypeInfo> join_column_types;
651  std::vector<JoinBucketInfo> join_bucket_info;
652  std::vector<std::shared_ptr<void>> malloc_owner;
653  const auto effective_memory_level =
655  for (const auto& inner_outer_pair : inner_outer_pairs_) {
656  const auto inner_col = inner_outer_pair.first;
657  const auto inner_cd = get_column_descriptor_maybe(
658  inner_col->get_column_id(), inner_col->get_table_id(), catalog);
659  if (inner_cd && inner_cd->isVirtualCol) {
661  }
662  join_columns.emplace_back(fetchJoinColumn(inner_col,
663  fragments,
664  effective_memory_level,
665  device_id,
666  chunks_owner,
667  dev_buff_owner,
668  malloc_owner,
669  executor_,
670  &column_cache_));
671  const auto& ti = inner_col->get_type_info();
672  join_column_types.emplace_back(JoinColumnTypeInfo{static_cast<size_t>(ti.get_size()),
673  0,
674  0,
676  isBitwiseEq(),
677  0,
679  }
680  return {join_columns, join_column_types, chunks_owner, join_bucket_info, malloc_owner};
681 }
const Data_Namespace::MemoryLevel memory_level_
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)
const ColumnDescriptor * get_column_descriptor_maybe(const int col_id, const int table_id, const Catalog_Namespace::Catalog &cat)
Definition: Execute.h:220
std::vector< InnerOuter > inner_outer_pairs_
ColumnCacheMap & column_cache_
ColumnType get_join_column_type_kind(const SQLTypeInfo &ti)
int64_t inline_fixed_encoding_null_val(const SQL_TYPE_INFO &ti)
bool isBitwiseEq() const override

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ChunkKey PerfectJoinHashTable::genChunkKey ( const std::vector< Fragmenter_Namespace::FragmentInfo > &  fragments,
const Analyzer::Expr outer_col,
const Analyzer::ColumnVar inner_col 
) const
private

Definition at line 872 of file PerfectJoinHashTable.cpp.

References gpu_enabled::accumulate(), CHECK, CHECK_EQ, executor_, Analyzer::ColumnVar::get_column_id(), Analyzer::ColumnVar::get_table_id(), Analyzer::Expr::get_type_info(), getInnerQueryInfo(), InputTableInfo::info, and kENCODING_DICT.

Referenced by reify().

875  {
876  ChunkKey chunk_key{executor_->getCatalog()->getCurrentDB().dbId,
877  inner_col->get_table_id(),
878  inner_col->get_column_id()};
879  const auto& ti = inner_col->get_type_info();
880  std::for_each(fragments.cbegin(), fragments.cend(), [&chunk_key](const auto& fragment) {
881  // collect all frag ids to correctly generated cache key for a cached hash table
882  chunk_key.push_back(fragment.fragmentId);
883  });
884  if (ti.is_string()) {
885  CHECK_EQ(kENCODING_DICT, ti.get_compression());
886  const auto outer_col = dynamic_cast<const Analyzer::ColumnVar*>(outer_col_expr);
887  CHECK(outer_col);
888  const auto& outer_query_info = getInnerQueryInfo(outer_col).info;
889  size_t outer_elem_count =
890  std::accumulate(outer_query_info.fragments.begin(),
891  outer_query_info.fragments.end(),
892  size_t(0),
893  [&chunk_key](size_t sum, const auto& fragment) {
894  chunk_key.push_back(fragment.fragmentId);
895  return sum + fragment.getNumTuples();
896  });
897  chunk_key.push_back(outer_elem_count);
898  }
899 
900  return chunk_key;
901 }
int get_table_id() const
Definition: Analyzer.h:201
#define CHECK_EQ(x, y)
Definition: Logger.h:230
std::vector< int > ChunkKey
Definition: types.h:36
Fragmenter_Namespace::TableInfo info
Definition: InputMetadata.h:35
const InputTableInfo & getInnerQueryInfo(const Analyzer::ColumnVar *inner_col) const
DEVICE auto accumulate(ARGS &&...args)
Definition: gpu_enabled.h:42
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:82
#define CHECK(condition)
Definition: Logger.h:222
int get_column_id() const
Definition: Analyzer.h:202

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static QueryPlanHash PerfectJoinHashTable::getAlternativeCacheKey ( AlternativeCacheKeyForPerfectHashJoin info)
inlinestaticprivate

Definition at line 249 of file PerfectJoinHashTable.h.

References PerfectJoinHashTable::AlternativeCacheKeyForPerfectHashJoin::chunk_key, PerfectJoinHashTable::AlternativeCacheKeyForPerfectHashJoin::col_range, Analyzer::Expr::get_type_info(), PerfectJoinHashTable::AlternativeCacheKeyForPerfectHashJoin::inner_col, PerfectJoinHashTable::AlternativeCacheKeyForPerfectHashJoin::inner_outer_string_op_infos, SQLTypeInfo::is_string(), PerfectJoinHashTable::AlternativeCacheKeyForPerfectHashJoin::join_type, PerfectJoinHashTable::AlternativeCacheKeyForPerfectHashJoin::num_elements, PerfectJoinHashTable::AlternativeCacheKeyForPerfectHashJoin::optype, PerfectJoinHashTable::AlternativeCacheKeyForPerfectHashJoin::outer_col, toString(), ExpressionRange::toString(), and Analyzer::ColumnVar::toString().

Referenced by reify().

250  {
251  auto hash = boost::hash_value(::toString(info.chunk_key));
252  boost::hash_combine(hash, info.inner_col->toString());
253  if (info.inner_col->get_type_info().is_string()) {
254  boost::hash_combine(hash, info.outer_col->toString());
255  }
256  boost::hash_combine(hash, ::toString(info.inner_outer_string_op_infos));
257  boost::hash_combine(hash, info.col_range.toString());
258  boost::hash_combine(hash, info.num_elements);
259  boost::hash_combine(hash, info.optype);
260  boost::hash_combine(hash, info.join_type);
261  return hash;
262  }
std::string toString(const ExecutorDeviceType device_type, const int device_id=0, bool raw=false) const override

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t PerfectJoinHashTable::getComponentBufferSize ( ) const
overrideprivatevirtualnoexcept

Implements HashJoin.

Definition at line 1063 of file PerfectJoinHashTable.cpp.

References HashJoin::hash_tables_for_device_, and OneToMany.

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

1063  {
1064  if (hash_tables_for_device_.empty()) {
1065  return 0;
1066  }
1067  auto hash_table = hash_tables_for_device_.front();
1068  if (hash_table && hash_table->getLayout() == HashType::OneToMany) {
1069  return hash_table->getEntryCount() * sizeof(int32_t);
1070  } else {
1071  return 0;
1072  }
1073 }
std::vector< std::shared_ptr< HashTable > > hash_tables_for_device_
Definition: HashJoin.h:351

+ Here is the caller graph for this function:

int PerfectJoinHashTable::getDeviceCount ( ) const
inlineoverridevirtualnoexcept

Implements HashJoin.

Definition at line 91 of file PerfectJoinHashTable.h.

References device_count_.

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

Definition at line 633 of file PerfectJoinHashTable.cpp.

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

Referenced by reify().

634  {
636  inner_outer_pairs.front(), inner_outer_string_op_infos_, executor_)) {
639  }
640  return memory_level_;
641 }
const Data_Namespace::MemoryLevel memory_level_
bool needs_dictionary_translation(const std::vector< InnerOuter > &inner_outer_pairs, const std::vector< InnerOuterStringOpInfos > &inner_outer_string_op_infos_pairs, const Executor *executor)
const InnerOuterStringOpInfos inner_outer_string_op_infos_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static HashingSchemeRecycler* PerfectJoinHashTable::getHashingSchemeCache ( )
inlinestatic

Definition at line 105 of file PerfectJoinHashTable.h.

References CHECK, and hash_table_layout_cache_.

105  {
107  return hash_table_layout_cache_.get();
108  }
static std::unique_ptr< HashingSchemeRecycler > hash_table_layout_cache_
#define CHECK(condition)
Definition: Logger.h:222
std::vector< llvm::Value * > PerfectJoinHashTable::getHashJoinArgs ( llvm::Value *  hash_ptr,
llvm::Value *  key_lvs,
const Analyzer::Expr key_col,
const int  shard_count,
const CompilationOptions co 
)
private

Definition at line 947 of file PerfectJoinHashTable.cpp.

References AUTOMATIC_IR_METADATA, CHECK, col_range_, device_count_, executor_, anonymous_namespace{PerfectJoinHashTable.cpp}::get_bucketized_hash_entry_info(), anonymous_namespace{PerfectJoinHashTable.cpp}::get_hash_entry_count(), get_logical_type_info(), SQLTypeInfo::get_type(), Analyzer::Expr::get_type_info(), ExpressionRange::getIntMax(), ExpressionRange::getIntMin(), inline_fixed_encoding_null_val(), isBitwiseEq(), and kDATE.

Referenced by codegenMatchingSet(), and codegenSlot().

952  {
953  AUTOMATIC_IR_METADATA(executor_->cgen_state_.get());
954  CodeGenerator code_generator(executor_);
955  CHECK(key_lv);
956  // Todo(todd): Fix below, it's gross (but didn't want to redo the plumbing yet)
957  // const auto key_lv = key_lvs.size() && key_lvs[0]
958  // ? key_lvs[0]
959  // : code_generator.codegen(key_col, true, co)[0];
960  auto const& key_col_ti = key_col->get_type_info();
961  auto hash_entry_info =
963 
964  std::vector<llvm::Value*> hash_join_idx_args{
965  hash_ptr,
966  executor_->cgen_state_->castToTypeIn(key_lv, 64),
967  executor_->cgen_state_->llInt(col_range_.getIntMin()),
968  executor_->cgen_state_->llInt(col_range_.getIntMax())};
969  if (shard_count) {
970  const auto expected_hash_entry_count =
972  const auto entry_count_per_shard =
973  (expected_hash_entry_count + shard_count - 1) / shard_count;
974  hash_join_idx_args.push_back(
975  executor_->cgen_state_->llInt<uint32_t>(entry_count_per_shard));
976  hash_join_idx_args.push_back(executor_->cgen_state_->llInt<uint32_t>(shard_count));
977  hash_join_idx_args.push_back(executor_->cgen_state_->llInt<uint32_t>(device_count_));
978  }
979  auto key_col_logical_ti = get_logical_type_info(key_col->get_type_info());
980  if (!key_col_logical_ti.get_notnull() || isBitwiseEq()) {
981  hash_join_idx_args.push_back(executor_->cgen_state_->llInt(
982  inline_fixed_encoding_null_val(key_col_logical_ti)));
983  }
984  auto special_date_bucketization_case = key_col_ti.get_type() == kDATE;
985  if (isBitwiseEq()) {
986  if (special_date_bucketization_case) {
987  hash_join_idx_args.push_back(executor_->cgen_state_->llInt(
988  col_range_.getIntMax() / hash_entry_info.bucket_normalization + 1));
989  } else {
990  hash_join_idx_args.push_back(
991  executor_->cgen_state_->llInt(col_range_.getIntMax() + 1));
992  }
993  }
994 
995  if (special_date_bucketization_case) {
996  hash_join_idx_args.emplace_back(
997  executor_->cgen_state_->llInt(hash_entry_info.bucket_normalization));
998  }
999 
1000  return hash_join_idx_args;
1001 }
int64_t getIntMin() const
size_t get_hash_entry_count(const ExpressionRange &col_range, const bool is_bw_eq)
HashEntryInfo get_bucketized_hash_entry_info(SQLTypeInfo const &context_ti, ExpressionRange const &col_range, bool const is_bw_eq)
SQLTypeInfo get_logical_type_info(const SQLTypeInfo &type_info)
Definition: sqltypes.h:1221
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:404
#define AUTOMATIC_IR_METADATA(CGENSTATE)
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:82
Definition: sqltypes.h:67
int64_t getIntMax() const
#define CHECK(condition)
Definition: Logger.h:222
int64_t inline_fixed_encoding_null_val(const SQL_TYPE_INFO &ti)
bool isBitwiseEq() const override

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string PerfectJoinHashTable::getHashJoinType ( ) const
inlinefinalvirtual

Implements HashJoin.

Definition at line 99 of file PerfectJoinHashTable.h.

99 { return "Perfect"; }
static HashtableRecycler* PerfectJoinHashTable::getHashTableCache ( )
inlinestatic

Definition at line 101 of file PerfectJoinHashTable.h.

References CHECK, and hash_table_cache_.

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

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

+ Here is the caller graph for this function:

HashTable * PerfectJoinHashTable::getHashTableForDevice ( const size_t  device_id) const
private

Definition at line 1075 of file PerfectJoinHashTable.cpp.

References CHECK_LT, and HashJoin::hash_tables_for_device_.

Referenced by toSet(), and toString().

1075  {
1076  CHECK_LT(device_id, hash_tables_for_device_.size());
1077  return hash_tables_for_device_[device_id].get();
1078 }
std::vector< std::shared_ptr< HashTable > > hash_tables_for_device_
Definition: HashJoin.h:351
#define CHECK_LT(x, y)
Definition: Logger.h:232

+ Here is the caller graph for this function:

HashType PerfectJoinHashTable::getHashType ( ) const
inlineoverridevirtualnoexcept

Implements HashJoin.

Definition at line 85 of file PerfectJoinHashTable.h.

References hash_type_.

Referenced by codegenSlot().

85 { return hash_type_; }

+ Here is the caller graph for this function:

const InputTableInfo & PerfectJoinHashTable::getInnerQueryInfo ( const Analyzer::ColumnVar inner_col) const
private

Definition at line 1241 of file PerfectJoinHashTable.cpp.

References get_inner_query_info(), Analyzer::ColumnVar::get_table_id(), and query_infos_.

Referenced by genChunkKey(), and reify().

1242  {
1243  return get_inner_query_info(inner_col->get_table_id(), query_infos_);
1244 }
int get_table_id() const
Definition: Analyzer.h:201
const InputTableInfo & get_inner_query_info(const int inner_table_id, const std::vector< InputTableInfo > &query_infos)
const std::vector< InputTableInfo > & query_infos_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int PerfectJoinHashTable::getInnerTableId ( ) const
inlineoverridevirtualnoexcept

Implements HashJoin.

Definition at line 77 of file PerfectJoinHashTable.h.

References col_var_.

Referenced by reify().

77  {
78  return col_var_.get()->get_table_id();
79  };
std::shared_ptr< Analyzer::ColumnVar > col_var_

+ Here is the caller graph for this function:

int PerfectJoinHashTable::getInnerTableRteIdx ( ) const
inlineoverridevirtualnoexcept

Implements HashJoin.

Definition at line 81 of file PerfectJoinHashTable.h.

References col_var_.

81  {
82  return col_var_.get()->get_rte_idx();
83  };
std::shared_ptr< Analyzer::ColumnVar > col_var_
std::shared_ptr< PerfectJoinHashTable > PerfectJoinHashTable::getInstance ( const std::shared_ptr< Analyzer::BinOper qual_bin_oper,
const std::vector< InputTableInfo > &  query_infos,
const Data_Namespace::MemoryLevel  memory_level,
const JoinType  join_type,
const HashType  preferred_hash_type,
const int  device_count,
ColumnCacheMap column_cache,
Executor executor,
const HashTableBuildDagMap hashtable_build_dag_map,
const TableIdToNodeMap table_id_to_node_map 
)
static

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

Definition at line 147 of file PerfectJoinHashTable.cpp.

References CHECK, CHECK_EQ, anonymous_namespace{PerfectJoinHashTable.cpp}::get_bucketized_hash_entry_info(), anonymous_namespace{HashJoin.cpp}::get_cols(), getExpressionRange(), HashJoin::getHashTypeString(), HashEntryInfo::getNormalizedHashEntryCount(), Data_Namespace::GPU_LEVEL, Invalid, IS_EQUIVALENCE, kBW_EQ, ExpressionRange::makeIntRange(), PerfectJoinHashTable(), VLOG, and VLOGGING.

Referenced by HashJoin::getInstance().

157  {
158  CHECK(IS_EQUIVALENCE(qual_bin_oper->get_optype()));
159  const auto cols_and_string_op_infos =
160  get_cols(qual_bin_oper.get(), *executor->getCatalog(), executor->temporary_tables_);
161  const auto& cols = cols_and_string_op_infos.first;
162  const auto& inner_outer_string_op_infos = cols_and_string_op_infos.second;
163  const auto inner_col = cols.first;
164  CHECK(inner_col);
165  const auto& ti = inner_col->get_type_info();
166  auto col_range =
167  getExpressionRange(ti.is_string() ? cols.second : inner_col, query_infos, executor);
168  if (col_range.getType() == ExpressionRangeType::Invalid) {
169  throw HashJoinFail(
170  "Could not compute range for the expressions involved in the equijoin");
171  }
172  const auto rhs_source_col_range =
173  ti.is_string() ? getExpressionRange(inner_col, query_infos, executor) : col_range;
174  if (ti.is_string()) {
175  // The nullable info must be the same as the source column.
176  if (rhs_source_col_range.getType() == ExpressionRangeType::Invalid) {
177  throw HashJoinFail(
178  "Could not compute range for the expressions involved in the equijoin");
179  }
180  if (rhs_source_col_range.getIntMin() > rhs_source_col_range.getIntMax()) {
181  // If the inner column expression range is empty, use the inner col range
182  CHECK_EQ(rhs_source_col_range.getIntMin(), int64_t(0));
183  CHECK_EQ(rhs_source_col_range.getIntMax(), int64_t(-1));
184  col_range = rhs_source_col_range;
185  } else {
186  col_range = ExpressionRange::makeIntRange(
187  std::min(rhs_source_col_range.getIntMin(), col_range.getIntMin()),
188  std::max(rhs_source_col_range.getIntMax(), col_range.getIntMax()),
189  0,
190  rhs_source_col_range.hasNulls());
191  }
192  }
193 
194  // We can't allocate more than 2GB contiguous memory on GPU and each entry is 4 bytes.
195  const auto max_hash_entry_count =
197  ? static_cast<size_t>(std::numeric_limits<int32_t>::max() / sizeof(int32_t))
198  : static_cast<size_t>(std::numeric_limits<int32_t>::max());
199 
200  auto bucketized_entry_count_info = get_bucketized_hash_entry_info(
201  ti, col_range, qual_bin_oper->get_optype() == kBW_EQ);
202  auto bucketized_entry_count = bucketized_entry_count_info.getNormalizedHashEntryCount();
203 
204  if (bucketized_entry_count > max_hash_entry_count) {
205  throw TooManyHashEntries();
206  }
207 
208  if (qual_bin_oper->get_optype() == kBW_EQ &&
209  col_range.getIntMax() >= std::numeric_limits<int64_t>::max()) {
210  throw HashJoinFail("Cannot translate null value for kBW_EQ");
211  }
212  decltype(std::chrono::steady_clock::now()) ts1, ts2;
213  if (VLOGGING(1)) {
214  ts1 = std::chrono::steady_clock::now();
215  }
216 
217  auto join_hash_table = std::shared_ptr<PerfectJoinHashTable>(
218  new PerfectJoinHashTable(qual_bin_oper,
219  inner_col,
220  query_infos,
221  memory_level,
222  join_type,
223  preferred_hash_type,
224  col_range,
225  rhs_source_col_range,
226  column_cache,
227  executor,
228  device_count,
229  hashtable_build_dag_map,
230  table_id_to_node_map,
231  inner_outer_string_op_infos));
232  try {
233  join_hash_table->reify();
234  } catch (const TableMustBeReplicated& e) {
235  // Throw a runtime error to abort the query
236  join_hash_table->freeHashBufferMemory();
237  throw std::runtime_error(e.what());
238  } catch (const HashJoinFail& e) {
239  // HashJoinFail exceptions log an error and trigger a retry with a join loop (if
240  // possible)
241  join_hash_table->freeHashBufferMemory();
242  throw HashJoinFail(std::string("Could not build a 1-to-1 correspondence for columns "
243  "involved in equijoin | ") +
244  e.what());
245  } catch (const ColumnarConversionNotSupported& e) {
246  throw HashJoinFail(std::string("Could not build hash tables for equijoin | ") +
247  e.what());
248  } catch (const OutOfMemory& e) {
249  throw HashJoinFail(
250  std::string("Ran out of memory while building hash tables for equijoin | ") +
251  e.what());
252  } catch (const std::exception& e) {
253  throw std::runtime_error(
254  std::string("Fatal error while attempting to build hash tables for join: ") +
255  e.what());
256  }
257  if (VLOGGING(1)) {
258  ts2 = std::chrono::steady_clock::now();
259  VLOG(1) << "Built perfect hash table "
260  << getHashTypeString(join_hash_table->getHashType()) << " in "
261  << std::chrono::duration_cast<std::chrono::milliseconds>(ts2 - ts1).count()
262  << " ms";
263  }
264  return join_hash_table;
265 }
#define CHECK_EQ(x, y)
Definition: Logger.h:230
HashEntryInfo get_bucketized_hash_entry_info(SQLTypeInfo const &context_ti, ExpressionRange const &col_range, bool const is_bw_eq)
#define IS_EQUIVALENCE(X)
Definition: sqldefs.h:68
ExpressionRange getExpressionRange(const Analyzer::BinOper *expr, const std::vector< InputTableInfo > &query_infos, const Executor *, boost::optional< std::list< std::shared_ptr< Analyzer::Expr >>> simple_quals)
static ExpressionRange makeIntRange(const int64_t int_min, const int64_t int_max, const int64_t bucket, const bool has_nulls)
PerfectJoinHashTable(const std::shared_ptr< Analyzer::BinOper > qual_bin_oper, const Analyzer::ColumnVar *col_var, const std::vector< InputTableInfo > &query_infos, const Data_Namespace::MemoryLevel memory_level, const JoinType join_type, const HashType preferred_hash_type, const ExpressionRange &col_range, const ExpressionRange &rhs_source_col_range, ColumnCacheMap &column_cache, Executor *executor, const int device_count, const HashTableBuildDagMap &hashtable_build_dag_map, const TableIdToNodeMap &table_id_to_node_map, const InnerOuterStringOpInfos &inner_outer_string_op_infos={})
#define VLOGGING(n)
Definition: Logger.h:220
static std::string getHashTypeString(HashType ht) noexcept
Definition: HashJoin.h:154
size_t getNormalizedHashEntryCount() const
#define CHECK(condition)
Definition: Logger.h:222
Definition: sqldefs.h:30
InnerOuter get_cols(const Analyzer::BinOper *qual_bin_oper, const Catalog_Namespace::Catalog &cat, const TemporaryTables *temporary_tables)
Definition: HashJoin.cpp:1035
#define VLOG(n)
Definition: Logger.h:316

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Implements HashJoin.

Definition at line 87 of file PerfectJoinHashTable.h.

References memory_level_.

87  {
88  return memory_level_;
89  };
const Data_Namespace::MemoryLevel memory_level_
int PerfectJoinHashTable::initHashTableForDevice ( const ChunkKey chunk_key,
const JoinColumn join_column,
const InnerOuter cols,
const HashType  layout,
const Data_Namespace::MemoryLevel  effective_memory_level,
const int  device_id 
)
private

Definition at line 720 of file PerfectJoinHashTable.cpp.

References PerfectJoinHashTableBuilder::allocateDeviceMemory(), CHECK, CHECK_EQ, CHECK_LT, col_range_, copyCpuHashTableToGpu(), DataRecyclerUtil::CPU_DEVICE_IDENTIFIER, cpu_hash_table_buff_mutex_, Data_Namespace::CPU_LEVEL, DEBUG_TIMER, device_count_, executor_, anonymous_namespace{PerfectJoinHashTable.cpp}::get_bucketized_hash_entry_info(), PerfectJoinHashTableBuilder::getHashTable(), Data_Namespace::GPU_LEVEL, hash_table_layout_cache_, HashJoin::hash_tables_for_device_, hash_type_, hashtable_cache_key_, HT_HASHING_SCHEME, PerfectJoinHashTableBuilder::initOneToManyHashTableOnCpu(), PerfectJoinHashTableBuilder::initOneToOneHashTableOnCpu(), inner_outer_string_op_infos_, isBitwiseEq(), HashtableRecycler::isSafeToCacheHashtable(), join_type_, memory_level_, needs_dict_translation_, JoinColumn::num_elems, OneToOne, PERFECT_HT, putHashTableOnCpuToCache(), shardCount(), str_proxy_translation_map_, table_id_to_node_map_, and UNREACHABLE.

Referenced by reifyForDevice().

726  {
727  auto timer = DEBUG_TIMER(__func__);
728  const auto inner_col = cols.first;
729  CHECK(inner_col);
730 
731  auto hash_entry_info = get_bucketized_hash_entry_info(
732  inner_col->get_type_info(), col_range_, isBitwiseEq());
733  if (!hash_entry_info && layout == HashType::OneToOne) {
734  // TODO: what is this for?
735  return 0;
736  }
737 
738 #ifndef HAVE_CUDA
739  CHECK_EQ(Data_Namespace::CPU_LEVEL, effective_memory_level);
740 #endif
741  int err{0};
742  const int32_t hash_join_invalid_val{-1};
743  auto hashtable_layout = layout;
744  auto allow_hashtable_recycling =
748  inner_col->get_table_id());
749  if (allow_hashtable_recycling) {
750  auto cached_hashtable_layout_type = hash_table_layout_cache_->getItemFromCache(
751  hashtable_cache_key_[device_id],
754  {});
755  if (cached_hashtable_layout_type) {
756  hash_type_ = *cached_hashtable_layout_type;
757  hashtable_layout = hash_type_;
758  }
759  }
760  if (effective_memory_level == Data_Namespace::CPU_LEVEL) {
761  CHECK(!chunk_key.empty());
762  std::shared_ptr<PerfectHashTable> hash_table{nullptr};
763  decltype(std::chrono::steady_clock::now()) ts1, ts2;
764  ts1 = std::chrono::steady_clock::now();
765  {
766  std::lock_guard<std::mutex> cpu_hash_table_buff_lock(cpu_hash_table_buff_mutex_);
768  if (hashtable_layout == HashType::OneToOne) {
769  builder.initOneToOneHashTableOnCpu(join_column,
770  col_range_,
771  isBitwiseEq(),
772  cols,
774  join_type_,
775  hashtable_layout,
776  hash_entry_info,
777  hash_join_invalid_val,
778  executor_);
779  hash_table = builder.getHashTable();
780  } else {
781  builder.initOneToManyHashTableOnCpu(join_column,
782  col_range_,
783  isBitwiseEq(),
784  cols,
786  hash_entry_info,
787  hash_join_invalid_val,
788  executor_);
789  hash_table = builder.getHashTable();
790  }
791  ts2 = std::chrono::steady_clock::now();
792  auto build_time =
793  std::chrono::duration_cast<std::chrono::milliseconds>(ts2 - ts1).count();
794  hash_table->setHashEntryInfo(hash_entry_info);
795  hash_table->setColumnNumElems(join_column.num_elems);
796  if (allow_hashtable_recycling && hash_table) {
797  // add ht-related items to cache iff we have a valid hashtable
798  hash_table_layout_cache_->putItemToCache(hashtable_cache_key_[device_id],
799  hashtable_layout,
802  0,
803  0,
804  {});
807  hash_table,
809  build_time);
810  }
811  }
812  // Transfer the hash table on the GPU if we've only built it on CPU
813  // but the query runs on GPU (join on dictionary encoded columns).
815 #ifdef HAVE_CUDA
816  const auto& ti = inner_col->get_type_info();
817  CHECK(ti.is_string());
818  auto data_mgr = executor_->getDataMgr();
819  copyCpuHashTableToGpu(hash_table, device_id, data_mgr);
820 #else
821  UNREACHABLE();
822 #endif
823  } else {
824  CHECK(hash_table);
825  CHECK_LT(static_cast<size_t>(device_id), hash_tables_for_device_.size());
826  hash_tables_for_device_[device_id] = hash_table;
827  }
828  } else {
829 #ifdef HAVE_CUDA
831  CHECK_EQ(Data_Namespace::GPU_LEVEL, effective_memory_level);
832  builder.allocateDeviceMemory(join_column,
833  hashtable_layout,
834  hash_entry_info,
835  shardCount(),
836  device_id,
838  executor_);
839  builder.initHashTableOnGpu(chunk_key,
840  join_column,
841  col_range_,
842  isBitwiseEq(),
843  cols,
844  join_type_,
845  hashtable_layout,
846  hash_entry_info,
847  shardCount(),
848  hash_join_invalid_val,
849  device_id,
851  executor_);
852  CHECK_LT(static_cast<size_t>(device_id), hash_tables_for_device_.size());
853  hash_tables_for_device_[device_id] = builder.getHashTable();
854  if (!err && allow_hashtable_recycling && hash_tables_for_device_[device_id]) {
855  // add layout to cache iff we have a valid hashtable
856  hash_table_layout_cache_->putItemToCache(
857  hashtable_cache_key_[device_id],
858  hash_tables_for_device_[device_id]->getLayout(),
861  0,
862  0,
863  {});
864  }
865 #else
866  UNREACHABLE();
867 #endif
868  }
869  return err;
870 }
#define CHECK_EQ(x, y)
Definition: Logger.h:230
HashEntryInfo get_bucketized_hash_entry_info(SQLTypeInfo const &context_ti, ExpressionRange const &col_range, bool const is_bw_eq)
const Data_Namespace::MemoryLevel memory_level_
size_t num_elems
const TableIdToNodeMap table_id_to_node_map_
std::vector< std::shared_ptr< HashTable > > hash_tables_for_device_
Definition: HashJoin.h:351
#define UNREACHABLE()
Definition: Logger.h:266
void copyCpuHashTableToGpu(std::shared_ptr< PerfectHashTable > &cpu_hash_table, const int device_id, Data_Namespace::DataMgr *data_mgr)
void initOneToManyHashTableOnCpu(const JoinColumn &join_column, const ExpressionRange &col_range, const bool is_bitwise_eq, const std::pair< const Analyzer::ColumnVar *, const Analyzer::Expr * > &cols, const StringDictionaryProxy::IdMap *str_proxy_translation_map, const HashEntryInfo hash_entry_info, const int32_t hash_join_invalid_val, const Executor *executor)
void initOneToOneHashTableOnCpu(const JoinColumn &join_column, const ExpressionRange &col_range, const bool is_bitwise_eq, const InnerOuter &cols, const StringDictionaryProxy::IdMap *str_proxy_translation_map, const JoinType join_type, const HashType hash_type, const HashEntryInfo hash_entry_info, const int32_t hash_join_invalid_val, const Executor *executor)
static std::unique_ptr< HashingSchemeRecycler > hash_table_layout_cache_
std::unique_ptr< PerfectHashTable > getHashTable()
#define CHECK_LT(x, y)
Definition: Logger.h:232
void allocateDeviceMemory(const size_t num_column_elems, const HashType layout, HashEntryInfo hash_entry_info, const size_t shard_count, const int device_id, const int device_count, const Executor *executor)
void putHashTableOnCpuToCache(QueryPlanHash key, CacheItemType item_type, std::shared_ptr< PerfectHashTable > hashtable_ptr, DeviceIdentifier device_identifier, size_t hashtable_building_time)
const InnerOuterStringOpInfos inner_outer_string_op_infos_
#define CHECK(condition)
Definition: Logger.h:222
#define DEBUG_TIMER(name)
Definition: Logger.h:371
std::vector< QueryPlanHash > hashtable_cache_key_
static constexpr DeviceIdentifier CPU_DEVICE_IDENTIFIER
Definition: DataRecycler.h:136
const StringDictionaryProxy::IdMap * str_proxy_translation_map_
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)
bool isBitwiseEq() const override

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::shared_ptr< PerfectHashTable > PerfectJoinHashTable::initHashTableOnCpuFromCache ( QueryPlanHash  key,
CacheItemType  item_type,
DeviceIdentifier  device_identifier 
)
private

Definition at line 903 of file PerfectJoinHashTable.cpp.

References CHECK, DEBUG_TIMER, hash_table_cache_, and VLOG.

Referenced by reify().

906  {
908  auto timer = DEBUG_TIMER(__func__);
909  VLOG(1) << "Checking CPU hash table cache.";
910  auto hashtable_ptr =
911  hash_table_cache_->getItemFromCache(key, item_type, device_identifier);
912  if (hashtable_ptr) {
913  return std::dynamic_pointer_cast<PerfectHashTable>(hashtable_ptr);
914  }
915  return nullptr;
916 }
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 PerfectJoinHashTable::invalidateCache ( )
inlinestatic

Definition at line 110 of file PerfectJoinHashTable.h.

References CHECK, hash_table_cache_, and hash_table_layout_cache_.

110  {
112  hash_table_layout_cache_->clearCache();
113 
115  hash_table_cache_->clearCache();
116  }
static std::unique_ptr< HashtableRecycler > hash_table_cache_
static std::unique_ptr< HashingSchemeRecycler > hash_table_layout_cache_
#define CHECK(condition)
Definition: Logger.h:222
bool PerfectJoinHashTable::isBitwiseEq ( ) const
overrideprivatevirtual

Implements HashJoin.

Definition at line 1281 of file PerfectJoinHashTable.cpp.

References kBW_EQ, and qual_bin_oper_.

Referenced by codegenMatchingSet(), codegenSlot(), fetchColumnsForDevice(), getHashJoinArgs(), and initHashTableForDevice().

1281  {
1282  return qual_bin_oper_->get_optype() == kBW_EQ;
1283 }
std::shared_ptr< Analyzer::BinOper > qual_bin_oper_
Definition: sqldefs.h:30

+ Here is the caller graph for this function:

bool PerfectJoinHashTable::isOneToOneHashPossible ( const std::vector< ColumnsForDevice > &  columns_per_device) const
private

Definition at line 330 of file PerfectJoinHashTable.cpp.

References CHECK, anonymous_namespace{PerfectJoinHashTable.cpp}::get_bucketized_hash_entry_info(), ExpressionRange::hasNulls(), inner_outer_pairs_, kBW_EQ, qual_bin_oper_, rhs_source_col_range_, and VLOG.

Referenced by reify().

331  {
332  CHECK(!inner_outer_pairs_.empty());
333  const auto& rhs_col_ti = inner_outer_pairs_.front().first->get_type_info();
334  const auto max_unique_hash_input_entries =
336  rhs_col_ti, rhs_source_col_range_, qual_bin_oper_->get_optype() == kBW_EQ)
337  .getNormalizedHashEntryCount() +
339  for (const auto& device_columns : columns_per_device) {
340  CHECK(!device_columns.join_columns.empty());
341  const auto rhs_join_col_num_entries = device_columns.join_columns.front().num_elems;
342  if (rhs_join_col_num_entries > max_unique_hash_input_entries) {
343  VLOG(1) << "Skipping attempt to build perfect hash one-to-one table as number of "
344  "rhs column entries ("
345  << rhs_join_col_num_entries << ") exceeds range for rhs join column ("
346  << max_unique_hash_input_entries << ").";
347  return false;
348  }
349  }
350  return true;
351 }
ExpressionRange rhs_source_col_range_
HashEntryInfo get_bucketized_hash_entry_info(SQLTypeInfo const &context_ti, ExpressionRange const &col_range, bool const is_bw_eq)
std::shared_ptr< Analyzer::BinOper > qual_bin_oper_
bool hasNulls() const
std::vector< InnerOuter > inner_outer_pairs_
#define CHECK(condition)
Definition: Logger.h:222
Definition: sqldefs.h:30
#define VLOG(n)
Definition: Logger.h:316

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void PerfectJoinHashTable::markCachedItemAsDirty ( size_t  table_key)
inlinestatic

Definition at line 118 of file PerfectJoinHashTable.h.

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

118  {
121  auto candidate_table_keys =
122  hash_table_cache_->getMappedQueryPlanDagsWithTableKey(table_key);
123  if (candidate_table_keys.has_value()) {
124  hash_table_layout_cache_->markCachedItemAsDirty(
125  table_key,
126  *candidate_table_keys,
129  hash_table_cache_->markCachedItemAsDirty(table_key,
130  *candidate_table_keys,
133  }
134  }
static std::unique_ptr< HashtableRecycler > hash_table_cache_
static std::unique_ptr< HashingSchemeRecycler > hash_table_layout_cache_
#define CHECK(condition)
Definition: Logger.h:222
static constexpr DeviceIdentifier CPU_DEVICE_IDENTIFIER
Definition: DataRecycler.h:136
size_t PerfectJoinHashTable::offsetBufferOff ( ) const
overridevirtualnoexcept

Implements HashJoin.

Definition at line 1051 of file PerfectJoinHashTable.cpp.

Referenced by toSet(), and toString().

1051  {
1052  return 0;
1053 }

+ Here is the caller graph for this function:

size_t PerfectJoinHashTable::payloadBufferOff ( ) const
overridevirtualnoexcept

Implements HashJoin.

Definition at line 1059 of file PerfectJoinHashTable.cpp.

References getComponentBufferSize().

Referenced by toSet(), and toString().

1059  {
1060  return 2 * getComponentBufferSize();
1061 }
size_t getComponentBufferSize() const noexceptoverride

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void PerfectJoinHashTable::putHashTableOnCpuToCache ( QueryPlanHash  key,
CacheItemType  item_type,
std::shared_ptr< PerfectHashTable hashtable_ptr,
DeviceIdentifier  device_identifier,
size_t  hashtable_building_time 
)
private

Definition at line 918 of file PerfectJoinHashTable.cpp.

References CHECK, CPU, and hash_table_cache_.

Referenced by initHashTableForDevice().

923  {
925  CHECK(hashtable_ptr && !hashtable_ptr->getGpuBuffer());
926  hash_table_cache_->putItemToCache(
927  key,
928  hashtable_ptr,
929  item_type,
930  device_identifier,
931  hashtable_ptr->getHashTableBufferSize(ExecutorDeviceType::CPU),
932  hashtable_building_time);
933 }
static std::unique_ptr< HashtableRecycler > hash_table_cache_
#define CHECK(condition)
Definition: Logger.h:222

+ Here is the caller graph for this function:

void PerfectJoinHashTable::reify ( )
private

Definition at line 353 of file PerfectJoinHashTable.cpp.

References gpu_enabled::accumulate(), threading_serial::async(), HashJoin::canAccessHashTable(), CHECK, CHECK_EQ, CHECK_GE, CHECK_LT, HashJoin::checkHashJoinReplicationConstraint(), col_range_, copyCpuHashTableToGpu(), DataRecyclerUtil::CPU_DEVICE_IDENTIFIER, Data_Namespace::CPU_LEVEL, DEBUG_TIMER, device_count_, executor_, fetchColumnsForDevice(), HashJoin::freeHashBufferMemory(), genChunkKey(), anonymous_namespace{HashJoin.cpp}::get_cols(), get_shard_count(), getAlternativeCacheKey(), DataRecyclerUtil::getAlternativeTableKeys(), getEffectiveMemoryLevel(), HashtableRecycler::getHashtableAccessPathInfo(), getInnerQueryInfo(), getInnerTableId(), getQueryEngineCudaStreamForDevice(), Data_Namespace::GPU_LEVEL, hash_table_cache_, HashJoin::hash_tables_for_device_, hash_type_, hashtable_build_dag_map_, hashtable_cache_key_, hashtable_cache_meta_info_, InputTableInfo::info, initHashTableOnCpuFromCache(), inner_outer_pairs_, inner_outer_string_op_infos_, HashtableRecycler::isInvalidHashTableCacheKey(), isOneToOneHashPossible(), HashtableRecycler::isSafeToCacheHashtable(), join_type_, memory_level_, needs_dict_translation_, needs_dictionary_translation(), OneToMany, OneToOne, only_shards_for_device(), PERFECT_HT, qual_bin_oper_, reifyForDevice(), shardCount(), str_proxy_translation_map_, str_proxy_translation_mutex_, table_id_to_node_map_, table_keys_, logger::thread_id(), HashJoin::translateInnerToOuterStrDictProxies(), UNREACHABLE, and VLOG.

353  {
354  auto timer = DEBUG_TIMER(__func__);
356  auto catalog = const_cast<Catalog_Namespace::Catalog*>(executor_->getCatalog());
357  const auto cols =
358  get_cols(qual_bin_oper_.get(), *catalog, executor_->temporary_tables_).first;
359  const auto inner_col = cols.first;
361  inner_col->get_table_id(),
363  executor_);
364  const auto& query_info = getInnerQueryInfo(inner_col).info;
365  if (query_info.fragments.empty()) {
366  return;
367  }
368  if (query_info.getNumTuplesUpperBound() >
369  static_cast<size_t>(std::numeric_limits<int32_t>::max())) {
370  throw TooManyHashEntries();
371  }
372  std::vector<std::future<void>> init_threads;
373  const int shard_count = shardCount();
374 
375  inner_outer_pairs_.push_back(cols);
376  CHECK_EQ(inner_outer_pairs_.size(), size_t(1));
377  // Todo(todd): Clean up the fact that we store the inner outer column pairs as a vector,
378  // even though only one is ever valid for perfect hash layout. Either move to 1 or keep
379  // the vector but move it to the HashTable parent class
382 
383  std::vector<std::vector<Fragmenter_Namespace::FragmentInfo>> fragments_per_device;
384  std::vector<ColumnsForDevice> columns_per_device;
385  std::vector<std::unique_ptr<CudaAllocator>> dev_buff_owners;
386 
387  auto data_mgr = executor_->getDataMgr();
388  // check the existence of cached hash table here before fetching columns
389  // if available, skip the rest of logic and copy it to GPU if necessary
390  // there are few considerable things:
391  // 1. if table is sharded? --> deploy per-device logic
392  // here, each device may load different set of fragments, so their cache keys are
393  // different accordingly
394  // 2. otherwise, each device has the same hash table built from "all" fragments
395  // and their cache keys are the same (but we stick to per-device cache key vector)
396  // here, for CPU, we consider its # device to be one
397  // for GPU, each device builds its own hash table, or we build a single hash table on
398  // CPU and then copy it to each device
399  // 3. if cache key is not available? --> use alternative cache key
400 
401  // retrieve fragment lists and chunk key per device
402  std::vector<ChunkKey> chunk_key_per_device;
403  auto outer_col =
404  dynamic_cast<const Analyzer::ColumnVar*>(inner_outer_pairs_.front().second);
405  for (int device_id = 0; device_id < device_count_; ++device_id) {
406  fragments_per_device.emplace_back(
407  shard_count
408  ? only_shards_for_device(query_info.fragments, device_id, device_count_)
409  : query_info.fragments);
411  dev_buff_owners.emplace_back(std::make_unique<CudaAllocator>(
412  data_mgr, device_id, getQueryEngineCudaStreamForDevice(device_id)));
413  }
414  const auto chunk_key =
415  genChunkKey(fragments_per_device[device_id], outer_col, inner_col);
416  chunk_key_per_device.emplace_back(std::move(chunk_key));
417  }
418 
419  // try to extract cache key for hash table and its relevant info
420  auto hashtable_access_path_info =
423  qual_bin_oper_->get_optype(),
424  join_type_,
427  shard_count,
428  fragments_per_device,
429  executor_);
430  hashtable_cache_key_ = hashtable_access_path_info.hashed_query_plan_dag;
431  hashtable_cache_meta_info_ = hashtable_access_path_info.meta_info;
432  table_keys_ = hashtable_access_path_info.table_keys;
433 
434  if (table_keys_.empty()) {
435  // the actual chunks fetched per device can be different but they constitute the same
436  // table in the same db, so we can exploit this to create an alternative table key
438  chunk_key_per_device,
439  executor_->getCatalog()->getDatabaseId(),
440  getInnerTableId());
441  }
442  CHECK(!table_keys_.empty());
443 
444  if (HashtableRecycler::isInvalidHashTableCacheKey(hashtable_cache_key_) &&
445  getInnerTableId() > 0) {
446  // sometimes we cannot retrieve query plan dag, so try to recycler cache
447  // with the old-fashioned cache key if we deal with hashtable of non-temporary table
448  for (int device_id = 0; device_id < device_count_; ++device_id) {
449  const auto num_tuples = std::accumulate(
450  fragments_per_device[device_id].begin(),
451  fragments_per_device[device_id].end(),
452  size_t(0),
453  [](size_t sum, const auto& fragment) { return sum + fragment.getNumTuples(); });
454  AlternativeCacheKeyForPerfectHashJoin cache_key{col_range_,
455  inner_col,
456  outer_col ? outer_col : inner_col,
458  chunk_key_per_device[device_id],
459  num_tuples,
460  qual_bin_oper_->get_optype(),
461  join_type_};
462  hashtable_cache_key_[device_id] = getAlternativeCacheKey(cache_key);
463  }
464  }
465 
466  // register a mapping between cache key and its input table info for per-table cache
467  // invalidation if we have valid cache key for "all" devices (otherwise, we skip to use
468  // cached hash table for safety)
469  const bool invalid_cache_key =
470  HashtableRecycler::isInvalidHashTableCacheKey(hashtable_cache_key_);
471  if (!invalid_cache_key) {
472  if (!shard_count) {
473  hash_table_cache_->addQueryPlanDagForTableKeys(hashtable_cache_key_.front(),
474  table_keys_);
475  } else {
476  std::for_each(hashtable_cache_key_.cbegin(),
477  hashtable_cache_key_.cend(),
478  [this](QueryPlanHash key) {
479  hash_table_cache_->addQueryPlanDagForTableKeys(key, table_keys_);
480  });
481  }
482  }
483 
484  const auto effective_memory_level = getEffectiveMemoryLevel(inner_outer_pairs_);
485 
486  // Assume we will need one-to-many if we have a string operation, as these tend
487  // to be cardinality-reducting operations, i.e. |S(t)| < |t|
488  // Todo(todd): Ostensibly only string ops on the rhs/inner expression cause rhs dups and
489  // so we may be too conservative here, but validate
490 
491  const bool has_string_ops = inner_outer_string_op_infos_.first.size() ||
492  inner_outer_string_op_infos_.second.size();
493 
494  // Also check if on the number of entries per column exceeds the rhs join hash table
495  // range, and skip trying to build a One-to-One hash table if so. There is a slight edge
496  // case where this can be overly pessimistic, and that is if the non-null values are all
497  // unique, but there are multiple null values, but we currently don't have the metadata
498  // to track null counts (only column nullability from the ddl and null existence from
499  // the encoded data), and this is probably too much of an edge case to worry about for
500  // now given the general performance benfits of skipping 1:1 if we are fairly confident
501  // it is doomed up front
502 
503  // Now check if on the number of entries per column exceeds the rhs join hash table
504  // range, and skip trying to build a One-to-One hash table if so
506  (has_string_ops || !isOneToOneHashPossible(columns_per_device))) {
508  }
509 
510  // todo (yoonmin) : support dictionary proxy cache for join including string op(s)
511  if (effective_memory_level == Data_Namespace::CPU_LEVEL) {
512  // construct string dictionary proxies if necessary
513  std::unique_lock<std::mutex> str_proxy_translation_lock(str_proxy_translation_mutex_);
514  if (needs_dict_translation_ && !str_proxy_translation_map_) {
515  CHECK_GE(inner_outer_pairs_.size(), 1UL);
519  col_range_,
520  executor_);
521  }
522  }
523 
524  auto allow_hashtable_recycling =
526  needs_dict_translation_,
528  inner_col->get_table_id());
529  bool has_invalid_cached_hash_table = false;
530  if (effective_memory_level == Data_Namespace::CPU_LEVEL &&
532  allow_hashtable_recycling, invalid_cache_key, join_type_)) {
533  // build a hash table on CPU, and we have a chance to recycle the cached one if
534  // available
535  for (int device_id = 0; device_id < device_count_; ++device_id) {
536  auto hash_table =
537  initHashTableOnCpuFromCache(hashtable_cache_key_[device_id],
540  if (hash_table) {
541  hash_tables_for_device_[device_id] = hash_table;
542  hash_type_ = hash_table->getLayout();
543  } else {
544  has_invalid_cached_hash_table = true;
545  break;
546  }
547  }
548 
549  if (has_invalid_cached_hash_table) {
550  hash_tables_for_device_.clear();
551  hash_tables_for_device_.resize(device_count_);
552  } else {
554 #ifdef HAVE_CUDA
555  for (int device_id = 0; device_id < device_count_; ++device_id) {
556  auto cpu_hash_table = std::dynamic_pointer_cast<PerfectHashTable>(
557  hash_tables_for_device_[device_id]);
558  copyCpuHashTableToGpu(cpu_hash_table, device_id, data_mgr);
559  }
560 #else
561  UNREACHABLE();
562 #endif
563  }
564  return;
565  }
566  }
567 
568  // we have no cached hash table for this qual
569  // so, start building the hash table by fetching columns for devices
570  for (int device_id = 0; device_id < device_count_; ++device_id) {
571  columns_per_device.emplace_back(
572  fetchColumnsForDevice(fragments_per_device[device_id],
573  device_id,
575  ? dev_buff_owners[device_id].get()
576  : nullptr,
577  *catalog));
578  }
579 
580  try {
581  for (int device_id = 0; device_id < device_count_; ++device_id) {
582  const auto chunk_key = genChunkKey(fragments_per_device[device_id],
583  inner_outer_pairs_.front().second,
584  inner_outer_pairs_.front().first);
585  init_threads.push_back(std::async(std::launch::async,
587  this,
588  chunk_key,
589  columns_per_device[device_id],
590  hash_type_,
591  device_id,
592  logger::thread_id()));
593  }
594  for (auto& init_thread : init_threads) {
595  init_thread.wait();
596  }
597  for (auto& init_thread : init_threads) {
598  init_thread.get();
599  }
600  } catch (const NeedsOneToManyHash& e) {
601  VLOG(1) << "RHS/Inner hash join values detected to not be unique, falling back to "
602  "One-to-Many hash layout.";
606  init_threads.clear();
608  CHECK_EQ(dev_buff_owners.size(), size_t(device_count_));
609  }
610  CHECK_EQ(columns_per_device.size(), size_t(device_count_));
611  for (int device_id = 0; device_id < device_count_; ++device_id) {
612  const auto chunk_key = genChunkKey(fragments_per_device[device_id],
613  inner_outer_pairs_.front().second,
614  inner_outer_pairs_.front().first);
615  init_threads.push_back(std::async(std::launch::async,
617  this,
618  chunk_key,
619  columns_per_device[device_id],
620  hash_type_,
621  device_id,
622  logger::thread_id()));
623  }
624  for (auto& init_thread : init_threads) {
625  init_thread.wait();
626  }
627  for (auto& init_thread : init_threads) {
628  init_thread.get();
629  }
630  }
631 }
void reifyForDevice(const ChunkKey &hash_table_key, const ColumnsForDevice &columns_for_device, const HashType layout, const int device_id, const logger::ThreadId parent_thread_id)
#define CHECK_EQ(x, y)
Definition: Logger.h:230
Fragmenter_Namespace::TableInfo info
Definition: InputMetadata.h:35
Data_Namespace::MemoryLevel getEffectiveMemoryLevel(const std::vector< InnerOuter > &inner_outer_pairs) const
class for a per-database catalog. also includes metadata for the current database and the current use...
Definition: Catalog.h:132
static bool isInvalidHashTableCacheKey(const std::vector< QueryPlanHash > &cache_keys)
static bool canAccessHashTable(bool allow_hash_table_recycling, bool invalid_cache_key, JoinType join_type)
Definition: HashJoin.cpp:1026
const Data_Namespace::MemoryLevel memory_level_
std::shared_ptr< Analyzer::BinOper > qual_bin_oper_
std::mutex str_proxy_translation_mutex_
ChunkKey genChunkKey(const std::vector< Fragmenter_Namespace::FragmentInfo > &fragments, const Analyzer::Expr *outer_col, const Analyzer::ColumnVar *inner_col) const
const TableIdToNodeMap table_id_to_node_map_
std::vector< std::shared_ptr< HashTable > > hash_tables_for_device_
Definition: HashJoin.h:351
#define UNREACHABLE()
Definition: Logger.h:266
#define CHECK_GE(x, y)
Definition: Logger.h:235
HashTableBuildDagMap hashtable_build_dag_map_
const InputTableInfo & getInnerQueryInfo(const Analyzer::ColumnVar *inner_col) const
std::shared_ptr< PerfectHashTable > initHashTableOnCpuFromCache(QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier)
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
void copyCpuHashTableToGpu(std::shared_ptr< PerfectHashTable > &cpu_hash_table, const int device_id, Data_Namespace::DataMgr *data_mgr)
HashtableCacheMetaInfo hashtable_cache_meta_info_
static std::unique_ptr< HashtableRecycler > hash_table_cache_
ColumnsForDevice fetchColumnsForDevice(const std::vector< Fragmenter_Namespace::FragmentInfo > &fragments, const int device_id, DeviceAllocator *dev_buff_owner, const Catalog_Namespace::Catalog &catalog)
future< Result > async(Fn &&fn, Args &&...args)
std::vector< Fragmenter_Namespace::FragmentInfo > only_shards_for_device(const std::vector< Fragmenter_Namespace::FragmentInfo > &fragments, const int device_id, const int device_count)
bool isOneToOneHashPossible(const std::vector< ColumnsForDevice > &columns_per_device) const
DEVICE auto accumulate(ARGS &&...args)
Definition: gpu_enabled.h:42
static void checkHashJoinReplicationConstraint(const int table_id, const size_t shard_count, const Executor *executor)
Definition: HashJoin.cpp:771
std::vector< InnerOuter > inner_outer_pairs_
static const StringDictionaryProxy::IdMap * translateInnerToOuterStrDictProxies(const InnerOuter &cols, const InnerOuterStringOpInfos &inner_outer_string_op_infos, ExpressionRange &old_col_range, const Executor *executor)
Definition: HashJoin.cpp:408
#define CHECK_LT(x, y)
Definition: Logger.h:232
static QueryPlanHash getAlternativeCacheKey(AlternativeCacheKeyForPerfectHashJoin &info)
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 QueryPlanHash
CUstream getQueryEngineCudaStreamForDevice(int device_num)
Definition: QueryEngine.cpp:7
const InnerOuterStringOpInfos inner_outer_string_op_infos_
ThreadId thread_id()
Definition: Logger.cpp:820
#define CHECK(condition)
Definition: Logger.h:222
#define DEBUG_TIMER(name)
Definition: Logger.h:371
std::vector< QueryPlanHash > hashtable_cache_key_
static constexpr DeviceIdentifier CPU_DEVICE_IDENTIFIER
Definition: DataRecycler.h:136
size_t get_shard_count(const Analyzer::BinOper *join_condition, const Executor *executor)
Definition: HashJoin.cpp:1045
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)
InnerOuter get_cols(const Analyzer::BinOper *qual_bin_oper, const Catalog_Namespace::Catalog &cat, const TemporaryTables *temporary_tables)
Definition: HashJoin.cpp:1035
const StringDictionaryProxy::IdMap * str_proxy_translation_map_
std::unordered_set< size_t > table_keys_
#define VLOG(n)
Definition: Logger.h:316
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)

+ Here is the call graph for this function:

void PerfectJoinHashTable::reifyForDevice ( const ChunkKey hash_table_key,
const ColumnsForDevice columns_for_device,
const HashType  layout,
const int  device_id,
const logger::ThreadId  parent_thread_id 
)
private

Definition at line 683 of file PerfectJoinHashTable.cpp.

References CHECK_EQ, DEBUG_TIMER_NEW_THREAD, get_effective_memory_level(), initHashTableForDevice(), inner_outer_pairs_, ColumnsForDevice::join_columns, memory_level_, needs_dict_translation_, OneToMany, OneToOne, and to_string().

Referenced by reify().

687  {
688  DEBUG_TIMER_NEW_THREAD(parent_thread_id);
689  const auto effective_memory_level =
691 
692  CHECK_EQ(columns_for_device.join_columns.size(), size_t(1));
693  CHECK_EQ(inner_outer_pairs_.size(), size_t(1));
694  auto& join_column = columns_for_device.join_columns.front();
695  if (layout == HashType::OneToOne) {
696  const auto err = initHashTableForDevice(chunk_key,
697  join_column,
698  inner_outer_pairs_.front(),
699  layout,
700 
701  effective_memory_level,
702  device_id);
703  if (err) {
704  throw NeedsOneToManyHash();
705  }
706  } else {
707  const auto err = initHashTableForDevice(chunk_key,
708  join_column,
709  inner_outer_pairs_.front(),
711  effective_memory_level,
712  device_id);
713  if (err) {
714  throw std::runtime_error("Unexpected error building one to many hash table: " +
715  std::to_string(err));
716  }
717  }
718 }
#define CHECK_EQ(x, y)
Definition: Logger.h:230
const Data_Namespace::MemoryLevel memory_level_
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)
std::vector< InnerOuter > inner_outer_pairs_
int initHashTableForDevice(const ChunkKey &chunk_key, const JoinColumn &join_column, const InnerOuter &cols, const HashType layout, const Data_Namespace::MemoryLevel effective_memory_level, const int device_id)
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:

size_t PerfectJoinHashTable::shardCount ( ) const
private

Definition at line 1275 of file PerfectJoinHashTable.cpp.

References executor_, get_shard_count(), Data_Namespace::GPU_LEVEL, memory_level_, and qual_bin_oper_.

Referenced by codegenMatchingSet(), codegenSlot(), copyCpuHashTableToGpu(), initHashTableForDevice(), and reify().

1275  {
1278  : 0;
1279 }
const Data_Namespace::MemoryLevel memory_level_
std::shared_ptr< Analyzer::BinOper > qual_bin_oper_
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:

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

Implements HashJoin.

Definition at line 1152 of file PerfectJoinHashTable.cpp.

References countBufferOff(), executor_, getHashTableForDevice(), HashJoin::getJoinHashBuffer(), HashJoin::getJoinHashBufferSize(), getQueryEngineCudaStreamForDevice(), GPU, offsetBufferOff(), payloadBufferOff(), and HashTable::toSet().

1154  {
1155  auto buffer = getJoinHashBuffer(device_type, device_id);
1156  auto buffer_size = getJoinHashBufferSize(device_type, device_id);
1157  auto hash_table = getHashTableForDevice(device_id);
1158 #ifdef HAVE_CUDA
1159  std::unique_ptr<int8_t[]> buffer_copy;
1160  if (device_type == ExecutorDeviceType::GPU) {
1161  buffer_copy = std::make_unique<int8_t[]>(buffer_size);
1162 
1163  auto data_mgr = executor_->getDataMgr();
1164  auto device_allocator = std::make_unique<CudaAllocator>(
1165  data_mgr, device_id, getQueryEngineCudaStreamForDevice(device_id));
1166  device_allocator->copyFromDevice(buffer_copy.get(), buffer, buffer_size);
1167  }
1168  auto ptr1 = buffer_copy ? buffer_copy.get() : reinterpret_cast<const int8_t*>(buffer);
1169 #else
1170  auto ptr1 = reinterpret_cast<const int8_t*>(buffer);
1171 #endif // HAVE_CUDA
1172  auto ptr2 = ptr1 + offsetBufferOff();
1173  auto ptr3 = ptr1 + countBufferOff();
1174  auto ptr4 = ptr1 + payloadBufferOff();
1175  return HashTable::toSet(0,
1176  0,
1177  hash_table ? hash_table->getEntryCount() : 0,
1178  ptr1,
1179  ptr2,
1180  ptr3,
1181  ptr4,
1182  buffer_size);
1183 }
size_t offsetBufferOff() const noexceptoverride
size_t payloadBufferOff() const noexceptoverride
int8_t * getJoinHashBuffer(const ExecutorDeviceType device_type, const int device_id) const
Definition: HashJoin.h:288
size_t getJoinHashBufferSize(const ExecutorDeviceType device_type)
Definition: HashJoin.h:274
CUstream getQueryEngineCudaStreamForDevice(int device_num)
Definition: QueryEngine.cpp:7
size_t countBufferOff() const noexceptoverride
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
HashTable * getHashTableForDevice(const size_t device_id) const

+ Here is the call graph for this function:

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

Implements HashJoin.

Definition at line 1116 of file PerfectJoinHashTable.cpp.

References countBufferOff(), executor_, getHashTableForDevice(), HashJoin::getHashTypeString(), HashJoin::getJoinHashBuffer(), HashJoin::getJoinHashBufferSize(), getQueryEngineCudaStreamForDevice(), GPU, hash_type_, offsetBufferOff(), payloadBufferOff(), and HashTable::toString().

Referenced by getAlternativeCacheKey().

1118  {
1119  auto buffer = getJoinHashBuffer(device_type, device_id);
1120  auto buffer_size = getJoinHashBufferSize(device_type, device_id);
1121  auto hash_table = getHashTableForDevice(device_id);
1122 #ifdef HAVE_CUDA
1123  std::unique_ptr<int8_t[]> buffer_copy;
1124  if (device_type == ExecutorDeviceType::GPU) {
1125  buffer_copy = std::make_unique<int8_t[]>(buffer_size);
1126 
1127  auto data_mgr = executor_->getDataMgr();
1128  auto device_allocator = std::make_unique<CudaAllocator>(
1129  data_mgr, device_id, getQueryEngineCudaStreamForDevice(device_id));
1130  device_allocator->copyFromDevice(buffer_copy.get(), buffer, buffer_size);
1131  }
1132  auto ptr1 = buffer_copy ? buffer_copy.get() : reinterpret_cast<const int8_t*>(buffer);
1133 #else
1134  auto ptr1 = reinterpret_cast<const int8_t*>(buffer);
1135 #endif // HAVE_CUDA
1136  auto ptr2 = ptr1 + offsetBufferOff();
1137  auto ptr3 = ptr1 + countBufferOff();
1138  auto ptr4 = ptr1 + payloadBufferOff();
1139  return HashTable::toString("perfect",
1141  0,
1142  0,
1143  hash_table ? hash_table->getEntryCount() : 0,
1144  ptr1,
1145  ptr2,
1146  ptr3,
1147  ptr4,
1148  buffer_size,
1149  raw);
1150 }
size_t offsetBufferOff() const noexceptoverride
size_t payloadBufferOff() const noexceptoverride
int8_t * getJoinHashBuffer(const ExecutorDeviceType device_type, const int device_id) const
Definition: HashJoin.h:288
static std::string getHashTypeString(HashType ht) noexcept
Definition: HashJoin.h:154
size_t getJoinHashBufferSize(const ExecutorDeviceType device_type)
Definition: HashJoin.h:274
static std::string toString(const std::string &type, const std::string &layout_type, size_t key_component_count, size_t key_component_width, size_t entry_count, const int8_t *ptr1, const int8_t *ptr2, const int8_t *ptr3, const int8_t *ptr4, size_t buffer_size, bool raw=false)
Decode hash table into a human-readable string.
Definition: HashTable.cpp:226
CUstream getQueryEngineCudaStreamForDevice(int device_num)
Definition: QueryEngine.cpp:7
size_t countBufferOff() const noexceptoverride
HashTable * getHashTableForDevice(const size_t device_id) const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

ExpressionRange PerfectJoinHashTable::col_range_
private

Definition at line 273 of file PerfectJoinHashTable.h.

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

std::shared_ptr<Analyzer::ColumnVar> PerfectJoinHashTable::col_var_
private

Definition at line 266 of file PerfectJoinHashTable.h.

Referenced by getInnerTableId(), and getInnerTableRteIdx().

ColumnCacheMap& PerfectJoinHashTable::column_cache_
private

Definition at line 276 of file PerfectJoinHashTable.h.

Referenced by fetchColumnsForDevice().

std::mutex PerfectJoinHashTable::cpu_hash_table_buff_mutex_
private

Definition at line 270 of file PerfectJoinHashTable.h.

Referenced by copyCpuHashTableToGpu(), and initHashTableForDevice().

const int PerfectJoinHashTable::device_count_
private
std::unique_ptr< HashtableRecycler > PerfectJoinHashTable::hash_table_cache_
staticprivate
std::unique_ptr< HashingSchemeRecycler > PerfectJoinHashTable::hash_table_layout_cache_
staticprivate
Initial value:
=
std::make_unique<HashingSchemeRecycler>()

Definition at line 288 of file PerfectJoinHashTable.h.

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

HashType PerfectJoinHashTable::hash_type_
private

Definition at line 269 of file PerfectJoinHashTable.h.

Referenced by getHashType(), initHashTableForDevice(), reify(), and toString().

HashTableBuildDagMap PerfectJoinHashTable::hashtable_build_dag_map_
private

Definition at line 279 of file PerfectJoinHashTable.h.

Referenced by reify().

std::vector<QueryPlanHash> PerfectJoinHashTable::hashtable_cache_key_
private

Definition at line 281 of file PerfectJoinHashTable.h.

Referenced by initHashTableForDevice(), and reify().

HashtableCacheMetaInfo PerfectJoinHashTable::hashtable_cache_meta_info_
private

Definition at line 282 of file PerfectJoinHashTable.h.

Referenced by reify().

std::vector<InnerOuter> PerfectJoinHashTable::inner_outer_pairs_
private
const InnerOuterStringOpInfos PerfectJoinHashTable::inner_outer_string_op_infos_
private
const JoinType PerfectJoinHashTable::join_type_
private

Definition at line 265 of file PerfectJoinHashTable.h.

Referenced by initHashTableForDevice(), and reify().

bool PerfectJoinHashTable::needs_dict_translation_
mutableprivate
std::shared_ptr<Analyzer::BinOper> PerfectJoinHashTable::qual_bin_oper_
private
const std::vector<InputTableInfo>& PerfectJoinHashTable::query_infos_
private

Definition at line 267 of file PerfectJoinHashTable.h.

Referenced by getInnerQueryInfo().

ExpressionRange PerfectJoinHashTable::rhs_source_col_range_
private

Definition at line 274 of file PerfectJoinHashTable.h.

Referenced by isOneToOneHashPossible().

const StringDictionaryProxy::IdMap* PerfectJoinHashTable::str_proxy_translation_map_ {nullptr}
private

Definition at line 272 of file PerfectJoinHashTable.h.

Referenced by initHashTableForDevice(), and reify().

std::mutex PerfectJoinHashTable::str_proxy_translation_mutex_
private

Definition at line 271 of file PerfectJoinHashTable.h.

Referenced by reify().

const TableIdToNodeMap PerfectJoinHashTable::table_id_to_node_map_
private

Definition at line 284 of file PerfectJoinHashTable.h.

Referenced by initHashTableForDevice(), and reify().

std::unordered_set<size_t> PerfectJoinHashTable::table_keys_
private

Definition at line 283 of file PerfectJoinHashTable.h.

Referenced by reify().


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