OmniSciDB  c0231cc57d
 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 (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 1344 of file RelAlgDag.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 1346 of file RelAlgDag.h.

References RelAlgNode::inputs_.

Referenced by toHash().

1350  : condition_(std::move(condition))
1351  , join_type_(join_type)
1352  , hint_applied_(false)
1353  , hints_(std::make_unique<Hints>()) {
1354  inputs_.push_back(lhs);
1355  inputs_.push_back(rhs);
1356  }
std::unique_ptr< const RexScalar > condition_
Definition: RelAlgDag.h:1440
const JoinType join_type_
Definition: RelAlgDag.h:1441
bool hint_applied_
Definition: RelAlgDag.h:1442
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1443
RelAlgInputs inputs_
Definition: RelAlgDag.h:886

+ Here is the caller graph for this function:

RelJoin::RelJoin ( RelJoin const &  rhs)

Definition at line 599 of file RelAlgDag.cpp.

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

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

+ Here is the call graph for this function:

Member Function Documentation

void RelJoin::addHint ( const ExplainedQueryHint hint_explained)
inline

Definition at line 1414 of file RelAlgDag.h.

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

Referenced by RelJoin().

1414  {
1415  if (!hint_applied_) {
1416  hint_applied_ = true;
1417  }
1418  hints_->emplace(hint_explained.getHint(), hint_explained);
1419  }
bool hint_applied_
Definition: RelAlgDag.h:1442
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1443
const QueryHint getHint() const
Definition: QueryHint.h:123

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

1410  {
1411  return std::make_shared<RelJoin>(*this);
1412  }
const RexScalar* RelJoin::getAndReleaseCondition ( ) const
inline

Definition at line 1364 of file RelAlgDag.h.

References condition_.

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

Definition at line 1362 of file RelAlgDag.h.

References condition_.

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

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

+ Here is the caller graph for this function:

Hints* RelJoin::getDeliveredHints ( )
inline

Definition at line 1437 of file RelAlgDag.h.

References hints_.

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

Definition at line 1428 of file RelAlgDag.h.

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

1428  {
1430  CHECK(!hints_->empty());
1431  CHECK(hasHintEnabled(hint));
1432  return hints_->at(hint);
1433  }
const bool hasHintEnabled(QueryHint candidate_hint) const
Definition: RelAlgDag.h:1421
bool hint_applied_
Definition: RelAlgDag.h:1442
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1443
#define CHECK(condition)
Definition: Logger.h:222

+ Here is the call graph for this function:

JoinType RelJoin::getJoinType ( ) const
inline

Definition at line 1360 of file RelAlgDag.h.

References join_type_.

Referenced by toHash().

1360 { return join_type_; }
const JoinType join_type_
Definition: RelAlgDag.h:1441

+ Here is the caller graph for this function:

bool RelJoin::hasDeliveredHint ( )
inline

Definition at line 1435 of file RelAlgDag.h.

References hints_.

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

Definition at line 1421 of file RelAlgDag.h.

References hint_applied_, and hints_.

Referenced by getHintInfo().

1421  {
1422  if (hint_applied_ && !hints_->empty()) {
1423  return hints_->find(candidate_hint) != hints_->end();
1424  }
1425  return false;
1426  }
bool hint_applied_
Definition: RelAlgDag.h:1442
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1443

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

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

References CHECK, and condition_.

1366  {
1367  CHECK(condition);
1368  condition_ = std::move(condition);
1369  }
std::unique_ptr< const RexScalar > condition_
Definition: RelAlgDag.h:1440
#define CHECK(condition)
Definition: Logger.h:222
size_t RelJoin::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1408 of file RelAlgDag.h.

References RelAlgNode::inputs_.

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

Implements RelAlgNode.

Definition at line 1396 of file RelAlgDag.h.

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

1396  {
1397  if (!hash_) {
1398  hash_ = typeid(RelJoin).hash_code();
1399  boost::hash_combine(*hash_, condition_ ? condition_->toHash() : HASH_N);
1400  for (auto& node : inputs_) {
1401  boost::hash_combine(*hash_, node->toHash());
1402  }
1403  boost::hash_combine(*hash_, ::toString(getJoinType()));
1404  }
1405  return *hash_;
1406  }
std::unique_ptr< const RexScalar > condition_
Definition: RelAlgDag.h:1440
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
Definition: RelAlgDag.h:1374
static auto const HASH_N
Definition: RelAlgDag.h:44
std::optional< size_t > hash_
Definition: RelAlgDag.h:889
JoinType getJoinType() const
Definition: RelAlgDag.h:1360
RelJoin(std::shared_ptr< const RelAlgNode > lhs, std::shared_ptr< const RelAlgNode > rhs, std::unique_ptr< const RexScalar > &condition, const JoinType join_type)
Definition: RelAlgDag.h:1346
RelAlgInputs inputs_
Definition: RelAlgDag.h:886

+ Here is the call graph for this function:

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

Implements RelAlgNode.

Definition at line 1374 of file RelAlgDag.h.

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

Referenced by toHash().

1375  {
1376  auto ret = cat(::typeName(this), "(");
1377  if (!config.skip_input_nodes) {
1378  ret += ::toString(inputs_);
1379  } else {
1380  ret += ", input node id={";
1381  for (auto& input : inputs_) {
1382  auto node_id_in_plan = input->getIdInPlanTree();
1383  auto node_id_str = node_id_in_plan ? std::to_string(*node_id_in_plan)
1384  : std::to_string(input->getId());
1385  ret += node_id_str + " ";
1386  }
1387  ret += "}";
1388  }
1389  return cat(ret,
1390  ", condition=",
1391  (condition_ ? condition_->toString(config) : "null"),
1392  ", join_type=",
1393  ::toString(join_type_));
1394  }
std::unique_ptr< const RexScalar > condition_
Definition: RelAlgDag.h:1440
std::string cat(Ts &&...args)
const JoinType join_type_
Definition: RelAlgDag.h:1441
std::string to_string(char const *&&v)
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
Definition: RelAlgDag.h:1374
unsigned getId() const
Definition: RelAlgDag.h:814
std::string typeName(const T *v)
Definition: toString.h:103
RelAlgInputs inputs_
Definition: RelAlgDag.h:886

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

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

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

Definition at line 1441 of file RelAlgDag.h.

Referenced by getJoinType(), and toString().


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