OmniSciDB  72c90bc290
 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 TemporaryTables *temporary_tables)
 
BucketizedHashEntryInfo 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 shared::TableKey &inner_table_key, const Executor *executor)
 
size_t get_shard_count (std::pair< const Analyzer::ColumnVar *, const Analyzer::Expr * > equi_pair, const Executor *executor)
 
const InputTableInfoget_inner_query_info (const shared::TableKey &inner_table_key, const std::vector< InputTableInfo > &query_infos)
 
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)
 
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)
 

Variables

bool g_is_test_env
 

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

References CHECK_GT, and Data_Namespace::GPU_LEVEL.

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

1298  {
1299  const auto entries_per_shard =
1300  shard_count ? (total_entries + shard_count - 1) / shard_count : total_entries;
1301  size_t entries_per_device = entries_per_shard;
1302  if (memory_level == Data_Namespace::GPU_LEVEL && shard_count) {
1303  const auto shards_per_device = (shard_count + device_count - 1) / device_count;
1304  CHECK_GT(shards_per_device, 0u);
1305  entries_per_device = entries_per_shard * shards_per_device;
1306  }
1307  return entries_per_device;
1308 }
#define CHECK_GT(x, y)
Definition: Logger.h:305

+ Here is the caller graph for this function:

const InputTableInfo& get_inner_query_info ( const shared::TableKey inner_table_key,
const std::vector< InputTableInfo > &  query_infos 
)

Definition at line 153 of file PerfectJoinHashTable.cpp.

References CHECK.

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

155  {
156  std::optional<size_t> ti_idx;
157  for (size_t i = 0; i < query_infos.size(); ++i) {
158  if (inner_table_key == query_infos[i].table_key) {
159  ti_idx = i;
160  break;
161  }
162  }
163  CHECK(ti_idx);
164  return query_infos[*ti_idx];
165 }
#define CHECK(condition)
Definition: Logger.h:291

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

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

117  {
118  const auto inner_col = equi_pair.first;
119  const auto outer_col = dynamic_cast<const Analyzer::ColumnVar*>(equi_pair.second);
120  if (!outer_col || inner_col->getColumnKey().table_id < 0 ||
121  outer_col->getColumnKey().table_id < 0) {
122  return 0;
123  }
124  if (outer_col->get_rte_idx()) {
125  return 0;
126  }
127  if (inner_col->get_type_info() != outer_col->get_type_info()) {
128  return 0;
129  }
130 
131  const auto inner_td =
132  Catalog_Namespace::get_metadata_for_table(inner_col->getTableKey());
133  CHECK(inner_td);
134  const auto outer_td =
135  Catalog_Namespace::get_metadata_for_table(outer_col->getTableKey());
136  CHECK(outer_td);
137  if (inner_td->shardedColumnId == 0 || outer_td->shardedColumnId == 0 ||
138  inner_td->nShards != outer_td->nShards) {
139  return 0;
140  }
141  if (!shard_count_less_or_equal_device_count(inner_col->getTableKey(), executor)) {
142  return 0;
143  }
144  // The two columns involved must be the ones on which the tables have been sharded on.
145  return (inner_td->shardedColumnId == inner_col->getColumnKey().column_id &&
146  outer_td->shardedColumnId == outer_col->getColumnKey().column_id) ||
147  (outer_td->shardedColumnId == inner_col->getColumnKey().column_id &&
148  inner_td->shardedColumnId == inner_col->getColumnKey().column_id)
149  ? inner_td->nShards
150  : 0;
151 }
const TableDescriptor * get_metadata_for_table(const ::shared::TableKey &table_key, bool populate_fragmenter)
bool shard_count_less_or_equal_device_count(const shared::TableKey &inner_table_key, const Executor *executor)
#define CHECK(condition)
Definition: Logger.h:291

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

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

318  {
319  if (inner_outer_string_op_infos.first.size() ||
320  inner_outer_string_op_infos.second.size()) {
321  return true;
322  }
323  auto inner_col = inner_outer_col_pair.first;
324  auto outer_col_expr = inner_outer_col_pair.second;
325  const auto inner_cd = get_column_descriptor_maybe(inner_col->getColumnKey());
326  const auto& inner_col_key = inner_col->getColumnKey();
327  const auto& inner_ti = get_column_type(inner_col_key.column_id,
328  inner_col_key.table_id,
329  inner_cd,
330  executor->getTemporaryTables());
331  // Only strings may need dictionary translation.
332  if (!inner_ti.is_string()) {
333  return false;
334  }
335  const auto outer_col = dynamic_cast<const Analyzer::ColumnVar*>(outer_col_expr);
336  CHECK(outer_col);
337  const auto outer_cd = get_column_descriptor_maybe(outer_col->getColumnKey());
338  // Don't want to deal with temporary tables for now, require translation.
339  if (!inner_cd || !outer_cd) {
340  return true;
341  }
342  const auto& outer_col_key = outer_col->getColumnKey();
343  const auto& outer_ti = get_column_type(outer_col_key.column_id,
344  outer_col_key.table_id,
345  outer_cd,
346  executor->getTemporaryTables());
347  CHECK_EQ(inner_ti.is_string(), outer_ti.is_string());
348  // If the two columns don't share the dictionary, translation is needed.
349  if (outer_ti.getStringDictKey() != inner_ti.getStringDictKey()) {
350  return true;
351  }
352  const auto inner_str_dict_proxy =
353  executor->getStringDictionaryProxy(inner_ti.getStringDictKey(), true);
354  CHECK(inner_str_dict_proxy);
355  const auto outer_str_dict_proxy =
356  executor->getStringDictionaryProxy(outer_ti.getStringDictKey(), true);
357  CHECK(outer_str_dict_proxy);
358 
359  return *inner_str_dict_proxy != *outer_str_dict_proxy;
360 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
const SQLTypeInfo get_column_type(const int col_id, const int table_id, const ColumnDescriptor *cd, const TemporaryTables *temporary_tables)
Definition: Execute.h:254
const ColumnDescriptor * get_column_descriptor_maybe(const shared::ColumnKey &column_key)
Definition: Execute.h:241
#define CHECK(condition)
Definition: Logger.h:291

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

References CHECK_GE.

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

365  {
366  std::vector<Fragmenter_Namespace::FragmentInfo> shards_for_device;
367  for (const auto& fragment : fragments) {
368  CHECK_GE(fragment.shard, 0);
369  if (fragment.shard % device_count == device_id) {
370  shards_for_device.push_back(fragment);
371  }
372  }
373  return shards_for_device;
374 }
#define CHECK_GE(x, y)
Definition: Logger.h:306

+ Here is the caller graph for this function:

Variable Documentation

bool g_is_test_env

Definition at line 149 of file Execute.cpp.