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

#include <RelAlgDagBuilder.h>

+ Inheritance diagram for RelCompound:
+ Collaboration diagram for RelCompound:

Public Member Functions

 RelCompound (std::unique_ptr< const RexScalar > &filter_expr, const std::vector< const Rex * > &target_exprs, const size_t groupby_count, const std::vector< const RexAgg * > &agg_exprs, const std::vector< std::string > &fields, std::vector< std::unique_ptr< const RexScalar >> &scalar_sources, const bool is_agg, bool update_disguised_as_select=false, bool delete_disguised_as_select=false, bool varlen_update_required=false, TableDescriptor const *manipulation_target_table=nullptr, ColumnNameList target_columns=ColumnNameList())
 
 RelCompound (RelCompound const &)
 
void replaceInput (std::shared_ptr< const RelAlgNode > old_input, std::shared_ptr< const RelAlgNode > input) override
 
size_t size () const override
 
const RexScalargetFilterExpr () const
 
void setFilterExpr (std::unique_ptr< const RexScalar > &new_expr)
 
const RexgetTargetExpr (const size_t i) const
 
const std::vector< std::string > & getFields () const
 
const std::string getFieldName (const size_t i) const
 
const size_t getScalarSourcesSize () const
 
const RexScalargetScalarSource (const size_t i) const
 
void setScalarSources (std::vector< std::unique_ptr< const RexScalar >> &new_sources)
 
const size_t getGroupByCount () const
 
bool isAggregate () const
 
size_t getAggExprSize () const
 
const RexAgggetAggExpr (size_t i) const
 
std::string toString () const override
 
size_t toHash () 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
 
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
 
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 ModifyManipulationTarget
 ModifyManipulationTarget (bool const update_via_select=false, bool const delete_via_select=false, bool const varlen_update_required=false, TableDescriptor const *table_descriptor=nullptr, ColumnNameList target_columns=ColumnNameList())
 
void setUpdateViaSelectFlag () const
 
void setDeleteViaSelectFlag () const
 
void setVarlenUpdateRequired (bool required) const
 
TableDescriptor constgetModifiedTableDescriptor () const
 
void setModifiedTableDescriptor (TableDescriptor const *td) const
 
auto const isUpdateViaSelect () const
 
auto const isDeleteViaSelect () const
 
auto const isVarlenUpdateRequired () const
 
void setTargetColumns (ColumnNameList const &target_columns) const
 
ColumnNameList constgetTargetColumns () const
 
template<typename VALIDATION_FUNCTOR >
bool validateTargetColumns (VALIDATION_FUNCTOR validator) const
 

Private Attributes

std::unique_ptr< const RexScalarfilter_expr_
 
const size_t groupby_count_
 
std::vector< std::unique_ptr
< const RexAgg > > 
agg_exprs_
 
const std::vector< std::string > fields_
 
const bool is_agg_
 
std::vector< std::unique_ptr
< const RexScalar > > 
scalar_sources_
 
const std::vector< const Rex * > target_exprs_
 
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 > hash_
 

Detailed Description

Definition at line 1520 of file RelAlgDagBuilder.h.

Constructor & Destructor Documentation

RelCompound::RelCompound ( std::unique_ptr< const RexScalar > &  filter_expr,
const std::vector< const Rex * > &  target_exprs,
const size_t  groupby_count,
const std::vector< const RexAgg * > &  agg_exprs,
const std::vector< std::string > &  fields,
std::vector< std::unique_ptr< const RexScalar >> &  scalar_sources,
const bool  is_agg,
bool  update_disguised_as_select = false,
bool  delete_disguised_as_select = false,
bool  varlen_update_required = false,
TableDescriptor const manipulation_target_table = nullptr,
ColumnNameList  target_columns = ColumnNameList() 
)
inline

Definition at line 1525 of file RelAlgDagBuilder.h.

References agg_exprs_, and CHECK_EQ.

Referenced by toHash().

