OmniSciDB  fe05a0c208
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 959 of file PerfectJoinHashTable.cpp.

References CHECK_GT, and Data_Namespace::GPU_LEVEL.

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

962  {
963  const auto entries_per_shard =
964  shard_count ? (total_entries + shard_count - 1) / shard_count : total_entries;
965  size_t entries_per_device = entries_per_shard;
966  if (memory_level == Data_Namespace::GPU_LEVEL && shard_count) {
967  const auto shards_per_device = (shard_count + device_count - 1) / device_count;
968  CHECK_GT(shards_per_device, 0u);
969  entries_per_device = entries_per_shard * shards_per_device;
970  }
971  return entries_per_device;
972 }
#define CHECK_GT(x, y)
Definition: Logger.h:215

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

References CHECK, and i.

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

947  {
948  std::optional<size_t> ti_idx;
949  for (size_t i = 0; i < query_infos.size(); ++i) {
950  if (inner_table_id == query_infos[i].table_id) {
951  ti_idx = i;
952  break;
953  }
954  }
955  CHECK(ti_idx);
956  return query_infos[*ti_idx];
957 }
#define CHECK(condition)
Definition: Logger.h:203

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

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

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

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

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

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

257  {
258  const auto catalog = executor->getCatalog();
259  CHECK(catalog);
260  const auto inner_cd = get_column_descriptor_maybe(
261  inner_col->get_column_id(), inner_col->get_table_id(), *catalog);
262  const auto& inner_ti = get_column_type(inner_col->get_column_id(),
263  inner_col->get_table_id(),
264  inner_cd,
265  executor->getTemporaryTables());
266  // Only strings may need dictionary translation.
267  if (!inner_ti.is_string()) {
268  return false;
269  }
270  const auto outer_col = dynamic_cast<const Analyzer::ColumnVar*>(outer_col_expr);
271  CHECK(outer_col);
272  const auto outer_cd = get_column_descriptor_maybe(
273  outer_col->get_column_id(), outer_col->get_table_id(), *catalog);
274  // Don't want to deal with temporary tables for now, require translation.
275  if (!inner_cd || !outer_cd) {
276  return true;
277  }
278  const auto& outer_ti = get_column_type(outer_col->get_column_id(),
279  outer_col->get_table_id(),
280  outer_cd,
281  executor->getTemporaryTables());
282  CHECK_EQ(inner_ti.is_string(), outer_ti.is_string());
283  // If the two columns don't share the dictionary, translation is needed.
284  return outer_ti.get_comp_param() != inner_ti.get_comp_param();
285 }
int get_table_id() const
Definition: Analyzer.h:194
#define CHECK_EQ(x, y)
Definition: Logger.h:211
const SQLTypeInfo get_column_type(const int col_id, const int table_id, const ColumnDescriptor *cd, const TemporaryTables *temporary_tables)
Definition: Execute.h:237
const ColumnDescriptor * get_column_descriptor_maybe(const int col_id, const int table_id, const Catalog_Namespace::Catalog &cat)
Definition: Execute.h:221
#define CHECK(condition)
Definition: Logger.h:203
int get_column_id() const
Definition: Analyzer.h:195

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

References CHECK_GE.

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

290  {
291  std::vector<Fragmenter_Namespace::FragmentInfo> shards_for_device;
292  for (const auto& fragment : fragments) {
293  CHECK_GE(fragment.shard, 0);
294  if (fragment.shard % device_count == device_id) {
295  shards_for_device.push_back(fragment);
296  }
297  }
298  return shards_for_device;
299 }
#define CHECK_GE(x, y)
Definition: Logger.h:216

+ Here is the caller graph for this function: