OmniSciDB  dfae7c3b14
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 219 of file JoinHashTable.cpp.

References CHECK_EQ, CHECK_GT, SQLTypeInfo::get_type(), ExpressionRange::getBucket(), ExpressionRange::getIntMax(), ExpressionRange::getIntMin(), and kDATE.

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

221  {
222  using EmptyRangeSize = boost::optional<size_t>;
223  auto empty_range_check = [](ExpressionRange const& col_range,
224  bool const is_bw_eq) -> EmptyRangeSize {
225  if (col_range.getIntMin() > col_range.getIntMax()) {
226  CHECK_EQ(col_range.getIntMin(), int64_t(0));
227  CHECK_EQ(col_range.getIntMax(), int64_t(-1));
228  if (is_bw_eq) {
229  return size_t(1);
230  }
231  return size_t(0);
232  }
233  return EmptyRangeSize{};
234  };
235 
236  auto empty_range = empty_range_check(col_range, is_bw_eq);
237  if (empty_range) {
238  return {size_t(*empty_range), 1};
239  }
240 
241  int64_t bucket_normalization =
242  context_ti.get_type() == kDATE ? col_range.getBucket() : 1;
243  CHECK_GT(bucket_normalization, 0);
244  return {size_t(col_range.getIntMax() - col_range.getIntMin() + 1 + (is_bw_eq ? 1 : 0)),
245  bucket_normalization};
246 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
int64_t getBucket() const
int64_t getIntMax() const
#define CHECK_GT(x, y)
Definition: Logger.h:209
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 210 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().

213  {
214  const auto lhs = qual_bin_oper->get_left_operand();
215  const auto rhs = qual_bin_oper->get_right_operand();
216  return normalize_column_pair(lhs, rhs, cat, temporary_tables);
217 }
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:443
const Expr * get_left_operand() const
Definition: Analyzer.h:442
+ 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 248 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().

248  {
249  if (col_range.getIntMin() > col_range.getIntMax()) {
250  CHECK_EQ(col_range.getIntMin(), int64_t(0));
251  CHECK_EQ(col_range.getIntMax(), int64_t(-1));
252  return is_bw_eq ? 1 : 0;
253  }
254  return col_range.getIntMax() - col_range.getIntMin() + 1 + (is_bw_eq ? 1 : 0);
255 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
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 283 of file JoinHashTable.cpp.

Referenced by get_shard_count().

284  {
285  const auto inner_table_info = executor->getTableInfo(inner_table_id);
286  std::unordered_set<int> device_holding_fragments;
287  auto cuda_mgr = executor->getCatalog()->getDataMgr().getCudaMgr();
288  const int device_count = cuda_mgr ? cuda_mgr->getDeviceCount() : 1;
289  for (const auto& fragment : inner_table_info.fragments) {
290  if (fragment.shard != -1) {
291  const auto it_ok = device_holding_fragments.emplace(fragment.shard % device_count);
292  if (!it_ok.second) {
293  return false;
294  }
295  }
296  }
297  return true;
298 }
+ Here is the caller graph for this function: