OmniSciDB  b24e664e58
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RelLeftDeepInnerJoin Class Reference

#include <RelAlgAbstractInterpreter.h>

+ Inheritance diagram for RelLeftDeepInnerJoin:
+ Collaboration diagram for RelLeftDeepInnerJoin:

Public Member Functions

 RelLeftDeepInnerJoin (const std::shared_ptr< RelFilter > &filter, std::vector< std::shared_ptr< const RelAlgNode >> inputs, std::vector< std::shared_ptr< const RelJoin >> &original_joins)
 
const RexScalargetInnerCondition () const
 
const RexScalargetOuterCondition (const size_t nesting_level) const
 
std::string toString () const override
 
size_t size () const override
 
std::shared_ptr< RelAlgNodedeepCopy () const override
 
bool coversOriginalNode (const RelAlgNode *node) const
 
- Public Member Functions inherited from RelAlgNode
 RelAlgNode ()
 
virtual ~RelAlgNode ()
 
void setContextData (const void *context_data) const
 
void setOutputMetainfo (const std::vector< TargetMetaInfo > &targets_metainfo) const
 
const std::vector
< TargetMetaInfo > & 
getOutputMetainfo () const
 
unsigned getId () const
 
bool hasContextData () const
 
const void * getContextData () 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
 
virtual void replaceInput (std::shared_ptr< const RelAlgNode > old_input, std::shared_ptr< const RelAlgNode > input)
 
bool isNop () const
 
void markAsNop ()
 

Private Attributes

std::unique_ptr< const RexScalarcondition_
 
std::vector< std::unique_ptr
< const RexScalar > > 
outer_conditions_per_level_
 
const std::shared_ptr< RelFilteroriginal_filter_
 
const std::vector
< std::shared_ptr< const
RelJoin > > 
original_joins_
 

Additional Inherited Members

- Static Public Member Functions inherited from RelAlgNode
static void resetRelAlgFirstId () noexcept
 
- Protected Attributes inherited from RelAlgNode
std::vector< std::shared_ptr
< const RelAlgNode > > 
inputs_
 
const unsigned id_
 

Detailed Description

Definition at line 1011 of file RelAlgAbstractInterpreter.h.

Constructor & Destructor Documentation

RelLeftDeepInnerJoin::RelLeftDeepInnerJoin ( const std::shared_ptr< RelFilter > &  filter,
std::vector< std::shared_ptr< const RelAlgNode >>  inputs,
std::vector< std::shared_ptr< const RelJoin >> &  original_joins 
)

Definition at line 24 of file RelLeftDeepInnerJoin.cpp.

References RelAlgNode::addManagedInput(), CHECK(), condition_, INNER, kAND, kBOOLEAN, LEFT, and outer_conditions_per_level_.

28  : condition_(filter ? filter->getAndReleaseCondition() : nullptr)
29  , original_filter_(filter)
30  , original_joins_(original_joins) {
31  std::vector<std::unique_ptr<const RexScalar>> operands;
32  bool is_notnull = true;
33  // Accumulate join conditions from the (explicit) joins themselves and
34  // from the filter node at the root of the left-deep tree pattern.
35  outer_conditions_per_level_.resize(original_joins.size());
36  for (size_t nesting_level = 0; nesting_level < original_joins.size(); ++nesting_level) {
37  const auto& original_join = original_joins[nesting_level];
38  const auto condition_true =
39  dynamic_cast<const RexLiteral*>(original_join->getCondition());
40  if (!condition_true || !condition_true->getVal<bool>()) {
41  if (dynamic_cast<const RexOperator*>(original_join->getCondition())) {
42  is_notnull =
43  is_notnull && dynamic_cast<const RexOperator*>(original_join->getCondition())
44  ->getType()
45  .get_notnull();
46  }
47  switch (original_join->getJoinType()) {
48  case JoinType::INNER: {
49  if (original_join->getCondition()) {
50  operands.emplace_back(original_join->getAndReleaseCondition());
51  }
52  break;
53  }
54  case JoinType::LEFT: {
55  if (original_join->getCondition()) {
56  outer_conditions_per_level_[nesting_level].reset(
57  original_join->getAndReleaseCondition());
58  }
59  break;
60  }
61  default:
62  CHECK(false);
63  }
64  }
65  }
66  if (!operands.empty()) {
67  if (condition_) {
68  CHECK(dynamic_cast<const RexOperator*>(condition_.get()));
69  is_notnull =
70  is_notnull &&
71  static_cast<const RexOperator*>(condition_.get())->getType().get_notnull();
72  operands.emplace_back(std::move(condition_));
73  }
74  if (operands.size() > 1) {
75  condition_.reset(
76  new RexOperator(kAND, operands, SQLTypeInfo(kBOOLEAN, is_notnull)));
77  } else {
78  condition_ = std::move(operands.front());
79  }
80  }
81  if (!condition_) {
82  condition_.reset(new RexLiteral(true, kBOOLEAN, kBOOLEAN, 0, 0, 0, 0));
83  }
84  for (const auto& input : inputs) {
85  addManagedInput(input);
86  }
87 }
std::vector< std::unique_ptr< const RexScalar > > outer_conditions_per_level_
void addManagedInput(std::shared_ptr< const RelAlgNode > input)
CHECK(cgen_state)
const std::vector< std::shared_ptr< const RelJoin > > original_joins_
Definition: sqldefs.h:37
SQLTypeInfoCore< ArrayContextTypeSizer, ExecutorTypePackaging, DateTimeFacilities > SQLTypeInfo
Definition: sqltypes.h:852
std::unique_ptr< const RexScalar > condition_
const std::shared_ptr< RelFilter > original_filter_

