OmniSciDB  471d68cefb
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PerfectJoinHashTable.cpp File Reference
+ Include dependency graph for PerfectJoinHashTable.cpp:

Go to the source code of this file.

Namespaces

 anonymous_namespace{PerfectJoinHashTable.cpp}
 

Functions

InnerOuter anonymous_namespace{PerfectJoinHashTable.cpp}::get_cols (const Analyzer::BinOper *qual_bin_oper, const Catalog_Namespace::Catalog &cat, const TemporaryTables *temporary_tables)
 
HashEntryInfo anonymous_namespace{PerfectJoinHashTable.cpp}::get_bucketized_hash_entry_info (SQLTypeInfo const &context_ti, ExpressionRange const &col_range, bool const is_bw_eq)
 
size_t anonymous_namespace{PerfectJoinHashTable.cpp}::get_hash_entry_count (const ExpressionRange &col_range, const bool is_bw_eq)
 
bool anonymous_namespace{PerfectJoinHashTable.cpp}::shard_count_less_or_equal_device_count (const int inner_table_id, const Executor *executor)
 
size_t get_shard_count (std::pair< const Analyzer::ColumnVar *, const Analyzer::Expr * > equi_pair, const Executor *executor)
 
bool needs_dictionary_translation (const Analyzer::ColumnVar *inner_col, const Analyzer::Expr *outer_col_expr, const Executor *executor)
 
std::vector
< Fragmenter_Namespace::FragmentInfo
only_shards_for_device (const std::vector< Fragmenter_Namespace::FragmentInfo > &fragments, const int device_id, const int device_count)
 
const InputTableInfoget_inner_query_info (const int inner_table_id, const std::vector< InputTableInfo > &query_infos)
 
size_t get_entries_per_device (const size_t total_entries, const size_t shard_count, const size_t device_count, const Data_Namespace::MemoryLevel memory_level)
 

Function Documentation

size_t get_entries_per_device ( const size_t  total_entries,
const size_t  shard_count,
const size_t  device_count,
const Data_Namespace::MemoryLevel  memory_level 
)

Definition at line 1037 of file PerfectJoinHashTable.cpp.

References CHECK_GT, and Data_Namespace::GPU_LEVEL.

Referenced by OverlapsJoinHashTable::computeHashTableCounts(), RangeJoinHashTable::computeRangeHashTableCounts(), and BaselineJoinHashTable::reifyWithLayout().

1040  {
1041  const auto entries_per_shard =
1042  shard_count ? (total_entries + shard_count - 1) / shard_count : total_entries;
1043  size_t entries_per_device = entries_per_shard;
1044  if (memory_level == Data_Namespace::GPU_LEVEL && shard_count) {
1045  const auto shards_per_device = (shard_count + device_count - 1) / device_count;
1046  CHECK_GT(shards_per_device, 0u);
1047  entries_per_device = entries_per_shard * shards_per_device;
1048  }
1049  return entries_per_device;
1050 }
#define CHECK_GT(x, y)
Definition: Logger.h:221

+ Here is the caller graph for this function:

const InputTableInfo& get_inner_query_info ( const int  inner_table_id,
const std::vector< InputTableInfo > &  query_infos 
)

Definition at line 1023 of file PerfectJoinHashTable.cpp.

References CHECK, and i.

Referenced by PerfectJoinHashTable::getInnerQueryInfo(), RangeJoinHashTable::getInstance(), OverlapsJoinHashTable::getInstance(), RangeJoinHashTable::reifyWithLayout(), OverlapsJoinHashTable::reifyWithLayout(), and BaselineJoinHashTable::reifyWithLayout().

1025  {
1026  std::optional<size_t> ti_idx;
1027  for (size_t i = 0; i < query_infos.size(); ++i) {
1028  if (inner_table_id == query_infos[i].table_id) {
1029  ti_idx = i;
1030  break;
1031  }
1032  }
1033  CHECK(ti_idx);
1034  return query_infos[*ti_idx];
1035 }
#define CHECK(condition)
Definition: Logger.h:209

+ Here is the caller graph for this function:

size_t get_shard_count ( std::pair< const Analyzer::ColumnVar *, const Analyzer::Expr * >  equi_pair,
const Executor executor 
)

Definition at line 111 of file PerfectJoinHashTable.cpp.

References CHECK, and anonymous_namespace{PerfectJoinHashTable.cpp}::shard_count_less_or_equal_device_count().

