OmniSciDB  085a039ca4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HashJoin.cpp File Reference
+ Include dependency graph for HashJoin.cpp:

Go to the source code of this file.

Classes

class  AllColumnVarsVisitor
 

Namespaces

 anonymous_namespace{HashJoin.cpp}
 

Functions

template<typename T >
std::string anonymous_namespace{HashJoin.cpp}::toStringFlat (const HashJoin *hash_table, const ExecutorDeviceType device_type, const int device_id)
 
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::string toString (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 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, Executor *executor)
 
void setupSyntheticCaching (std::set< const Analyzer::ColumnVar * > cvs, Executor *executor)
 
std::vector< InputTableInfogetSyntheticInputTableInfo (std::set< const Analyzer::ColumnVar * > cvs, Executor *executor)
 
InnerOuter anonymous_namespace{HashJoin.cpp}::get_cols (const Analyzer::BinOper *qual_bin_oper, const Catalog_Namespace::Catalog &cat, const TemporaryTables *temporary_tables)
 
size_t get_shard_count (const Analyzer::BinOper *join_condition, const Executor *executor)
 

Variables

bool g_enable_overlaps_hashjoin
 

Function Documentation

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

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

1046  {
1047  const Analyzer::ColumnVar* inner_col{nullptr};
1048  const Analyzer::Expr* outer_col{nullptr};
1049  std::shared_ptr<Analyzer::BinOper> redirected_bin_oper;
1050  try {
1051  std::tie(inner_col, outer_col) =
1052  get_cols(join_condition, *executor->getCatalog(), executor->getTemporaryTables());
1053  } catch (...) {
1054  return 0;
1055  }
1056  if (!inner_col || !outer_col) {
1057  return 0;
1058  }
1059  return get_shard_count({inner_col, outer_col}, executor);
1060 }
size_t get_shard_count(const Analyzer::BinOper *join_condition, const Executor *executor)
Definition: HashJoin.cpp:1045
InnerOuter get_cols(const Analyzer::BinOper *qual_bin_oper, const Catalog_Namespace::Catalog &cat, const TemporaryTables *temporary_tables)
Definition: HashJoin.cpp:1035

+ Here is the call graph for this function:

+ Here is the caller 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 555 of file HashJoin.cpp.

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

Referenced by HashJoin::getSyntheticInstance().

558  {
559  auto catalog = executor->getCatalog();
560  CHECK(catalog);
561 
562  auto tmeta = catalog->getMetadataForTable(std::string(table));
563  CHECK(tmeta);
564 
565  auto cmeta = catalog->getMetadataForColumn(tmeta->tableId, std::string(column));
566  CHECK(cmeta);
567 
568  auto ti = cmeta->columnType;
569 
570  if (ti.is_geometry() && ti.get_type() != kPOINT) {
571  int geoColumnId{0};
572  switch (ti.get_type()) {
573  case kLINESTRING: {
574  geoColumnId = cmeta->columnId + 2;
575  break;
576  }
577  case kPOLYGON: {
578  geoColumnId = cmeta->columnId + 3;
579  break;
580  }
581  case kMULTIPOLYGON: {
582  geoColumnId = cmeta->columnId + 4;
583  break;
584  }
585  default:
586  CHECK(false);
587  }
588  cmeta = catalog->getMetadataForColumn(tmeta->tableId, geoColumnId);
589  CHECK(cmeta);
590  ti = cmeta->columnType;
591  }
592 
593  auto cv =
594  std::make_shared<Analyzer::ColumnVar>(ti, tmeta->tableId, cmeta->columnId, rte_idx);
595  return cv;
596 }
#define CHECK(condition)
Definition: Logger.h:223

+ Here is the caller graph for this function:

std::vector<InputTableInfo> getSyntheticInputTableInfo ( std::set< const Analyzer::ColumnVar * >  cvs,
Executor executor 
)

Definition at line 640 of file HashJoin.cpp.

References CHECK.

Referenced by HashJoin::getSyntheticInstance().

642  {
643  auto catalog = executor->getCatalog();
644  CHECK(catalog);
645 
646  std::unordered_set<int> phys_table_ids;
647  for (auto cv : cvs) {
648  phys_table_ids.insert(cv->get_table_id());
649  }
650 
651  // NOTE(sy): This vector ordering seems to work for now, but maybe we need to
652  // review how rte_idx is assigned for ColumnVars. See for example Analyzer.h
653  // and RelAlgExecutor.cpp and rte_idx there.
654  std::vector<InputTableInfo> query_infos(phys_table_ids.size());
655  size_t i = 0;
656  for (auto id : phys_table_ids) {
657  auto tmeta = catalog->getMetadataForTable(id);
658  query_infos[i].table_id = id;
659  query_infos[i].info = tmeta->fragmenter->getFragmentsForQuery();
660  ++i;
661  }
662 
663  return query_infos;
664 }
#define CHECK(condition)
Definition: Logger.h:223

+ Here is the caller graph for this function:

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

Definition at line 126 of file HashJoin.cpp.

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

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

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

Definition at line 170 of file HashJoin.cpp.

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

Definition at line 183 of file HashJoin.cpp.

185  {
186  os << "[";
187  bool first_elem = true;
188  for (const auto& inner_outer_string_op_infos : inner_outer_string_op_infos_pairs) {
189  if (!first_elem) {
190  os << ", ";
191  }
192  first_elem = false;
193  os << inner_outer_string_op_infos;
194  }
195  os << "]";
196  return os;
197 }
void setupSyntheticCaching ( std::set< const Analyzer::ColumnVar * >  cvs,
Executor executor 
)

Definition at line 626 of file HashJoin.cpp.

Referenced by HashJoin::getSyntheticInstance().

626  {
627  std::unordered_set<int> phys_table_ids;
628  for (auto cv : cvs) {
629  phys_table_ids.insert(cv->get_table_id());
630  }
631 
632  std::unordered_set<PhysicalInput> phys_inputs;
633  for (auto cv : cvs) {
634  phys_inputs.emplace(PhysicalInput{cv->get_column_id(), cv->get_table_id()});
635  }
636 
637  executor->setupCaching(phys_inputs, phys_table_ids);
638 }

+ Here is the caller graph for this function:

std::string toString ( const InnerOuterStringOpInfos inner_outer_string_op_infos)

Definition at line 177 of file HashJoin.cpp.

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

Definition at line 199 of file HashJoin.cpp.

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

Variable Documentation

bool g_enable_overlaps_hashjoin

Definition at line 102 of file Execute.cpp.