+ Here is the call graph for this function:

Member Function Documentation

bool RelLeftDeepInnerJoin::coversOriginalNode ( const RelAlgNode node) const

Definition at line 127 of file RelLeftDeepInnerJoin.cpp.

References original_filter_, and original_joins_.

127  {
128  if (node == original_filter_.get()) {
129  return true;
130  }
131  for (const auto& original_join : original_joins_) {
132  if (original_join.get() == node) {
133  return true;
134  }
135  }
136  return false;
137 }
const std::vector< std::shared_ptr< const RelJoin > > original_joins_
const std::shared_ptr< RelFilter > original_filter_
std::shared_ptr< RelAlgNode > RelLeftDeepInnerJoin::deepCopy ( ) const
overridevirtual

Implements RelAlgNode.

Definition at line 122 of file RelLeftDeepInnerJoin.cpp.

References CHECK().

122  {
123  CHECK(false);
124  return nullptr;
125 }
CHECK(cgen_state)

+ Here is the call graph for this function:

const RexScalar * RelLeftDeepInnerJoin::getInnerCondition ( ) const

Definition at line 89 of file RelLeftDeepInnerJoin.cpp.

References condition_.

Referenced by RelAlgExecutor::translateLeftDeepJoinFilter(), and anonymous_namespace{QueryPhysicalInputsCollector.cpp}::RelAlgPhysicalInputsVisitor::visitLeftDeepInnerJoin().

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

+ Here is the caller graph for this function:

const RexScalar * RelLeftDeepInnerJoin::getOuterCondition ( const size_t  nesting_level) const

Definition at line 93 of file RelLeftDeepInnerJoin.cpp.

References CHECK_GE, CHECK_LE, and outer_conditions_per_level_.

Referenced by anonymous_namespace{RelAlgExecutor.cpp}::left_deep_join_types(), RelAlgExecutor::translateLeftDeepJoinFilter(), and anonymous_namespace{QueryPhysicalInputsCollector.cpp}::RelAlgPhysicalInputsVisitor::visitLeftDeepInnerJoin().

94  {
95  CHECK_GE(nesting_level, size_t(1));
96  CHECK_LE(nesting_level, outer_conditions_per_level_.size());
97  // Outer join conditions are collected depth-first while the returned condition
98  // must be consistent with the order of the loops (which is reverse depth-first).
99  return outer_conditions_per_level_[outer_conditions_per_level_.size() - nesting_level]
100  .get();
101 }
std::vector< std::unique_ptr< const RexScalar > > outer_conditions_per_level_
#define CHECK_GE(x, y)
Definition: Logger.h:203
#define CHECK_LE(x, y)
Definition: Logger.h:201

+ Here is the caller graph for this function:

size_t RelLeftDeepInnerJoin::size ( ) const
overridevirtual

Implements RelAlgNode.

Definition at line 114 of file RelLeftDeepInnerJoin.cpp.

References RelAlgNode::inputs_.

114  {
115  size_t total_size = 0;
116  for (const auto& input : inputs_) {
117  total_size += input->size();
118  }
119  return total_size;
120 }
std::vector< std::shared_ptr< const RelAlgNode > > inputs_
std::string RelLeftDeepInnerJoin::toString ( ) const
overridevirtual

Implements RelAlgNode.

Definition at line 103 of file RelLeftDeepInnerJoin.cpp.

References condition_, RelAlgNode::inputs_, run_benchmark_import::result, and to_string().

103  {
104  std::string result =
105  "(RelLeftDeepInnerJoin<" + std::to_string(reinterpret_cast<uint64_t>(this)) + ">(";
106  result += condition_->toString();
107  for (const auto& input : inputs_) {
108  result += " " + input->toString();
109  }
110  result += ")";
111  return result;
112 }
std::vector< std::shared_ptr< const RelAlgNode > > inputs_
std::string to_string(char const *&&v)
std::unique_ptr< const RexScalar > condition_

+ Here is the call graph for this function:

Member Data Documentation

std::unique_ptr<const RexScalar> RelLeftDeepInnerJoin::condition_
private

Definition at line 1030 of file RelAlgAbstractInterpreter.h.

Referenced by getInnerCondition(), RelLeftDeepInnerJoin(), and toString().

const std::shared_ptr<RelFilter> RelLeftDeepInnerJoin::original_filter_
private

Definition at line 1032 of file RelAlgAbstractInterpreter.h.

Referenced by coversOriginalNode().

const std::vector<std::shared_ptr<const RelJoin> > RelLeftDeepInnerJoin::original_joins_
private

Definition at line 1033 of file RelAlgAbstractInterpreter.h.

Referenced by coversOriginalNode().

std::vector<std::unique_ptr<const RexScalar> > RelLeftDeepInnerJoin::outer_conditions_per_level_
private

Definition at line 1031 of file RelAlgAbstractInterpreter.h.

Referenced by getOuterCondition(), and RelLeftDeepInnerJoin().


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