1537  : ModifyManipulationTarget(update_disguised_as_select,
1538  delete_disguised_as_select,
1539  varlen_update_required,
1540  manipulation_target_table,
1541  target_columns)
1542  , filter_expr_(std::move(filter_expr))
1543  , groupby_count_(groupby_count)
1544  , fields_(fields)
1545  , is_agg_(is_agg)
1546  , scalar_sources_(std::move(scalar_sources))
1547  , target_exprs_(target_exprs)
1548  , hint_applied_(false)
1549  , hints_(std::make_unique<Hints>()) {
1550  CHECK_EQ(fields.size(), target_exprs.size());
1551  for (auto agg_expr : agg_exprs) {
1552  agg_exprs_.emplace_back(agg_expr);
1553  }
1554  }
bool is_agg(const Analyzer::Expr *expr)
#define CHECK_EQ(x, y)
Definition: Logger.h:219
const std::vector< std::string > fields_
std::vector< std::unique_ptr< const RexScalar > > scalar_sources_
const size_t groupby_count_
std::unique_ptr< Hints > hints_
const std::vector< const Rex * > target_exprs_
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
std::unique_ptr< const RexScalar > filter_expr_
ModifyManipulationTarget(bool const update_via_select=false, bool const delete_via_select=false, bool const varlen_update_required=false, TableDescriptor const *table_descriptor=nullptr, ColumnNameList target_columns=ColumnNameList())
const bool is_agg_

+ Here is the caller graph for this function:

RelCompound::RelCompound ( RelCompound const rhs)

Definition at line 442 of file RelAlgDagBuilder.cpp.

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

443  : RelAlgNode(rhs)
445  , groupby_count_(rhs.groupby_count_)
446  , agg_exprs_(copyAggExprs(rhs.agg_exprs_))
447  , fields_(rhs.fields_)
448  , is_agg_(rhs.is_agg_)
449  , scalar_sources_(copyRexScalars(rhs.scalar_sources_))
452  rhs.agg_exprs_,
453  rhs.scalar_sources_,
454  rhs.target_exprs_))
455  , hint_applied_(false)
456  , hints_(std::make_unique<Hints>()) {
457  RexDeepCopyVisitor copier;
458  filter_expr_ = rhs.filter_expr_ ? copier.visit(rhs.filter_expr_.get()) : nullptr;
459  if (rhs.hint_applied_) {
460  for (auto const& kv : *rhs.hints_) {
461  addHint(kv.second);
462  }
463  }
464 }
std::vector< const Rex * > remapTargetPointers(std::vector< std::unique_ptr< const RexAgg >> const &agg_exprs_new, std::vector< std::unique_ptr< const RexScalar >> const &scalar_sources_new, std::vector< std::unique_ptr< const RexAgg >> const &agg_exprs_old, std::vector< std::unique_ptr< const RexScalar >> const &scalar_sources_old, std::vector< const Rex * > const &target_exprs_old)
RelAlgNode(RelAlgInputs inputs={})
void addHint(const ExplainedQueryHint &hint_explained)
const std::vector< std::string > fields_
std::vector< std::unique_ptr< const RexScalar > > scalar_sources_
virtual T visit(const RexScalar *rex_scalar) const
Definition: RexVisitor.h:27
const size_t groupby_count_
std::vector< std::unique_ptr< const RexAgg > > copyAggExprs(std::vector< std::unique_ptr< const RexAgg >> const &agg_exprs)
std::unique_ptr< Hints > hints_
const std::vector< const Rex * > target_exprs_
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
std::unique_ptr< const RexScalar > filter_expr_
ModifyManipulationTarget(bool const update_via_select=false, bool const delete_via_select=false, bool const varlen_update_required=false, TableDescriptor const *table_descriptor=nullptr, ColumnNameList target_columns=ColumnNameList())
std::vector< std::unique_ptr< const RexScalar > > copyRexScalars(std::vector< std::unique_ptr< const RexScalar >> const &scalar_sources)
const bool is_agg_

+ Here is the call graph for this function:

Member Function Documentation

void RelCompound::addHint ( const ExplainedQueryHint hint_explained)
inline

Definition at line 1602 of file RelAlgDagBuilder.h.

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

Referenced by RelCompound().

1602  {
1603  if (!hint_applied_) {
1604  hint_applied_ = true;
1605  }
1606  hints_->emplace(hint_explained.getHint(), hint_explained);
1607  }
std::unique_ptr< Hints > hints_
const QueryHint getHint() const
Definition: QueryHint.h:117

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Implements RelAlgNode.

Definition at line 1598 of file RelAlgDagBuilder.h.

1598  {
1599  return std::make_shared<RelCompound>(*this);
1600  }
const RexAgg* RelCompound::getAggExpr ( size_t  i) const
inline

Definition at line 1592 of file RelAlgDagBuilder.h.

References agg_exprs_, and i.

1592 { return agg_exprs_[i].get(); }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
size_t RelCompound::getAggExprSize ( ) const
inline

Definition at line 1590 of file RelAlgDagBuilder.h.

References agg_exprs_.

1590 { return agg_exprs_.size(); }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Hints* RelCompound::getDeliveredHints ( )
inline

Definition at line 1625 of file RelAlgDagBuilder.h.

References hints_.

Referenced by anonymous_namespace{RelAlgDagBuilder.cpp}::handleQueryHint().

1625 { return hints_.get(); }
std::unique_ptr< Hints > hints_

+ Here is the caller graph for this function:

const std::string RelCompound::getFieldName ( const size_t  i) const
inline

Definition at line 1573 of file RelAlgDagBuilder.h.

References fields_, and i.

1573 { return fields_[i]; }
const std::vector< std::string > fields_
const std::vector<std::string>& RelCompound::getFields ( ) const
inline

Definition at line 1571 of file RelAlgDagBuilder.h.

References fields_.

1571 { return fields_; }
const std::vector< std::string > fields_
const RexScalar* RelCompound::getFilterExpr ( ) const
inline

Definition at line 1563 of file RelAlgDagBuilder.h.

References filter_expr_.

Referenced by anonymous_namespace{RelAlgExecutor.cpp}::get_used_inputs(), anonymous_namespace{RelAlgExecutor.cpp}::translate_quals(), RelRexDagVisitor::visit(), and anonymous_namespace{QueryPhysicalInputsCollector.cpp}::RelAlgPhysicalInputsVisitor::visitCompound().

1563 { return filter_expr_.get(); }
std::unique_ptr< const RexScalar > filter_expr_

+ Here is the caller graph for this function:

const size_t RelCompound::getGroupByCount ( ) const
inline

Definition at line 1586 of file RelAlgDagBuilder.h.

References groupby_count_.

Referenced by anonymous_namespace{RelAlgExecutor.cpp}::translate_groupby_exprs().

1586 { return groupby_count_; }
const size_t groupby_count_

+ Here is the caller graph for this function:

const ExplainedQueryHint& RelCompound::getHintInfo ( QueryHint  hint) const
inline

Definition at line 1616 of file RelAlgDagBuilder.h.

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

1616  {
1618  CHECK(!hints_->empty());
1619  CHECK(hasHintEnabled(hint));
1620  return hints_->at(hint);
1621  }
std::unique_ptr< Hints > hints_
#define CHECK(condition)
Definition: Logger.h:211
const bool hasHintEnabled(QueryHint candidate_hint) const

+ Here is the call graph for this function:

const RexScalar* RelCompound::getScalarSource ( const size_t  i) const
inline

Definition at line 1577 of file RelAlgDagBuilder.h.

References i, and scalar_sources_.

Referenced by anonymous_namespace{RelAlgExecutor.cpp}::get_used_inputs(), anonymous_namespace{RelAlgExecutor.cpp}::scalar_at(), and anonymous_namespace{QueryPhysicalInputsCollector.cpp}::RelAlgPhysicalInputsVisitor::visitCompound().

1577  {
1578  return scalar_sources_[i].get();
1579  }
std::vector< std::unique_ptr< const RexScalar > > scalar_sources_

+ Here is the caller graph for this function:

const size_t RelCompound::getScalarSourcesSize ( ) const
inline

Definition at line 1575 of file RelAlgDagBuilder.h.

References scalar_sources_.

Referenced by anonymous_namespace{RelAlgExecutor.cpp}::get_scalar_sources_size(), anonymous_namespace{RelAlgExecutor.cpp}::get_used_inputs(), and anonymous_namespace{QueryPhysicalInputsCollector.cpp}::RelAlgPhysicalInputsVisitor::visitCompound().

1575 { return scalar_sources_.size(); }
std::vector< std::unique_ptr< const RexScalar > > scalar_sources_

+ Here is the caller graph for this function:

const Rex* RelCompound::getTargetExpr ( const size_t  i) const
inline

Definition at line 1569 of file RelAlgDagBuilder.h.

References i, and target_exprs_.

Referenced by anonymous_namespace{RelAlgExecutor.cpp}::translate_targets(), and QueryPlanDagChecker::visit().

1569 { return target_exprs_[i]; }
const std::vector< const Rex * > target_exprs_

+ Here is the caller graph for this function:

bool RelCompound::hasDeliveredHint ( )
inline

Definition at line 1623 of file RelAlgDagBuilder.h.

References hints_.

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

Definition at line 1609 of file RelAlgDagBuilder.h.

References hint_applied_, and hints_.

Referenced by getHintInfo().

1609  {
1610  if (hint_applied_ && !hints_->empty()) {
1611  return hints_->find(candidate_hint) != hints_->end();
1612  }
1613  return false;
1614  }
std::unique_ptr< Hints > hints_

+ Here is the caller graph for this function:

bool RelCompound::isAggregate ( ) const
inline

Definition at line 1588 of file RelAlgDagBuilder.h.

References is_agg_.

Referenced by RelAlgExecutor::executeCompound(), anonymous_namespace{RelAlgExecutor.cpp}::translate_groupby_exprs(), and QueryPlanDagChecker::visit().

1588 { return is_agg_; }
const bool is_agg_

+ Here is the caller graph for this function:

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

Reimplemented from RelAlgNode.

Definition at line 325 of file RelAlgDagBuilder.cpp.

References filter_expr_, RelAlgNode::replaceInput(), and scalar_sources_.

326  {
327  RelAlgNode::replaceInput(old_input, input);
328  RexRebindInputsVisitor rebind_inputs(old_input.get(), input.get());
329  for (const auto& scalar_source : scalar_sources_) {
330  rebind_inputs.visit(scalar_source.get());
331  }
332  if (filter_expr_) {
333  rebind_inputs.visit(filter_expr_.get());
334  }
335 }
std::vector< std::unique_ptr< const RexScalar > > scalar_sources_
virtual void replaceInput(std::shared_ptr< const RelAlgNode > old_input, std::shared_ptr< const RelAlgNode > input)
std::unique_ptr< const RexScalar > filter_expr_

+ Here is the call graph for this function:

void RelCompound::setFilterExpr ( std::unique_ptr< const RexScalar > &  new_expr)
inline

Definition at line 1565 of file RelAlgDagBuilder.h.

References filter_expr_.

1565  {
1566  filter_expr_ = std::move(new_expr);
1567  }
std::unique_ptr< const RexScalar > filter_expr_
void RelCompound::setScalarSources ( std::vector< std::unique_ptr< const RexScalar >> &  new_sources)
inline

Definition at line 1581 of file RelAlgDagBuilder.h.

References CHECK_EQ, and scalar_sources_.

1581  {
1582  CHECK_EQ(new_sources.size(), scalar_sources_.size());
1583  scalar_sources_ = std::move(new_sources);
1584  }
#define CHECK_EQ(x, y)
Definition: Logger.h:219
std::vector< std::unique_ptr< const RexScalar > > scalar_sources_
size_t RelCompound::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1561 of file RelAlgDagBuilder.h.

References target_exprs_.

Referenced by RelAlgExecutor::createCompoundWorkUnit(), anonymous_namespace{RelAlgExecutor.cpp}::translate_targets(), and QueryPlanDagChecker::visit().

1561 { return target_exprs_.size(); }
const std::vector< const Rex * > target_exprs_

+ Here is the caller graph for this function:

size_t RelCompound::toHash ( ) const
overridevirtual

Implements RelAlgNode.

Definition at line 2885 of file RelAlgDagBuilder.cpp.

References agg_exprs_, fields_, filter_expr_, groupby_count_, RelAlgNode::hash_, is_agg_, RelCompound(), scalar_sources_, target_exprs_, and toString().

2885  {
2886  if (!hash_) {
2887  hash_ = typeid(RelCompound).hash_code();
2888  boost::hash_combine(*hash_,
2889  filter_expr_ ? filter_expr_->toHash() : boost::hash_value("n"));
2890  boost::hash_combine(*hash_, is_agg_);
2891  for (auto& target_expr : target_exprs_) {
2892  if (auto rex_scalar = dynamic_cast<const RexScalar*>(target_expr)) {
2893  boost::hash_combine(*hash_, rex_scalar->toHash());
2894  }
2895  }
2896  for (auto& agg_expr : agg_exprs_) {
2897  boost::hash_combine(*hash_, agg_expr->toHash());
2898  }
2899  for (auto& scalar_source : scalar_sources_) {
2900  boost::hash_combine(*hash_, scalar_source->toHash());
2901  }
2902  boost::hash_combine(*hash_, groupby_count_);
2903  boost::hash_combine(*hash_, ::toString(fields_));
2904  }
2905  return *hash_;
2906 }
RelCompound(std::unique_ptr< const RexScalar > &filter_expr, const std::vector< const Rex * > &target_exprs, const size_t groupby_count, const std::vector< const RexAgg * > &agg_exprs, const std::vector< std::string > &fields, std::vector< std::unique_ptr< const RexScalar >> &scalar_sources, const bool is_agg, bool update_disguised_as_select=false, bool delete_disguised_as_select=false, bool varlen_update_required=false, TableDescriptor const *manipulation_target_table=nullptr, ColumnNameList target_columns=ColumnNameList())
const std::vector< std::string > fields_
std::string toString() const override
std::vector< std::unique_ptr< const RexScalar > > scalar_sources_
const size_t groupby_count_
std::optional< size_t > hash_
const std::vector< const Rex * > target_exprs_
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
std::unique_ptr< const RexScalar > filter_expr_
const bool is_agg_

+ Here is the call graph for this function:

std::string RelCompound::toString ( ) const
overridevirtual

Implements RelAlgNode.

Definition at line 2866 of file RelAlgDagBuilder.cpp.

References agg_exprs_, cat(), fields_, filter_expr_, groupby_count_, is_agg_, scalar_sources_, target_exprs_, to_string(), and typeName().

Referenced by toHash().

2866  {
2867  return cat(::typeName(this),
2868  "(",
2869  (filter_expr_ ? filter_expr_->toString() : "null"),
2870  ", target_exprs=",
2872  ", ",
2874  ", agg_exps=",
2876  ", fields=",
2878  ", scalar_sources=",
2880  ", is_agg=",
2882  ")");
2883 }
std::string cat(Ts &&...args)
const std::vector< std::string > fields_
std::string toString() const override
std::vector< std::unique_ptr< const RexScalar > > scalar_sources_
std::string to_string(char const *&&v)
const size_t groupby_count_
const std::vector< const Rex * > target_exprs_
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
std::unique_ptr< const RexScalar > filter_expr_
std::string typeName(const T *v)
Definition: toString.h:93
const bool is_agg_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

std::vector<std::unique_ptr<const RexAgg> > RelCompound::agg_exprs_
private

Definition at line 1630 of file RelAlgDagBuilder.h.

Referenced by getAggExpr(), getAggExprSize(), RelCompound(), toHash(), and toString().

const std::vector<std::string> RelCompound::fields_
private

Definition at line 1631 of file RelAlgDagBuilder.h.

Referenced by getFieldName(), getFields(), toHash(), and toString().

std::unique_ptr<const RexScalar> RelCompound::filter_expr_
private
const size_t RelCompound::groupby_count_
private

Definition at line 1629 of file RelAlgDagBuilder.h.

Referenced by getGroupByCount(), toHash(), and toString().

bool RelCompound::hint_applied_
private

Definition at line 1637 of file RelAlgDagBuilder.h.

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

std::unique_ptr<Hints> RelCompound::hints_
private
const bool RelCompound::is_agg_
private

Definition at line 1632 of file RelAlgDagBuilder.h.

Referenced by isAggregate(), toHash(), and toString().

std::vector<std::unique_ptr<const RexScalar> > RelCompound::scalar_sources_
private
const std::vector<const Rex*> RelCompound::target_exprs_
private

Definition at line 1636 of file RelAlgDagBuilder.h.

Referenced by getTargetExpr(), size(), toHash(), and toString().


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