OmniSciDB  8a228a1076
RelAggregate Class Reference

#include <RelAlgDagBuilder.h>

+ Inheritance diagram for RelAggregate:
+ Collaboration diagram for RelAggregate:

Public Member Functions

 RelAggregate (const size_t groupby_count, std::vector< std::unique_ptr< const RexAgg >> &agg_exprs, const std::vector< std::string > &fields, std::shared_ptr< const RelAlgNode > input)
 
 RelAggregate (RelAggregate const &)
 
size_t size () const override
 
const size_t getGroupByCount () const
 
const size_t getAggExprsCount () const
 
const std::vector< std::string > & getFields () const
 
void setFields (std::vector< std::string > &new_fields)
 
const std::string getFieldName (const size_t i) const
 
std::vector< const RexAgg * > getAggregatesAndRelease ()
 
std::vector< std::unique_ptr< const RexAgg > > getAggExprsAndRelease ()
 
const std::vector< std::unique_ptr< const RexAgg > > & getAggExprs () const
 
void setAggExprs (std::vector< std::unique_ptr< const RexAgg >> &agg_exprs)
 
std::string toString () const override
 
std::shared_ptr< RelAlgNodedeepCopy () const override
 
void addHint (const HintExplained &hint_explained)
 
const bool hasHintEnabled (const std::string &candidate_hint_name) const
 
const HintExplainedgetHintInfo (const std::string &hint_name) const
 
- Public Member Functions inherited from RelAlgNode
 RelAlgNode (RelAlgInputs inputs={})
 
virtual ~RelAlgNode ()
 
void resetQueryExecutionState ()
 
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

const size_t groupby_count_
 
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
 
std::vector< std::string > fields_
 
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_
 

Detailed Description

Definition at line 1025 of file RelAlgDagBuilder.h.

Constructor & Destructor Documentation

◆ RelAggregate() [1/2]

RelAggregate::RelAggregate ( const size_t  groupby_count,
std::vector< std::unique_ptr< const RexAgg >> &  agg_exprs,
const std::vector< std::string > &  fields,
std::shared_ptr< const RelAlgNode input 
)
inline

Definition at line 1028 of file RelAlgDagBuilder.h.

1032  : groupby_count_(groupby_count)
1033  , agg_exprs_(std::move(agg_exprs))
1034  , fields_(fields)
1035  , hint_applied_(false)
1036  , hints_(std::make_unique<Hints>()) {
1037  inputs_.push_back(input);
1038  }
const size_t groupby_count_
std::unique_ptr< Hints > hints_
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
std::vector< std::string > fields_
RelAlgInputs inputs_

◆ RelAggregate() [2/2]

RelAggregate::RelAggregate ( RelAggregate const &  rhs)

Definition at line 364 of file RelAlgDagBuilder.cpp.

References addHint(), agg_exprs_, hint_applied_, and hints_.

365  : RelAlgNode(rhs)
366  , groupby_count_(rhs.groupby_count_)
367  , fields_(rhs.fields_)
368  , hint_applied_(false)
369  , hints_(std::make_unique<Hints>()) {
370  agg_exprs_.reserve(rhs.agg_exprs_.size());
371  for (auto const& agg : rhs.agg_exprs_) {
372  agg_exprs_.push_back(agg->deepCopy());
373  }
374  if (rhs.hint_applied_) {
375  for (auto const& kv : *rhs.hints_) {
376  addHint(kv.second);
377  }
378  }
379 }
RelAlgNode(RelAlgInputs inputs={})
void addHint(const HintExplained &hint_explained)
const size_t groupby_count_
std::unique_ptr< Hints > hints_
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
std::vector< std::string > fields_
+ Here is the call graph for this function:

Member Function Documentation

◆ addHint()

void RelAggregate::addHint ( const HintExplained hint_explained)
inline

Definition at line 1092 of file RelAlgDagBuilder.h.

References HintExplained::getHintName().

Referenced by RelAggregate().

1092  {
1093  if (!hint_applied_) {
1094  hint_applied_ = true;
1095  }
1096  hints_->emplace(hint_explained.getHintName(), hint_explained);
1097  }
std::unique_ptr< Hints > hints_
const std::string & getHintName() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deepCopy()

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

Implements RelAlgNode.

Definition at line 1088 of file RelAlgDagBuilder.h.

1088  {
1089  return std::make_shared<RelAggregate>(*this);
1090  }

◆ getAggExprs()

const std::vector<std::unique_ptr<const RexAgg> >& RelAggregate::getAggExprs ( ) const
inline

Definition at line 1067 of file RelAlgDagBuilder.h.

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

1067  {
1068  return agg_exprs_;
1069  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
+ Here is the caller graph for this function:

◆ getAggExprsAndRelease()

std::vector<std::unique_ptr<const RexAgg> > RelAggregate::getAggExprsAndRelease ( )
inline

Definition at line 1063 of file RelAlgDagBuilder.h.

1063  {
1064  return std::move(agg_exprs_);
1065  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_

◆ getAggExprsCount()

const size_t RelAggregate::getAggExprsCount ( ) const
inline

Definition at line 1046 of file RelAlgDagBuilder.h.

1046 { return agg_exprs_.size(); }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_

◆ getAggregatesAndRelease()

std::vector<const RexAgg*> RelAggregate::getAggregatesAndRelease ( )
inline

Definition at line 1055 of file RelAlgDagBuilder.h.

References run_benchmark_import::result.

1055  {
1056  std::vector<const RexAgg*> result;
1057  for (auto& agg_expr : agg_exprs_) {
1058  result.push_back(agg_expr.release());
1059  }
1060  return result;
1061  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_

◆ getFieldName()

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

Definition at line 1053 of file RelAlgDagBuilder.h.

1053 { return fields_[i]; }
std::vector< std::string > fields_

◆ getFields()

const std::vector<std::string>& RelAggregate::getFields ( ) const
inline

Definition at line 1048 of file RelAlgDagBuilder.h.

1048 { return fields_; }
std::vector< std::string > fields_

◆ getGroupByCount()

const size_t RelAggregate::getGroupByCount ( ) const
inline

Definition at line 1044 of file RelAlgDagBuilder.h.

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

1044 { return groupby_count_; }
const size_t groupby_count_
+ Here is the caller graph for this function:

◆ getHintInfo()

const HintExplained& RelAggregate::getHintInfo ( const std::string &  hint_name) const
inline

Definition at line 1106 of file RelAlgDagBuilder.h.

References CHECK.

1106  {
1108  CHECK(!hints_->empty());
1109  CHECK(hasHintEnabled(hint_name));
1110  return hints_->at(hint_name);
1111  }
const bool hasHintEnabled(const std::string &candidate_hint_name) const
std::unique_ptr< Hints > hints_
#define CHECK(condition)
Definition: Logger.h:197

◆ hasHintEnabled()

const bool RelAggregate::hasHintEnabled ( const std::string &  candidate_hint_name) const
inline

Definition at line 1099 of file RelAlgDagBuilder.h.

1099  {
1100  if (hint_applied_ && !hints_->empty()) {
1101  return hints_->find(candidate_hint_name) != hints_->end();
1102  }
1103  return false;
1104  }
std::unique_ptr< Hints > hints_

◆ setAggExprs()

void RelAggregate::setAggExprs ( std::vector< std::unique_ptr< const RexAgg >> &  agg_exprs)
inline

Definition at line 1071 of file RelAlgDagBuilder.h.

1071  {
1072  agg_exprs_ = std::move(agg_exprs);
1073  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_

◆ setFields()

void RelAggregate::setFields ( std::vector< std::string > &  new_fields)
inline

Definition at line 1049 of file RelAlgDagBuilder.h.

1049  {
1050  fields_ = std::move(new_fields);
1051  }
std::vector< std::string > fields_

◆ size()

size_t RelAggregate::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1042 of file RelAlgDagBuilder.h.

1042 { return groupby_count_ + agg_exprs_.size(); }
const size_t groupby_count_
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_

◆ toString()

std::string RelAggregate::toString ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1075 of file RelAlgDagBuilder.h.

References run_benchmark_import::result, and to_string().

1075  {
1076  std::string result = "(RelAggregate<" +
1077  std::to_string(reinterpret_cast<uint64_t>(this)) + ">(groups: [";
1078  for (size_t group_index = 0; group_index < groupby_count_; ++group_index) {
1079  result += " " + std::to_string(group_index);
1080  }
1081  result += " ] aggs: [";
1082  for (const auto& agg_expr : agg_exprs_) {
1083  result += " " + agg_expr->toString();
1084  }
1085  return result + " ]))";
1086  }
std::string to_string(char const *&&v)
const size_t groupby_count_
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
+ Here is the call graph for this function:

Member Data Documentation

◆ agg_exprs_

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

Definition at line 1115 of file RelAlgDagBuilder.h.

Referenced by RelAggregate().

◆ fields_

std::vector<std::string> RelAggregate::fields_
private

Definition at line 1116 of file RelAlgDagBuilder.h.

◆ groupby_count_

const size_t RelAggregate::groupby_count_
private

Definition at line 1114 of file RelAlgDagBuilder.h.

◆ hint_applied_

bool RelAggregate::hint_applied_
private

Definition at line 1117 of file RelAlgDagBuilder.h.

Referenced by RelAggregate().

◆ hints_

std::unique_ptr<Hints> RelAggregate::hints_
private

Definition at line 1118 of file RelAlgDagBuilder.h.

Referenced by RelAggregate().


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