OmniSciDB  c1a53651b2
 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 &)
 
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 (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_
 
JoinType join_type_
 
bool hint_applied_
 
std::unique_ptr< Hintshints_
 

Friends

struct RelAlgDagSerializer
 

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 > id_in_plan_tree_
 
std::optional< size_t > hash_
 

Detailed Description

Definition at line 1451 of file RelAlgDag.h.

Constructor & Destructor Documentation

RelJoin::RelJoin ( )
inline

Definition at line 1454 of file RelAlgDag.h.

Referenced by toHash().

bool hint_applied_
Definition: RelAlgDag.h:1552
JoinType join_type_
Definition: RelAlgDag.h:1551

+ Here is the caller graph for this function:

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

References RelAlgNode::inputs_.

1460  : condition_(std::move(condition))
1461  , join_type_(join_type)
1462  , hint_applied_(false)
1463  , hints_(std::make_unique<Hints>()) {
1464  inputs_.push_back(lhs);
1465  inputs_.push_back(rhs);
1466  }
std::unique_ptr< const RexScalar > condition_
Definition: RelAlgDag.h:1550
bool hint_applied_
Definition: RelAlgDag.h:1552
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1553
JoinType join_type_
Definition: RelAlgDag.h:1551
RelAlgInputs inputs_
Definition: RelAlgDag.h:952
RelJoin::RelJoin ( RelJoin const &  rhs)

Definition at line 600 of file RelAlgDag.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_
Definition: RelAlgDag.h:1550
RelAlgNode(RelAlgInputs inputs={})
Definition: RelAlgDag.h:840
bool hint_applied_
Definition: RelAlgDag.h:1552
void addHint(const ExplainedQueryHint &hint_explained)
Definition: RelAlgDag.h:1524
virtual T visit(const RexScalar *rex_scalar) const
Definition: RexVisitor.h:27
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1553
JoinType join_type_
Definition: RelAlgDag.h:1551

+ Here is the call graph for this function:

Member Function Documentation

void RelJoin::addHint ( const ExplainedQueryHint hint_explained)
inline

Definition at line 1524 of file RelAlgDag.h.

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

Referenced by RelJoin().

1524  {
1525  if (!hint_applied_) {
1526  hint_applied_ = true;
1527  }
1528  hints_->emplace(hint_explained.getHint(), hint_explained);
1529  }
bool hint_applied_
Definition: RelAlgDag.h:1552
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1553
const QueryHint getHint() const
Definition: QueryHint.h:154

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

1520  {
1521  return std::make_shared<RelJoin>(*this);
1522  }
const RexScalar* RelJoin::getAndReleaseCondition ( ) const
inline

Definition at line 1474 of file RelAlgDag.h.

References condition_.

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

Definition at line 1472 of file RelAlgDag.h.

References condition_.

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

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

+ Here is the caller graph for this function:

Hints* RelJoin::getDeliveredHints ( )
inline

Definition at line 1547 of file RelAlgDag.h.

References hints_.

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

Definition at line 1538 of file RelAlgDag.h.

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

1538  {
1540  CHECK(!hints_->empty());
1541  CHECK(hasHintEnabled(hint));
1542  return hints_->at(hint);
1543  }
const bool hasHintEnabled(QueryHint candidate_hint) const
Definition: RelAlgDag.h:1531
bool hint_applied_
Definition: RelAlgDag.h:1552
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1553
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

JoinType RelJoin::getJoinType ( ) const
inline

Definition at line 1470 of file RelAlgDag.h.

References join_type_.

Referenced by toHash().

1470 { return join_type_; }
JoinType join_type_
Definition: RelAlgDag.h:1551

+ Here is the caller graph for this function:

bool RelJoin::hasDeliveredHint ( )
inline

Definition at line 1545 of file RelAlgDag.h.

References hints_.

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

Definition at line 1531 of file RelAlgDag.h.

References hint_applied_, and hints_.

Referenced by getHintInfo().

1531  {
1532  if (hint_applied_ && !hints_->empty()) {
1533  return hints_->find(candidate_hint) != hints_->end();
1534  }
1535  return false;
1536  }
bool hint_applied_
Definition: RelAlgDag.h:1552
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1553

+ 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 527 of file RelAlgDag.cpp.

References condition_, and RelAlgNode::replaceInput().

Referenced by create_left_deep_join().

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

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

References CHECK, and condition_.

1476  {
1477  CHECK(condition);
1478  condition_ = std::move(condition);
1479  }
std::unique_ptr< const RexScalar > condition_
Definition: RelAlgDag.h:1550
#define CHECK(condition)
Definition: Logger.h:291
size_t RelJoin::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1518 of file RelAlgDag.h.

References RelAlgNode::inputs_.

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

Implements RelAlgNode.

Definition at line 1506 of file RelAlgDag.h.

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

1506  {
1507  if (!hash_) {
1508  hash_ = typeid(RelJoin).hash_code();
1509  boost::hash_combine(*hash_, condition_ ? condition_->toHash() : HASH_N);
1510  for (auto& node : inputs_) {
1511  boost::hash_combine(*hash_, node->toHash());
1512  }
1513  boost::hash_combine(*hash_, ::toString(getJoinType()));
1514  }
1515  return *hash_;
1516  }
std::unique_ptr< const RexScalar > condition_
Definition: RelAlgDag.h:1550
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
Definition: RelAlgDag.h:1484
static auto const HASH_N
Definition: RelAlgDag.h:44
std::optional< size_t > hash_
Definition: RelAlgDag.h:955
JoinType getJoinType() const
Definition: RelAlgDag.h:1470
RelAlgInputs inputs_
Definition: RelAlgDag.h:952

+ Here is the call graph for this function:

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

Implements RelAlgNode.

Definition at line 1484 of file RelAlgDag.h.

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

Referenced by toHash().

1485  {
1486  auto ret = cat(::typeName(this), "(");
1487  if (!config.skip_input_nodes) {
1488  ret += ::toString(inputs_);
1489  } else {
1490  ret += ", input node id={";
1491  for (auto& input : inputs_) {
1492  auto node_id_in_plan = input->getIdInPlanTree();
1493  auto node_id_str = node_id_in_plan ? std::to_string(*node_id_in_plan)
1494  : std::to_string(input->getId());
1495  ret += node_id_str + " ";
1496  }
1497  ret += "}";
1498  }
1499  return cat(ret,
1500  ", condition=",
1501  (condition_ ? condition_->toString(config) : "null"),
1502  ", join_type=",
1503  ::toString(join_type_));
1504  }
std::unique_ptr< const RexScalar > condition_
Definition: RelAlgDag.h:1550
std::string cat(Ts &&...args)
std::string to_string(char const *&&v)
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
Definition: RelAlgDag.h:1484
unsigned getId() const
Definition: RelAlgDag.h:880
JoinType join_type_
Definition: RelAlgDag.h:1551
std::string typeName(const T *v)
Definition: toString.h:103
RelAlgInputs inputs_
Definition: RelAlgDag.h:952

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Friends And Related Function Documentation

friend struct RelAlgDagSerializer
friend

Definition at line 1555 of file RelAlgDag.h.

Member Data Documentation

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

Definition at line 1552 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 1551 of file RelAlgDag.h.

Referenced by getJoinType(), and toString().


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