OmniSciDB  6686921089
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HashJoin.h File Reference
+ Include dependency graph for HashJoin.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  TooManyHashEntries
 
class  TableMustBeReplicated
 
class  HashJoinFail
 
class  NeedsOneToManyHash
 
class  FailedToFetchColumn
 
class  FailedToJoinOnVirtualColumn
 
class  OverlapsHashTableTooBig
 
struct  ColumnsForDevice
 
struct  HashJoinMatchingSet
 
struct  CompositeKeyInfo
 
class  HashJoin
 

Typedefs

using InnerOuter = std::pair< const Analyzer::ColumnVar *, const Analyzer::Expr * >
 

Functions

std::ostream & operator<< (std::ostream &os, const DecodedJoinHashBufferEntry &e)
 
std::ostream & operator<< (std::ostream &os, const DecodedJoinHashBufferSet &s)
 
std::shared_ptr
< Analyzer::ColumnVar
getSyntheticColumnVar (std::string_view table, std::string_view column, int rte_idx, Executor *executor)
 
size_t get_shard_count (const Analyzer::BinOper *join_condition, const Executor *executor)
 
size_t get_shard_count (std::pair< const Analyzer::ColumnVar *, const Analyzer::Expr * > equi_pair, const Executor *executor)
 

Typedef Documentation

Definition at line 77 of file HashJoin.h.

Function Documentation

size_t get_shard_count ( const Analyzer::BinOper join_condition,
const Executor executor 
)

Definition at line 790 of file HashJoin.cpp.

References anonymous_namespace{HashJoin.cpp}::get_cols(), and get_shard_count().

Referenced by get_shard_count(), BaselineJoinHashTable::getShardCountForCondition(), PerfectJoinHashTable::reify(), PerfectJoinHashTable::shardCount(), and Executor::skipFragmentPair().

791  {
792  const Analyzer::ColumnVar* inner_col{nullptr};
793  const Analyzer::Expr* outer_col{nullptr};
794  std::shared_ptr<Analyzer::BinOper> redirected_bin_oper;
795  try {
796  std::tie(inner_col, outer_col) =
797  get_cols(join_condition, *executor->getCatalog(), executor->getTemporaryTables());
798  } catch (...) {
799  return 0;
800  }
801  if (!inner_col || !outer_col) {
802  return 0;
803  }
804  return get_shard_count({inner_col, outer_col}, executor);
805 }
size_t get_shard_count(const Analyzer::BinOper *join_condition, const Executor *executor)
Definition: HashJoin.cpp:790
InnerOuter get_cols(const Analyzer::BinOper *qual_bin_oper, const Catalog_Namespace::Catalog &cat, const TemporaryTables *temporary_tables)
Definition: HashJoin.cpp:780

+ Here is the call graph for this function:

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

std::shared_ptr<Analyzer::ColumnVar> getSyntheticColumnVar ( std::string_view  table,
std::string_view  column,
int  rte_idx,
Executor executor 
)

Definition at line 371 of file HashJoin.cpp.

References CHECK, kLINESTRING, kMULTIPOLYGON, kPOINT, and kPOLYGON.

Referenced by HashJoin::getSyntheticInstance().

374  {
375  auto catalog = executor->getCatalog();
376  CHECK(catalog);
377 
378  auto tmeta = catalog->getMetadataForTable(std::string(table));
379  CHECK(tmeta);
380 
381  auto cmeta = catalog->getMetadataForColumn(tmeta->tableId, std::string(column));
382  CHECK(cmeta);
383 
384  auto ti = cmeta->columnType;
385 
386  if (ti.is_geometry() && ti.get_type() != kPOINT) {
387  int geoColumnId{0};
388  switch (ti.get_type()) {
389  case kLINESTRING: {
390  geoColumnId = cmeta->columnId + 2;
391  break;
392  }
393  case kPOLYGON: {
394  geoColumnId = cmeta->columnId + 3;
395  break;
396  }
397  case kMULTIPOLYGON: {
398  geoColumnId = cmeta->columnId + 4;
399  break;
400  }
401  default:
402  CHECK(false);
403  }
404  cmeta = catalog->getMetadataForColumn(tmeta->tableId, geoColumnId);
405  CHECK(cmeta);
406  ti = cmeta->columnType;
407  }
408 
409  auto cv =
410  std::make_shared<Analyzer::ColumnVar>(ti, tmeta->tableId, cmeta->columnId, rte_idx);
411  return cv;
412 }
#define CHECK(condition)
Definition: Logger.h:209

+ Here is the caller graph for this function:

std::ostream& operator<< ( std::ostream &  os,
const DecodedJoinHashBufferEntry e 
)

Definition at line 122 of file HashJoin.cpp.

References DecodedJoinHashBufferEntry::key, and DecodedJoinHashBufferEntry::payload.

122  {
123  os << " {{";
124  bool first = true;
125  for (auto k : e.key) {
126  if (!first) {
127  os << ",";
128  } else {
129  first = false;
130  }
131  os << k;
132  }
133  os << "}, ";
134  os << "{";
135  first = true;
136  for (auto p : e.payload) {
137  if (!first) {
138  os << ", ";
139  } else {
140  first = false;
141  }
142  os << p;
143  }
144  os << "}}";
145  return os;
146 }
std::set< int32_t > payload
Definition: HashTable.h:23
std::vector< int64_t > key
Definition: HashTable.h:22
std::ostream& operator<< ( std::ostream &  os,
const DecodedJoinHashBufferSet s 
)

Definition at line 148 of file HashJoin.cpp.

148  {
149  os << "{\n";
150  bool first = true;
151  for (auto e : s) {
152  if (!first) {
153  os << ",\n";
154  } else {
155  first = false;
156  }
157  os << e;
158  }
159  if (!s.empty()) {
160  os << "\n";
161  }
162  os << "}\n";
163  return os;
164 }