33 const std::vector<InputTableInfo>& query_infos,
37 const std::vector<InnerOuter>& inner_outer_pairs,
38 const int device_count,
60 static std::shared_ptr<BoundingBoxIntersectJoinHashTable>
getInstance(
61 const std::shared_ptr<Analyzer::BinOper> condition,
62 const std::vector<InputTableInfo>& query_infos,
65 const int device_count,
83 auto candidate_table_keys =
85 if (candidate_table_keys.has_value()) {
88 *candidate_table_keys,
92 *candidate_table_keys,
114 virtual void reifyImpl(std::vector<ColumnsForDevice>& columns_per_device,
117 const size_t shard_count,
118 const size_t entry_count,
119 const size_t emitted_keys_count,
120 const bool skip_hashtable_caching,
121 const size_t chosen_max_hashtable_size,
122 const double chosen_bucket_threshold);
126 const size_t entry_count,
127 const size_t emitted_keys_count,
128 const bool skip_hashtable_caching,
133 size_t emitted_keys_count,
134 size_t entry_count)
const;
137 const std::vector<Fragmenter_Namespace::FragmentInfo>& fragments,
143 const std::vector<double>& inverse_bucket_sizes_for_dimension,
144 std::vector<ColumnsForDevice>&,
145 const size_t chosen_max_hashtable_size,
146 const double chosen_bucket_threshold);
150 const size_t shard_count,
151 const std::vector<double>& inverse_bucket_sizes_for_dimension,
152 std::vector<ColumnsForDevice>& columns_per_device,
153 const size_t chosen_max_hashtable_size,
154 const double chosen_bucket_threshold);
157 std::vector<ColumnsForDevice>& columns_per_device,
158 const size_t device_count);
170 return hash_table->getLayout();
180 const std::vector<JoinColumn>& join_columns,
181 const std::vector<JoinColumnTypeInfo>& join_column_types,
182 const std::vector<JoinBucketInfo>& join_bucket_info,
184 const bool skip_hashtable_caching);
187 std::shared_ptr<BaselineHashTable> initHashTableOnGpu(
188 const std::vector<JoinColumn>& join_columns,
189 const std::vector<JoinColumnTypeInfo>& join_column_types,
190 const std::vector<JoinBucketInfo>& join_bucket_info,
192 const size_t device_id);
194 std::shared_ptr<BaselineHashTable> copyCpuHashTableToGpu(
195 std::shared_ptr<BaselineHashTable>& cpu_hash_table,
196 const size_t device_id);
200 const size_t)
override;
203 const int device_id = 0,
204 bool raw =
false)
const override;
207 const int device_id)
const override;
221 return hash_table->getEntryCount();
227 return hash_table->getEmittedKeysCount();
234 return hash_table->getEntryCount() *
sizeof(int32_t);
246 const std::vector<InnerOuter>& inner_outer_pairs)
const;
253 return first_inner_col->get_rte_idx();
258 CHECK(key_component_width == 4 || key_component_width == 8);
261 return getEntryCount() * key_component_count * key_component_width;
263 return getEntryCount() * (key_component_count + 1) * key_component_width;
288 return "BoundingBoxIntersect";
305 std::shared_ptr<HashTable> hashtable_ptr,
307 size_t hashtable_building_time);
330 auto inner_col = inner_outer.first;
332 auto outer_col = rhs_col_var ? rhs_col_var : inner_col;
333 boost::hash_combine(hash, inner_col->toString());
334 if (inner_col->get_type_info().is_string()) {
335 boost::hash_combine(hash, outer_col->toString());
339 boost::hash_combine(hash, info.
optype);
347 const size_t max_hashtable_size,
348 const double bucket_threshold,
349 const std::vector<double>& bucket_sizes,
350 std::vector<std::vector<Fragmenter_Namespace::FragmentInfo>>& fragments_per_device,
352 for (
int device_id = 0; device_id < device_count; ++device_id) {
354 boost::hash_combine(hash_val, max_hashtable_size);
355 boost::hash_combine(hash_val, bucket_threshold);
356 boost::hash_combine(hash_val, bucket_sizes);
357 boost::hash_combine(hash_val,
374 double bucket_threshold,
375 std::vector<double>& bucket_sizes) {
402 std::optional<HashType>
static std::vector< int > collectFragmentIds(const std::vector< Fragmenter_Namespace::FragmentInfo > &fragments)
const RegisteredQueryHint & getRegisteredQueryHint()
virtual ~BoundingBoxIntersectJoinHashTable()
static std::unique_ptr< BoundingBoxIntersectTuningParamRecycler > auto_tuner_cache_
size_t getKeyComponentCount() const
std::string getHashJoinType() const final
size_t getEmittedKeysCount() const
void setBoundingBoxIntersectionMetaInfo(size_t max_table_size_bytes, double bucket_threshold, std::vector< double > &bucket_sizes)
llvm::Value * codegenSlot(const CompilationOptions &, const size_t) override
virtual std::pair< size_t, size_t > computeHashTableCounts(const size_t shard_count, const std::vector< double > &inverse_bucket_sizes_for_dimension, std::vector< ColumnsForDevice > &columns_per_device, const size_t chosen_max_hashtable_size, const double chosen_bucket_threshold)
HashtableCacheMetaInfo hashtable_cache_meta_info_
const TableIdToNodeMap table_id_to_node_map_
std::mutex cpu_hash_table_buff_mutex_
Data_Namespace::MemoryLevel getEffectiveMemoryLevel(const std::vector< InnerOuter > &inner_outer_pairs) const
Data_Namespace::MemoryLevel getMemoryLevel() const noexceptoverride
size_t calculateHashTableSize(size_t number_of_dimensions, size_t emitted_keys_count, size_t entry_count) const
std::pair< const Analyzer::ColumnVar *, const Analyzer::Expr * > InnerOuter
llvm::Value * codegenKey(const CompilationOptions &)
size_t getKeyComponentWidth() const
shared::TableKey getInnerTableId() const noexceptoverride
std::vector< QueryPlanHash > hashtable_cache_key_
HashJoinMatchingSet codegenMatchingSet(const CompilationOptions &, const size_t) override
std::unordered_set< size_t > table_keys_
static void invalidateCache()
size_t offsetBufferOff() const noexceptoverride
void reify(const HashType preferred_layout)
std::vector< std::shared_ptr< HashTable > > hash_tables_for_device_
const std::shared_ptr< Analyzer::BinOper > condition_
std::shared_ptr< BaselineHashTable > initHashTableOnCpu(const std::vector< JoinColumn > &join_columns, const std::vector< JoinColumnTypeInfo > &join_column_types, const std::vector< JoinBucketInfo > &join_bucket_info, const BaselineHashTableEntryInfo hash_table_entry_info, const bool skip_hashtable_caching)
std::vector< double > inverse_bucket_sizes_for_dimension_
DecodedJoinHashBufferSet toSet(const ExecutorDeviceType device_type, const int device_id) const override
CompositeKeyInfo composite_key_info_
std::optional< HashType > layout_override_
BoundingBoxIntersectJoinHashTable(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 int device_count, const RegisteredQueryHint &query_hints, const HashTableBuildDagMap &hashtable_build_dag_map, const TableIdToNodeMap &table_id_to_node_map)
virtual std::pair< size_t, size_t > approximateTupleCount(const std::vector< double > &inverse_bucket_sizes_for_dimension, std::vector< ColumnsForDevice > &, const size_t chosen_max_hashtable_size, const double chosen_bucket_threshold)
double chosen_bbox_intersect_bucket_threshold_
std::vector< llvm::Value * > codegenManyKey(const CompilationOptions &)
size_t shardCount() const
void setInverseBucketSizeInfo(const std::vector< double > &inverse_bucket_sizes, std::vector< ColumnsForDevice > &columns_per_device, const size_t device_count)
HashTableBuildDagMap hashtable_build_dag_map_
const std::vector< InnerOuter > & getInnerOuterPairs() const
bool isBitwiseEq() const override
ColumnsForDevice fetchColumnsForDevice(const std::vector< Fragmenter_Namespace::FragmentInfo > &fragments, const int device_id, DeviceAllocator *dev_buff_owner)
std::optional< BoundingBoxIntersectMetaInfo > getBoundingBoxIntersectMetaInfo()
std::unordered_map< size_t, HashTableBuildDag > HashTableBuildDagMap
const Data_Namespace::MemoryLevel memory_level_
static std::unique_ptr< HashtableRecycler > hash_table_cache_
void generateCacheKey(const size_t max_hashtable_size, const double bucket_threshold, const std::vector< double > &bucket_sizes, std::vector< std::vector< Fragmenter_Namespace::FragmentInfo >> &fragments_per_device, int device_count)
static std::shared_ptr< BoundingBoxIntersectJoinHashTable > getInstance(const std::shared_ptr< Analyzer::BinOper > condition, const std::vector< InputTableInfo > &query_infos, const Data_Namespace::MemoryLevel memory_level, const JoinType join_type, const int device_count, ColumnCacheMap &column_cache, Executor *executor, const HashTableBuildDagMap &hashtable_build_dag_map, const RegisteredQueryHint &query_hint, const TableIdToNodeMap &table_id_to_node_map)
Make hash table from an in-flight SQL query's parse tree etc.
const std::vector< InputTableInfo > & query_infos_
QueryPlanDAG query_plan_dag_
virtual void reifyImpl(std::vector< ColumnsForDevice > &columns_per_device, const Fragmenter_Namespace::TableInfo &query_info, const HashType layout, const size_t shard_count, const size_t entry_count, const size_t emitted_keys_count, const bool skip_hashtable_caching, const size_t chosen_max_hashtable_size, const double chosen_bucket_threshold)
QueryPlanHash getAlternativeCacheKey(AlternativeCacheKeyForBoundingBoxIntersection &info)
const size_t num_elements
std::vector< InnerOuter > inner_outer_pairs
size_t payloadBufferOff() const noexceptoverride
size_t getKeyBufferSize() const noexcept
HashTable * getHashTableForDevice(const size_t device_id) const
std::unordered_map< shared::TableKey, const RelAlgNode * > TableIdToNodeMap
const size_t chunk_key_hash
const double bucket_threshold
HashType getHashType() const noexceptoverride
std::vector< InnerOuter > inner_outer_pairs_
size_t chosen_bbox_intersect_max_table_size_bytes_
std::set< DecodedJoinHashBufferEntry > DecodedJoinHashBufferSet
size_t getEntryCount() const
static void markCachedItemAsDirty(size_t table_key)
virtual void reifyWithLayout(const HashType layout)
std::unordered_map< shared::TableKey, std::unordered_map< int, std::shared_ptr< const ColumnarResults >>> ColumnCacheMap
int getInnerTableRteIdx() const noexceptoverride
const JoinType join_type_
std::size_t hash_value(RexAbstractInput const &rex_ab_input)
const size_t max_hashtable_size
RegisteredQueryHint query_hints_
void putHashTableOnCpuToCache(QueryPlanHash key, CacheItemType item_type, std::shared_ptr< HashTable > hashtable_ptr, DeviceIdentifier device_identifier, size_t hashtable_building_time)
void reifyForDevice(const ColumnsForDevice &columns_for_device, const HashType layout, const size_t entry_count, const size_t emitted_keys_count, const bool skip_hashtable_caching, const int device_id, const logger::ThreadLocalIds parent_thread_local_ids)
size_t countBufferOff() const noexceptoverride
QueryPlanHash getCacheKey(int device_id) const
constexpr int32_t kMaxBBoxOverlapsCount
ColumnCacheMap & column_cache_
std::optional< std::pair< size_t, size_t > > getApproximateTupleCountFromCache(QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier)
int getDeviceCount() const noexceptoverride
static size_t getShardCountForCondition(const Analyzer::BinOper *condition, const Executor *executor, const std::vector< InnerOuter > &inner_outer_pairs)
static HashtableRecycler * getHashTableCache()
std::shared_ptr< HashTable > initHashTableOnCpuFromCache(QueryPlanHash key, CacheItemType item_type, DeviceIdentifier device_identifier)
static constexpr DeviceIdentifier CPU_DEVICE_IDENTIFIER
std::string toString(const ExecutorDeviceType device_type, const int device_id=0, bool raw=false) const override
const std::vector< double > inverse_bucket_sizes
static BoundingBoxIntersectTuningParamRecycler * getBoundingBoxIntersectTuningParamCache()
static bool layoutRequiresAdditionalBuffers(HashType layout) noexcept
size_t getComponentBufferSize() const noexceptoverride