OmniSciDB  72c90bc290
 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  JoinHashTableTooBig
 
class  TooManyHashEntries
 
class  TableMustBeReplicated
 
class  HashJoinFail
 
class  NeedsOneToManyHash
 
class  FailedToFetchColumn
 
class  FailedToJoinOnVirtualColumn
 
class  TooBigHashTableForBoundingBoxIntersect
 
struct  ColumnsForDevice
 
struct  HashJoinMatchingSet
 
struct  CompositeKeyInfo
 
class  HashJoin
 

Typedefs

using InnerOuter = std::pair< const Analyzer::ColumnVar *, const Analyzer::Expr * >
 
using InnerOuterStringOpInfos = std::pair< std::vector< StringOps_Namespace::StringOpInfo >, std::vector< StringOps_Namespace::StringOpInfo >>
 

Enumerations

enum  InnerQualDecision { InnerQualDecision::IGNORE = 0, InnerQualDecision::UNKNOWN, InnerQualDecision::LHS, InnerQualDecision::RHS }
 

Functions

std::ostream & operator<< (std::ostream &os, InnerQualDecision const decision)
 
std::ostream & operator<< (std::ostream &os, const DecodedJoinHashBufferEntry &e)
 
std::ostream & operator<< (std::ostream &os, const DecodedJoinHashBufferSet &s)
 
std::ostream & operator<< (std::ostream &os, const InnerOuterStringOpInfos &inner_outer_string_op_infos)
 
std::ostream & operator<< (std::ostream &os, const std::vector< InnerOuterStringOpInfos > &inner_outer_string_op_infos_pairs)
 
std::string toString (const InnerOuterStringOpInfos &inner_outer_string_op_infos)
 
std::string toString (const std::vector< InnerOuterStringOpInfos > &inner_outer_string_op_infos_pairs)
 
std::shared_ptr
< Analyzer::ColumnVar
getSyntheticColumnVar (std::string_view table, std::string_view column, int rte_idx, const Catalog_Namespace::Catalog &catalog)
 
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

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

Definition at line 105 of file HashJoin.h.

Definition at line 107 of file HashJoin.h.

Enumeration Type Documentation

enum InnerQualDecision
strong
Enumerator
IGNORE 
UNKNOWN 
LHS 
RHS 

Definition at line 61 of file HashJoin.h.

Function Documentation

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

Definition at line 1084 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().

1085  {
1086  const Analyzer::ColumnVar* inner_col{nullptr};
1087  const Analyzer::Expr* outer_col{nullptr};
1088  std::shared_ptr<Analyzer::BinOper> redirected_bin_oper;
1089  try {
1090  std::tie(inner_col, outer_col) =
1091  get_cols(join_condition, executor->getTemporaryTables());
1092  } catch (...) {
1093  return 0;
1094  }
1095  if (!inner_col || !outer_col) {
1096  return 0;
1097  }
1098  return get_shard_count({inner_col, outer_col}, executor);
1099 }
InnerOuter get_cols(const Analyzer::BinOper *qual_bin_oper, const TemporaryTables *temporary_tables)
Definition: HashJoin.cpp:1075
size_t get_shard_count(const Analyzer::BinOper *join_condition, const Executor *executor)
Definition: HashJoin.cpp:1084

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

std::shared_ptr<Analyzer::ColumnVar> getSyntheticColumnVar ( std::string_view  table,
std::string_view  column,
int  rte_idx,
const Catalog_Namespace::Catalog catalog 
)

Definition at line 580 of file HashJoin.cpp.

References CHECK, Catalog_Namespace::Catalog::getDatabaseId(), Catalog_Namespace::Catalog::getMetadataForColumn(), Catalog_Namespace::Catalog::getMetadataForTable(), kLINESTRING, kMULTIPOLYGON, kPOINT, and kPOLYGON.

Referenced by HashJoin::getSyntheticInstance().

584  {
585  auto tmeta = catalog.getMetadataForTable(std::string(table));
586  CHECK(tmeta);
587 
588  auto cmeta = catalog.getMetadataForColumn(tmeta->tableId, std::string(column));
589  CHECK(cmeta);
590 
591  auto ti = cmeta->columnType;
592 
593  if (ti.is_geometry() && ti.get_type() != kPOINT) {
594  int geoColumnId{0};
595  switch (ti.get_type()) {
596  case kLINESTRING: {
597  geoColumnId = cmeta->columnId + 2;
598  break;
599  }
600  case kPOLYGON: {
601  geoColumnId = cmeta->columnId + 3;
602  break;
603  }
604  case kMULTIPOLYGON: {
605  geoColumnId = cmeta->columnId + 4;
606  break;
607  }
608  default:
609  CHECK(false);
610  }
611  cmeta = catalog.getMetadataForColumn(tmeta->tableId, geoColumnId);
612  CHECK(cmeta);
613  ti = cmeta->columnType;
614  }
615 
616  auto cv = std::make_shared<Analyzer::ColumnVar>(
617  ti,
618  shared::ColumnKey{catalog.getDatabaseId(), tmeta->tableId, cmeta->columnId},
619  rte_idx);
620  return cv;
621 }
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
int getDatabaseId() const
Definition: Catalog.h:326
#define CHECK(condition)
Definition: Logger.h:291
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::ostream& operator<< ( std::ostream &  os,
InnerQualDecision const  decision 
)
inline

Definition at line 64 of file HashJoin.h.

64  {
65  constexpr char const* strings[]{"IGNORE", "UNKNOWN", "LHS", "RHS"};
66  return os << strings[static_cast<int>(decision)];
67 }
std::ostream& operator<< ( std::ostream &  os,
const DecodedJoinHashBufferEntry e 
)

Definition at line 128 of file HashJoin.cpp.

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

128  {
129  os << " {{";
130  bool first = true;
131  for (auto k : e.key) {
132  if (!first) {
133  os << ",";
134  } else {
135  first = false;
136  }
137  os << k;
138  }
139  os << "}, ";
140  os << "{";
141  first = true;
142  for (auto p : e.payload) {
143  if (!first) {
144  os << ", ";
145  } else {
146  first = false;
147  }
148  os << p;
149  }
150  os << "}}";
151  return os;
152 }
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 154 of file HashJoin.cpp.

154  {
155  os << "{\n";
156  bool first = true;
157  for (auto e : s) {
158  if (!first) {
159  os << ",\n";
160  } else {
161  first = false;
162  }
163  os << e;
164  }
165  if (!s.empty()) {
166  os << "\n";
167  }
168  os << "}\n";
169  return os;
170 }
std::ostream& operator<< ( std::ostream &  os,
const InnerOuterStringOpInfos inner_outer_string_op_infos 
)

Definition at line 172 of file HashJoin.cpp.

173  {
174  os << "(" << inner_outer_string_op_infos.first << ", "
175  << inner_outer_string_op_infos.second << ")";
176  return os;
177 }
std::ostream& operator<< ( std::ostream &  os,
const std::vector< InnerOuterStringOpInfos > &  inner_outer_string_op_infos_pairs 
)

Definition at line 185 of file HashJoin.cpp.

187  {
188  os << "[";
189  bool first_elem = true;
190  for (const auto& inner_outer_string_op_infos : inner_outer_string_op_infos_pairs) {
191  if (!first_elem) {
192  os << ", ";
193  }
194  first_elem = false;
195  os << inner_outer_string_op_infos;
196  }
197  os << "]";
198  return os;
199 }
std::string toString ( const InnerOuterStringOpInfos inner_outer_string_op_infos)

Definition at line 179 of file HashJoin.cpp.

179  {
180  std::ostringstream os;
181  os << inner_outer_string_op_infos;
182  return os.str();
183 }
std::string toString ( const std::vector< InnerOuterStringOpInfos > &  inner_outer_string_op_infos_pairs)

Definition at line 201 of file HashJoin.cpp.

202  {
203  std::ostringstream os;
204  os << inner_outer_string_op_infos_pairs;
205  return os.str();
206 }