113  {
114  const auto inner_col = equi_pair.first;
115  const auto outer_col = dynamic_cast<const Analyzer::ColumnVar*>(equi_pair.second);
116  if (!outer_col || inner_col->get_table_id() < 0 || outer_col->get_table_id() < 0) {
117  return 0;
118  }
119  if (outer_col->get_rte_idx()) {
120  return 0;
121  }
122  if (inner_col->get_type_info() != outer_col->get_type_info()) {
123  return 0;
124  }
125  const auto catalog = executor->getCatalog();
126  const auto inner_td = catalog->getMetadataForTable(inner_col->get_table_id());
127  CHECK(inner_td);
128  const auto outer_td = catalog->getMetadataForTable(outer_col->get_table_id());
129  CHECK(outer_td);
130  if (inner_td->shardedColumnId == 0 || outer_td->shardedColumnId == 0 ||
131  inner_td->nShards != outer_td->nShards) {
132  return 0;
133  }
134  if (!shard_count_less_or_equal_device_count(inner_td->tableId, executor)) {
135  return 0;
136  }
137  // The two columns involved must be the ones on which the tables have been sharded on.
138  return (inner_td->shardedColumnId == inner_col->get_column_id() &&
139  outer_td->shardedColumnId == outer_col->get_column_id()) ||
140  (outer_td->shardedColumnId == inner_col->get_column_id() &&
141  inner_td->shardedColumnId == inner_col->get_column_id())
142  ? inner_td->nShards
143  : 0;
144 }
bool shard_count_less_or_equal_device_count(const int inner_table_id, const Executor *executor)
#define CHECK(condition)
Definition: Logger.h:209

+ Here is the call graph for this function:

bool needs_dictionary_translation ( const Analyzer::ColumnVar inner_col,
const Analyzer::Expr outer_col_expr,
const Executor executor 
)

Definition at line 270 of file PerfectJoinHashTable.cpp.

References CHECK, CHECK_EQ, get_column_descriptor_maybe(), Analyzer::ColumnVar::get_column_id(), get_column_type(), Analyzer::ColumnVar::get_comp_param(), and Analyzer::ColumnVar::get_table_id().

Referenced by PerfectJoinHashTable::getEffectiveMemoryLevel(), and BaselineJoinHashTable::getEffectiveMemoryLevel().

272  {
273  const auto catalog = executor->getCatalog();
274  CHECK(catalog);
275  const auto inner_cd = get_column_descriptor_maybe(
276  inner_col->get_column_id(), inner_col->get_table_id(), *catalog);
277  const auto& inner_ti = get_column_type(inner_col->get_column_id(),
278  inner_col->get_table_id(),
279  inner_cd,
280  executor->getTemporaryTables());
281  // Only strings may need dictionary translation.
282  if (!inner_ti.is_string()) {
283  return false;
284  }
285  const auto outer_col = dynamic_cast<const Analyzer::ColumnVar*>(outer_col_expr);
286  CHECK(outer_col);
287  const auto outer_cd = get_column_descriptor_maybe(
288  outer_col->get_column_id(), outer_col->get_table_id(), *catalog);
289  // Don't want to deal with temporary tables for now, require translation.
290  if (!inner_cd || !outer_cd) {
291  return true;
292  }
293  const auto& outer_ti = get_column_type(outer_col->get_column_id(),
294  outer_col->get_table_id(),
295  outer_cd,
296  executor->getTemporaryTables());
297  CHECK_EQ(inner_ti.is_string(), outer_ti.is_string());
298  // If the two columns don't share the dictionary, translation is needed.
299  if (outer_ti.get_comp_param() != inner_ti.get_comp_param()) {
300  return true;
301  }
302  const auto inner_str_dict_proxy =
303  executor->getStringDictionaryProxy(inner_col->get_comp_param(), true);
304  CHECK(inner_str_dict_proxy);
305  const auto outer_str_dict_proxy =
306  executor->getStringDictionaryProxy(inner_col->get_comp_param(), true);
307  CHECK(outer_str_dict_proxy);
308 
309  return *inner_str_dict_proxy != *outer_str_dict_proxy;
310 }
int get_table_id() const
Definition: Analyzer.h:193
#define CHECK_EQ(x, y)
Definition: Logger.h:217
const SQLTypeInfo get_column_type(const int col_id, const int table_id, const ColumnDescriptor *cd, const TemporaryTables *temporary_tables)
Definition: Execute.h:234
const ColumnDescriptor * get_column_descriptor_maybe(const int col_id, const int table_id, const Catalog_Namespace::Catalog &cat)
Definition: Execute.h:218
int get_comp_param() const
Definition: Analyzer.h:197
#define CHECK(condition)
Definition: Logger.h:209
int get_column_id() const
Definition: Analyzer.h:194

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector<Fragmenter_Namespace::FragmentInfo> only_shards_for_device ( const std::vector< Fragmenter_Namespace::FragmentInfo > &  fragments,
const int  device_id,
const int  device_count 
)

Definition at line 312 of file PerfectJoinHashTable.cpp.

References CHECK_GE.

Referenced by PerfectJoinHashTable::reify(), OverlapsJoinHashTable::reifyImpl(), RangeJoinHashTable::reifyWithLayout(), OverlapsJoinHashTable::reifyWithLayout(), and BaselineJoinHashTable::reifyWithLayout().

315  {
316  std::vector<Fragmenter_Namespace::FragmentInfo> shards_for_device;
317  for (const auto& fragment : fragments) {
318  CHECK_GE(fragment.shard, 0);
319  if (fragment.shard % device_count == device_id) {
320  shards_for_device.push_back(fragment);
321  }
322  }
323  return shards_for_device;
324 }
#define CHECK_GE(x, y)
Definition: Logger.h:222

+ Here is the caller graph for this function: