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

#include <RelAlgDag.h>

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

Public Member Functions

 RelJoin ()
 
 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 &)
 
virtual void acceptChildren (Visitor &v) const override
 
virtual void accept (Visitor &v, std::string name) const override
 
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 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 ()
 
virtual size_t toHash () const override
 
- Public Member Functions inherited from RelAlgNode
 RelAlgNode (RelAlgInputs inputs={})
 
virtual ~RelAlgNode ()
 
void resetQueryExecutionState ()
 
void setContextData (const RaExecutionDesc *context_data) const
 
void setOutputMetainfo (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
 
bool hasContextData () const
 
const RaExecutionDescgetContextData () const
 
const size_t inputCount () const
 
const RelAlgNodegetInput (const size_t idx) const
 
const std::vector< RelAlgNode
const * > 
getInputs () 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
 
- Public Member Functions inherited from RelAlgDagNode
 RelAlgDagNode ()
 
virtual size_t getStepNumber () const
 
virtual void setStepNumber (size_t step) const
 
std::optional< size_t > getIdInPlanTree () const
 
void setIdInPlanTree (size_t id) const
 

Private Attributes

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

Friends

struct RelAlgDagSerializer
 
std::size_t hash_value (RelJoin const &)
 

Additional Inherited Members

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

Detailed Description

Definition at line 1615 of file RelAlgDag.h.

Constructor & Destructor Documentation

RelJoin::RelJoin ( )
inline

Definition at line 1618 of file RelAlgDag.h.

bool hint_applied_
Definition: RelAlgDag.h:1733
JoinType join_type_
Definition: RelAlgDag.h:1732
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 1620 of file RelAlgDag.h.

References RelAlgNode::inputs_.

1624  : condition_(std::move(condition))
1625  , join_type_(join_type)
1626  , hint_applied_(false)
1627  , hints_(std::make_unique<Hints>()) {
1628  inputs_.push_back(lhs);
1629  inputs_.push_back(rhs);
1630  }
std::unique_ptr< const RexScalar > condition_
Definition: RelAlgDag.h:1731
bool hint_applied_
Definition: RelAlgDag.h:1733
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1734
JoinType join_type_
Definition: RelAlgDag.h:1732
RelAlgInputs inputs_
Definition: RelAlgDag.h:945
RelJoin::RelJoin ( RelJoin const &  rhs)

Definition at line 601 of file RelAlgDag.cpp.

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

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

+ Here is the call graph for this function:

Member Function Documentation

virtual void RelJoin::accept ( Visitor v,
std::string  name 
) const
inlineoverridevirtual

Implements RelAlgDagNode.

Definition at line 1644 of file RelAlgDag.h.

References acceptChildren(), and RelAlgDagNode::Visitor::visit().

Referenced by TableFunctionsFactory_node.PrintNode::__str__().

1644  {
1645  if (v.visit(this, std::move(name))) {
1646  acceptChildren(v);
1647  }
1648  }
virtual void acceptChildren(Visitor &v) const override
Definition: RelAlgDag.h:1634
string name
Definition: setup.in.py:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual void RelJoin::acceptChildren ( Visitor v) const
inlineoverridevirtual

Implements RelAlgDagNode.

Definition at line 1634 of file RelAlgDag.h.

References RelAlgDagNode::accept(), getCondition(), RelAlgNode::getInputs(), and anonymous_namespace{Utm.h}::n.

Referenced by accept().

1634  {
1635  if (getCondition()) {
1636  getCondition()->accept(v, "condition");
1637  }
1638  for (auto& n : getInputs()) {
1639  if (n) {
1640  n->accept(v, "input");
1641  }
1642  }
1643  }
const RexScalar * getCondition() const
Definition: RelAlgDag.h:1652
virtual void accept(Visitor &v, std::string name) const =0
const std::vector< RelAlgNode const * > getInputs() const
Definition: RelAlgDag.h:882
constexpr double n
Definition: Utm.h:38

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void RelJoin::addHint ( const ExplainedQueryHint hint_explained)
inline

Definition at line 1701 of file RelAlgDag.h.

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

Referenced by RelJoin().

1701  {
1702  if (!hint_applied_) {
1703  hint_applied_ = true;
1704  }
1705  hints_->emplace(hint_explained.getHint(), hint_explained);
1706  }
bool hint_applied_
Definition: RelAlgDag.h:1733
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1734
const QueryHint getHint() const
Definition: QueryHint.h:167

+ 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 1697 of file RelAlgDag.h.

1697  {
1698  return std::make_shared<RelJoin>(*this);
1699  }
const RexScalar* RelJoin::getAndReleaseCondition ( ) const
inline

Definition at line 1654 of file RelAlgDag.h.

References condition_.

1654 { return condition_.release(); }
std::unique_ptr< const RexScalar > condition_
Definition: RelAlgDag.h:1731
const RexScalar* RelJoin::getCondition ( ) const
inline

Definition at line 1652 of file RelAlgDag.h.

References condition_.

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

1652 { return condition_.get(); }
std::unique_ptr< const RexScalar > condition_
Definition: RelAlgDag.h:1731

+ Here is the caller graph for this function:

Hints* RelJoin::getDeliveredHints ( )
inline

Definition at line 1724 of file RelAlgDag.h.

References hints_.

1724 { return hints_.get(); }
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1734
const ExplainedQueryHint& RelJoin::getHintInfo ( QueryHint  hint) const
inline

Definition at line 1715 of file RelAlgDag.h.

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

1715  {
1717  CHECK(!hints_->empty());
1718  CHECK(hasHintEnabled(hint));
1719  return hints_->at(hint);
1720  }
const bool hasHintEnabled(QueryHint candidate_hint) const
Definition: RelAlgDag.h:1708
bool hint_applied_
Definition: RelAlgDag.h:1733
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1734
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

JoinType RelJoin::getJoinType ( ) const
inline

Definition at line 1650 of file RelAlgDag.h.

References join_type_.

Referenced by hash_value().

1650 { return join_type_; }
JoinType join_type_
Definition: RelAlgDag.h:1732

+ Here is the caller graph for this function:

bool RelJoin::hasDeliveredHint ( )
inline

Definition at line 1722 of file RelAlgDag.h.

References hints_.

1722 { return !hints_->empty(); }
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1734
const bool RelJoin::hasHintEnabled ( QueryHint  candidate_hint) const
inline

Definition at line 1708 of file RelAlgDag.h.

References hint_applied_, and hints_.

Referenced by getHintInfo().

1708  {
1709  if (hint_applied_ && !hints_->empty()) {
1710  return hints_->find(candidate_hint) != hints_->end();
1711  }
1712  return false;
1713  }
bool hint_applied_
Definition: RelAlgDag.h:1733
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1734

+ 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 RelAlgDag.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_
Definition: RelAlgDag.h:1731
virtual void replaceInput(std::shared_ptr< const RelAlgNode > old_input, std::shared_ptr< const RelAlgNode > input)
Definition: RelAlgDag.h:908

+ 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 1656 of file RelAlgDag.h.

References CHECK, and condition_.

1656  {
1657  CHECK(condition);
1658  condition_ = std::move(condition);
1659  }
std::unique_ptr< const RexScalar > condition_
Definition: RelAlgDag.h:1731
#define CHECK(condition)
Definition: Logger.h:291
size_t RelJoin::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1695 of file RelAlgDag.h.

References RelAlgNode::inputs_.

1695 { return inputs_[0]->size() + inputs_[1]->size(); }
RelAlgInputs inputs_
Definition: RelAlgDag.h:945
virtual size_t RelJoin::toHash ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1726 of file RelAlgDag.h.

References hash_value.

1726 { return hash_value(*this); }
friend std::size_t hash_value(RelJoin const &)
Definition: RelAlgDag.cpp:3725
std::string RelJoin::toString ( RelRexToStringConfig  config = RelRexToStringConfig::defaults()) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1664 of file RelAlgDag.h.

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

1665  {
1666  if (!config.attributes_only) {
1667  auto ret = cat(::typeName(this), "(");
1668  if (!config.skip_input_nodes) {
1669  ret += ::toString(inputs_);
1670  } else {
1671  ret += ", input node id={";
1672  for (auto& input : inputs_) {
1673  auto node_id_in_plan = input->getIdInPlanTree();
1674  auto node_id_str = node_id_in_plan ? std::to_string(*node_id_in_plan)
1675  : std::to_string(input->getId());
1676  ret += node_id_str + " ";
1677  }
1678  ret += "}";
1679  }
1680  return cat(ret,
1681  ", condition=",
1682  (condition_ ? condition_->toString(config) : "null"),
1683  ", join_type=",
1684  ::toString(join_type_));
1685  } else {
1686  return cat(::typeName(this),
1687  "(condition=",
1688  (condition_ ? condition_->toString(config) : "null"),
1689  ", join_type=",
1690  ::toString(join_type_),
1691  ")");
1692  }
1693  }
std::unique_ptr< const RexScalar > condition_
Definition: RelAlgDag.h:1731
std::string cat(Ts &&...args)
std::string to_string(char const *&&v)
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
Definition: RelAlgDag.h:1664
unsigned getId() const
Definition: RelAlgDag.h:869
JoinType join_type_
Definition: RelAlgDag.h:1732
std::string typeName(const T *v)
Definition: toString.h:106
RelAlgInputs inputs_
Definition: RelAlgDag.h:945

+ Here is the call graph for this function:

Friends And Related Function Documentation

std::size_t hash_value ( RelJoin const &  rel_join)
friend

Definition at line 3725 of file RelAlgDag.cpp.

Referenced by toHash().

3725  {
3726  if (rel_join.hash_) {
3727  return *rel_join.hash_;
3728  }
3729  rel_join.hash_ = typeid(RelJoin).hash_code();
3730  boost::hash_combine(*rel_join.hash_, rel_join.condition_);
3731  boost::hash_combine(*rel_join.hash_, rel_join.inputs_);
3732  boost::hash_combine(*rel_join.hash_, ::toString(rel_join.getJoinType()));
3733  return *rel_join.hash_;
3734 }
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
Definition: RelAlgDag.h:1664
friend struct RelAlgDagSerializer
friend

Definition at line 1736 of file RelAlgDag.h.

Member Data Documentation

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

Definition at line 1733 of file RelAlgDag.h.

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

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

Definition at line 1732 of file RelAlgDag.h.

Referenced by getJoinType(), and toString().


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