OmniSciDB  085a039ca4
 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

std::pair< InnerOuter,
InnerOuterStringOpInfos
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 InnerOuter &inner_outer_col_pair, const InnerOuterStringOpInfos &inner_outer_string_op_infos, 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 1254 of file PerfectJoinHashTable.cpp.

References CHECK_GT, and Data_Namespace::GPU_LEVEL.

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

1257  {
1258  const auto entries_per_shard =
1259  shard_count ? (total_entries + shard_count - 1) / shard_count : total_entries;
1260  size_t entries_per_device = entries_per_shard;
1261  if (memory_level == Data_Namespace::GPU_LEVEL && shard_count) {
1262  const auto shards_per_device = (shard_count + device_count - 1) / device_count;
1263  CHECK_GT(shards_per_device, 0u);
1264  entries_per_device = entries_per_shard * shards_per_device;
1265  }
1266  return entries_per_device;
1267 }
#define CHECK_GT(x, y)
Definition: Logger.h:235

+ 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 1240 of file PerfectJoinHashTable.cpp.

References CHECK.

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

1242  {
1243  std::optional<size_t> ti_idx;
1244  for (size_t i = 0; i < query_infos.size(); ++i) {
1245  if (inner_table_id == query_infos[i].table_id) {
1246  ti_idx = i;
1247  break;
1248  }
1249  }
1250  CHECK(ti_idx);
1251  return query_infos[*ti_idx];
1252 }
#define CHECK(condition)
Definition: Logger.h:223

+ 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:223

+ Here is the call graph for this function:

bool needs_dictionary_translation ( const InnerOuter inner_outer_col_pair,
const InnerOuterStringOpInfos inner_outer_string_op_infos,
const Executor executor 
)

Definition at line 267 of file PerfectJoinHashTable.cpp.

References CHECK, CHECK_EQ, get_column_descriptor_maybe(), and get_column_type().

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

+ Here is the call 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 316 of file PerfectJoinHashTable.cpp.

References CHECK_GE.

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

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

+ Here is the caller graph for this function: