OmniSciDB  085a039ca4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RelJoin Class Reference

#include <RelAlgDagBuilder.h>

+ Inheritance diagram for RelJoin:
+ Collaboration diagram for RelJoin:

Public Member Functions

 RelJoin (std::shared_ptr< const RelAlgNode > lhs, std::shared_ptr< const RelAlgNode > rhs, std::unique_ptr< const RexScalar > &condition, const JoinType join_type)
 
 RelJoin (RelJoin const &)
 
JoinType getJoinType () const
 
const RexScalargetCondition () const
 
const RexScalargetAndReleaseCondition () const
 
void setCondition (std::unique_ptr< const RexScalar > &condition)
 
void replaceInput (std::shared_ptr< const RelAlgNode > old_input, std::shared_ptr< const RelAlgNode > input) override
 
std::string toString (RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
 
size_t toHash () const override
 
size_t size () const override
 
std::shared_ptr< RelAlgNodedeepCopy () const override
 
void addHint (const ExplainedQueryHint &hint_explained)
 
const bool hasHintEnabled (QueryHint candidate_hint) const
 
const ExplainedQueryHintgetHintInfo (QueryHint hint) const
 
bool hasDeliveredHint ()
 
HintsgetDeliveredHints ()
 
- Public Member Functions inherited from RelAlgNode
 RelAlgNode (RelAlgInputs inputs={})
 
virtual ~RelAlgNode ()
 
void resetQueryExecutionState ()
 
void setContextData (const RaExecutionDesc *context_data) const
 
void setOutputMetainfo (const std::vector< TargetMetaInfo > &targets_metainfo) const
 
void setQueryPlanDag (const std::string &extracted_query_plan_dag) const
 
std::string getQueryPlanDag () const
 
size_t getQueryPlanDagHash () const
 
const std::vector
< TargetMetaInfo > & 
getOutputMetainfo () const
 
unsigned getId () const
 
void setIdInPlanTree (size_t id) const
 
std::optional< size_t > getIdInPlanTree () const
 
bool hasContextData () const
 
const RaExecutionDescgetContextData () const
 
const size_t inputCount () const
 
const RelAlgNodegetInput (const size_t idx) const
 
std::shared_ptr< const RelAlgNodegetAndOwnInput (const size_t idx) const
 
void addManagedInput (std::shared_ptr< const RelAlgNode > input)
 
bool hasInput (const RelAlgNode *needle) const
 
void setRelNodeDagId (const size_t id) const
 
size_t getRelNodeDagId () const
 
bool isNop () const
 
void markAsNop ()
 
void clearContextData () const
 

Private Attributes

std::unique_ptr< const RexScalarcondition_
 
const JoinType join_type_
 
bool hint_applied_
 
std::unique_ptr< Hintshints_
 

Additional Inherited Members

- Static Public Member Functions inherited from RelAlgNode
static void resetRelAlgFirstId () noexcept
 
- Protected Attributes inherited from RelAlgNode
RelAlgInputs inputs_
 
const unsigned id_
 
std::optional< size_t > id_in_plan_tree_
 
std::optional< size_t > hash_
 

Detailed Description

Definition at line 1288 of file RelAlgDagBuilder.h.

Constructor & Destructor Documentation

RelJoin::RelJoin ( std::shared_ptr< const RelAlgNode lhs,
std::shared_ptr< const RelAlgNode rhs,
std::unique_ptr< const RexScalar > &  condition,
const JoinType  join_type 
)
inline

Definition at line 1290 of file RelAlgDagBuilder.h.

References RelAlgNode::inputs_.

Referenced by toHash().

1294  : condition_(std::move(condition))
1295  , join_type_(join_type)
1296  , hint_applied_(false)
1297  , hints_(std::make_unique<Hints>()) {
1298  inputs_.push_back(lhs);
1299  inputs_.push_back(rhs);
1300  }
std::unique_ptr< const RexScalar > condition_
const JoinType join_type_
bool hint_applied_
std::unique_ptr< Hints > hints_
RelAlgInputs inputs_

+ Here is the caller graph for this function:

RelJoin::RelJoin ( RelJoin const &  rhs)

Definition at line 600 of file RelAlgDagBuilder.cpp.

References addHint(), condition_, hint_applied_, hints_, and RexVisitorBase< T >::visit().

601  : RelAlgNode(rhs)
602  , join_type_(rhs.join_type_)
603  , hint_applied_(false)
604  , hints_(std::make_unique<Hints>()) {
605  RexDeepCopyVisitor copier;
606  condition_ = copier.visit(rhs.condition_.get());
607  if (rhs.hint_applied_) {
608  for (auto const& kv : *rhs.hints_) {
609  addHint(kv.second);
610  }
611  }
612 }
std::unique_ptr< const RexScalar > condition_
RelAlgNode(RelAlgInputs inputs={})
const JoinType join_type_
bool hint_applied_
void addHint(const ExplainedQueryHint &hint_explained)
virtual T visit(const RexScalar *rex_scalar) const
Definition: RexVisitor.h:27
std::unique_ptr< Hints > hints_

+ Here is the call graph for this function:

Member Function Documentation

void RelJoin::addHint ( const ExplainedQueryHint hint_explained)
inline

Definition at line 1358 of file RelAlgDagBuilder.h.

References ExplainedQueryHint::getHint(), hint_applied_, and hints_.

Referenced by RelJoin().

1358  {
1359  if (!hint_applied_) {
1360  hint_applied_ = true;
1361  }
1362  hints_->emplace(hint_explained.getHint(), hint_explained);
1363  }
bool hint_applied_
std::unique_ptr< Hints > hints_
const QueryHint getHint() const
Definition: QueryHint.h:121

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::shared_ptr<RelAlgNode> RelJoin::deepCopy ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1354 of file RelAlgDagBuilder.h.

1354  {
1355  return std::make_shared<RelJoin>(*this);
1356  }
const RexScalar* RelJoin::getAndReleaseCondition ( ) const
inline

Definition at line 1308 of file RelAlgDagBuilder.h.

References condition_.

1308 { return condition_.release(); }
std::unique_ptr< const RexScalar > condition_
const RexScalar* RelJoin::getCondition ( ) const
inline

Definition at line 1306 of file RelAlgDagBuilder.h.

References condition_.

Referenced by RelRexDagVisitor::visit(), and anonymous_namespace{QueryPhysicalInputsCollector.cpp}::RelAlgPhysicalInputsVisitor::visitJoin().

1306 { return condition_.get(); }
std::unique_ptr< const RexScalar > condition_

+ Here is the caller graph for this function:

Hints* RelJoin::getDeliveredHints ( )
inline

Definition at line 1381 of file RelAlgDagBuilder.h.

References hints_.

1381 { return hints_.get(); }
std::unique_ptr< Hints > hints_
const ExplainedQueryHint& RelJoin::getHintInfo ( QueryHint  hint) const
inline

Definition at line 1372 of file RelAlgDagBuilder.h.

References CHECK, hasHintEnabled(), hint_applied_, and hints_.

1372  {
1374  CHECK(!hints_->empty());
1375  CHECK(hasHintEnabled(hint));
1376  return hints_->at(hint);
1377  }
const bool hasHintEnabled(QueryHint candidate_hint) const
bool hint_applied_
std::unique_ptr< Hints > hints_
#define CHECK(condition)
Definition: Logger.h:223

+ Here is the call graph for this function:

JoinType RelJoin::getJoinType ( ) const
inline

Definition at line 1304 of file RelAlgDagBuilder.h.

References join_type_.

Referenced by toHash().

1304 { return join_type_; }
const JoinType join_type_

+ Here is the caller graph for this function:

bool RelJoin::hasDeliveredHint ( )
inline

Definition at line 1379 of file RelAlgDagBuilder.h.

References hints_.

1379 { return !hints_->empty(); }
std::unique_ptr< Hints > hints_
const bool RelJoin::hasHintEnabled ( QueryHint  candidate_hint) const
inline

Definition at line 1365 of file RelAlgDagBuilder.h.

References hint_applied_, and hints_.

Referenced by getHintInfo().

1365  {
1366  if (hint_applied_ && !hints_->empty()) {
1367  return hints_->find(candidate_hint) != hints_->end();
1368  }
1369  return false;
1370  }
bool hint_applied_
std::unique_ptr< Hints > hints_

+ Here is the caller graph for this function:

void RelJoin::replaceInput ( std::shared_ptr< const RelAlgNode old_input,
std::shared_ptr< const RelAlgNode input 
)
overridevirtual

Reimplemented from RelAlgNode.

Definition at line 528 of file RelAlgDagBuilder.cpp.

References condition_, and RelAlgNode::replaceInput().

Referenced by create_left_deep_join().

529  {
530  RelAlgNode::replaceInput(old_input, input);
531  RexRebindInputsVisitor rebind_inputs(old_input.get(), input.get());
532  if (condition_) {
533  rebind_inputs.visit(condition_.get());
534  }
535 }
std::unique_ptr< const RexScalar > condition_
virtual void replaceInput(std::shared_ptr< const RelAlgNode > old_input, std::shared_ptr< const RelAlgNode > input)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void RelJoin::setCondition ( std::unique_ptr< const RexScalar > &  condition)
inline

Definition at line 1310 of file RelAlgDagBuilder.h.

References CHECK, and condition_.

1310  {
1311  CHECK(condition);
1312  condition_ = std::move(condition);
1313  }
std::unique_ptr< const RexScalar > condition_
#define CHECK(condition)
Definition: Logger.h:223
size_t RelJoin::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1352 of file RelAlgDagBuilder.h.

References RelAlgNode::inputs_.

1352 { return inputs_[0]->size() + inputs_[1]->size(); }
RelAlgInputs inputs_
size_t RelJoin::toHash ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1340 of file RelAlgDagBuilder.h.

References condition_, getJoinType(), RelAlgNode::hash_, HASH_N, RelAlgNode::inputs_, RelJoin(), and toString().

1340  {
1341  if (!hash_) {
1342  hash_ = typeid(RelJoin).hash_code();
1343  boost::hash_combine(*hash_, condition_ ? condition_->toHash() : HASH_N);
1344  for (auto& node : inputs_) {
1345  boost::hash_combine(*hash_, node->toHash());
1346  }
1347  boost::hash_combine(*hash_, ::toString(getJoinType()));
1348  }
1349  return *hash_;
1350  }
std::unique_ptr< const RexScalar > condition_
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
std::optional< size_t > hash_
static auto const HASH_N
JoinType getJoinType() const
RelJoin(std::shared_ptr< const RelAlgNode > lhs, std::shared_ptr< const RelAlgNode > rhs, std::unique_ptr< const RexScalar > &condition, const JoinType join_type)
RelAlgInputs inputs_

+ Here is the call graph for this function:

std::string RelJoin::toString ( RelRexToStringConfig  config = RelRexToStringConfig::defaults()) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1318 of file RelAlgDagBuilder.h.

References cat(), condition_, RelAlgNode::inputs_, join_type_, to_string(), and typeName().

Referenced by toHash().

1319  {
1320  auto ret = cat(::typeName(this), "(");
1321  if (!config.skip_input_nodes) {
1322  ret += ::toString(inputs_);
1323  } else {
1324  ret += ", input node id={";
1325  for (auto& input : inputs_) {
1326  auto node_id_in_plan = input->getIdInPlanTree();
1327  auto node_id_str = node_id_in_plan ? std::to_string(*node_id_in_plan)
1328  : std::to_string(input->getId());
1329  ret += node_id_str + " ";
1330  }
1331  ret += "}";
1332  }
1333  return cat(ret,
1334  ", condition=",
1335  (condition_ ? condition_->toString(config) : "null"),
1336  ", join_type=",
1337  ::toString(join_type_));
1338  }
std::unique_ptr< const RexScalar > condition_
std::string cat(Ts &&...args)
const JoinType join_type_
std::string to_string(char const *&&v)
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
unsigned getId() const
std::string typeName(const T *v)
Definition: toString.h:102
RelAlgInputs inputs_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

std::unique_ptr<const RexScalar> RelJoin::condition_
mutableprivate
bool RelJoin::hint_applied_
private

Definition at line 1386 of file RelAlgDagBuilder.h.

Referenced by addHint(), getHintInfo(), hasHintEnabled(), and RelJoin().

std::unique_ptr<Hints> RelJoin::hints_
private
const JoinType RelJoin::join_type_
private

Definition at line 1385 of file RelAlgDagBuilder.h.

Referenced by getJoinType(), and toString().


The documentation for this class was generated from the following files: