OmniSciDB  04ee39c94c
anonymous_namespace{JoinHashTable.cpp} Namespace Reference

Classes

class  NeedsOneToManyHash
 

Functions

std::pair< const Analyzer::ColumnVar *, const Analyzer::Expr * > get_cols (const Analyzer::BinOper *qual_bin_oper, const Catalog_Namespace::Catalog &cat, const TemporaryTables *temporary_tables)
 
HashEntryInfo get_bucketized_hash_entry_info (SQLTypeInfo const &context_ti, ExpressionRange const &col_range, bool const is_bw_eq)
 
size_t get_hash_entry_count (const ExpressionRange &col_range, const bool is_bw_eq)
 
bool shard_count_less_or_equal_device_count (const int inner_table_id, const Executor *executor)
 

Function Documentation

◆ get_bucketized_hash_entry_info()

HashEntryInfo anonymous_namespace{JoinHashTable.cpp}::get_bucketized_hash_entry_info ( SQLTypeInfo const &  context_ti,
ExpressionRange const &  col_range,
bool const  is_bw_eq 
)

Definition at line 185 of file JoinHashTable.cpp.

References CHECK_EQ, CHECK_GT, SQLTypeInfoCore< TYPE_FACET_PACK >::get_type(), ExpressionRange::getBucket(), ExpressionRange::getIntMax(), ExpressionRange::getIntMin(), and kDATE.

Referenced by JoinHashTable::getHashJoinArgs(), JoinHashTable::getInstance(), JoinHashTable::initHashTableForDevice(), and JoinHashTable::initOneToManyHashTable().

187  {
188  using EmptyRangeSize = boost::optional<size_t>;
189  auto empty_range_check = [](ExpressionRange const& col_range,
190  bool const is_bw_eq) -> EmptyRangeSize {
191  if (col_range.getIntMin() > col_range.getIntMax()) {
192  CHECK_EQ(col_range.getIntMin(), int64_t(0));
193  CHECK_EQ(col_range.getIntMax(), int64_t(-1));
194  if (is_bw_eq) {
195  return size_t(1);
196  }
197  return size_t(0);
198  }
199  return EmptyRangeSize{};
200  };
201 
202  auto empty_range = empty_range_check(col_range, is_bw_eq);
203  if (empty_range) {
204  return {size_t(*empty_range), 1};
205  }
206 
207  int64_t bucket_normalization =
208  context_ti.get_type() == kDATE ? col_range.getBucket() : 1;
209  CHECK_GT(bucket_normalization, 0);
210  return {size_t(col_range.getIntMax() - col_range.getIntMin() + 1 + (is_bw_eq ? 1 : 0)),
211  bucket_normalization};
212 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
int64_t getBucket() const
int64_t getIntMax() const
#define CHECK_GT(x, y)
Definition: Logger.h:199
int64_t getIntMin() const
Definition: sqltypes.h:55
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_cols()

std::pair<const Analyzer::ColumnVar*, const Analyzer::Expr*> anonymous_namespace{JoinHashTable.cpp}::get_cols ( const Analyzer::BinOper qual_bin_oper,
const Catalog_Namespace::Catalog cat,
const TemporaryTables temporary_tables 
)

Definition at line 176 of file JoinHashTable.cpp.

References Analyzer::BinOper::get_left_operand(), Analyzer::BinOper::get_right_operand(), and normalize_column_pair().

Referenced by JoinHashTable::codegenMatchingSet(), JoinHashTable::codegenSlot(), get_shard_count(), JoinHashTable::getInstance(), JoinHashTable::reify(), JoinHashTable::reifyOneToManyForDevice(), and JoinHashTable::reifyOneToOneForDevice().

179  {
180  const auto lhs = qual_bin_oper->get_left_operand();
181  const auto rhs = qual_bin_oper->get_right_operand();
182  return normalize_column_pair(lhs, rhs, cat, temporary_tables);
183 }
InnerOuter normalize_column_pair(const Analyzer::Expr *lhs, const Analyzer::Expr *rhs, const Catalog_Namespace::Catalog &cat, const TemporaryTables *temporary_tables, const bool is_overlaps_join)
const Expr * get_right_operand() const
Definition: Analyzer.h:436
const Expr * get_left_operand() const
Definition: Analyzer.h:435
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_hash_entry_count()

size_t anonymous_namespace{JoinHashTable.cpp}::get_hash_entry_count ( const ExpressionRange col_range,
const bool  is_bw_eq 
)

Definition at line 214 of file JoinHashTable.cpp.

References CHECK_EQ, ExpressionRange::getIntMax(), ExpressionRange::getIntMin(), JoinHashTable::join_hash_table_cache_, and JoinHashTable::join_hash_table_cache_mutex_.

Referenced by JoinHashTable::getHashJoinArgs().

214  {
215  if (col_range.getIntMin() > col_range.getIntMax()) {
216  CHECK_EQ(col_range.getIntMin(), int64_t(0));
217  CHECK_EQ(col_range.getIntMax(), int64_t(-1));
218  return is_bw_eq ? 1 : 0;
219  }
220  return col_range.getIntMax() - col_range.getIntMin() + 1 + (is_bw_eq ? 1 : 0);
221 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
int64_t getIntMax() const
int64_t getIntMin() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ shard_count_less_or_equal_device_count()

bool anonymous_namespace{JoinHashTable.cpp}::shard_count_less_or_equal_device_count ( const int  inner_table_id,
const Executor executor 
)

Definition at line 249 of file JoinHashTable.cpp.

Referenced by get_shard_count().

250  {
251  const auto inner_table_info = executor->getTableInfo(inner_table_id);
252  std::unordered_set<int> device_holding_fragments;
253  auto cuda_mgr = executor->getCatalog()->getDataMgr().getCudaMgr();
254  const int device_count = cuda_mgr ? cuda_mgr->getDeviceCount() : 1;
255  for (const auto& fragment : inner_table_info.fragments) {
256  if (fragment.shard != -1) {
257  const auto it_ok = device_holding_fragments.emplace(fragment.shard % device_count);
258  if (!it_ok.second) {
259  return false;
260  }
261  }
262  }
263  return true;
264 }
+ Here is the caller graph for this function: