OmniSciDB  72180abbfe
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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)
 
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 1012 of file RelAlgDagBuilder.h.

Constructor & Destructor Documentation

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 1015 of file RelAlgDagBuilder.h.

References RelAlgNode::inputs_.

1019  : groupby_count_(groupby_count)
1020  , agg_exprs_(std::move(agg_exprs))
1021  , fields_(fields)
1022  , hint_applied_(false)
1023  , hints_(std::make_unique<Hints>()) {
1024  inputs_.push_back(input);
1025  }
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_

Member Function Documentation

void RelAggregate::addHint ( const HintExplained hint_explained)
inline

Definition at line 1075 of file RelAlgDagBuilder.h.

References HintExplained::getHintName().

1075  {
1076  if (!hint_applied_) {
1077  hint_applied_ = true;
1078  }
1079  hints_->emplace(hint_explained.getHintName(), hint_explained);
1080  }
std::unique_ptr< Hints > hints_
const std::string & getHintName() const

+ Here is the call graph for this function:

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

Implements RelAlgNode.

Definition at line 368 of file RelAlgDagBuilder.cpp.

References agg_exprs_, fields_, groupby_count_, hint_applied_, hints_, and RelAlgNode::inputs_.

368  {
369  std::vector<std::unique_ptr<const RexAgg>> aggs_copy;
370  for (auto& agg : agg_exprs_) {
371  auto copy = agg->deepCopy();
372  aggs_copy.push_back(std::move(copy));
373  }
374  if (hint_applied_) {
375  auto copied =
376  std::make_shared<RelAggregate>(groupby_count_, aggs_copy, fields_, inputs_[0]);
377  for (auto& kv : *hints_) {
378  copied->addHint(kv.second);
379  }
380  return copied;
381  }
382  return std::make_shared<RelAggregate>(groupby_count_, aggs_copy, fields_, inputs_[0]);
383 }
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_
const std::vector<std::unique_ptr<const RexAgg> >& RelAggregate::getAggExprs ( ) const
inline

Definition at line 1052 of file RelAlgDagBuilder.h.

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

1052  {
1053  return agg_exprs_;
1054  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_

+ Here is the caller graph for this function:

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

Definition at line 1048 of file RelAlgDagBuilder.h.

1048  {
1049  return std::move(agg_exprs_);
1050  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
const size_t RelAggregate::getAggExprsCount ( ) const
inline

Definition at line 1031 of file RelAlgDagBuilder.h.

1031 { return agg_exprs_.size(); }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
std::vector<const RexAgg*> RelAggregate::getAggregatesAndRelease ( )
inline

Definition at line 1040 of file RelAlgDagBuilder.h.

References run_benchmark_import::result.

1040  {
1041  std::vector<const RexAgg*> result;
1042  for (auto& agg_expr : agg_exprs_) {
1043  result.push_back(agg_expr.release());
1044  }
1045  return result;
1046  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
const std::string RelAggregate::getFieldName ( const size_t  i) const
inline

Definition at line 1038 of file RelAlgDagBuilder.h.

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

Definition at line 1033 of file RelAlgDagBuilder.h.

1033 { return fields_; }
std::vector< std::string > fields_
const size_t RelAggregate::getGroupByCount ( ) const
inline

Definition at line 1029 of file RelAlgDagBuilder.h.

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

1029 { return groupby_count_; }
const size_t groupby_count_

+ Here is the caller graph for this function:

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

Definition at line 1089 of file RelAlgDagBuilder.h.

References CHECK().

1089  {
1091  CHECK(!hints_->empty());
1092  CHECK(hasHintEnabled(hint_name));
1093  return hints_->at(hint_name);
1094  }
CHECK(cgen_state)
std::unique_ptr< Hints > hints_
const bool hasHintEnabled(const std::string &candidate_hint_name) const

+ Here is the call graph for this function:

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

Definition at line 1082 of file RelAlgDagBuilder.h.

1082  {
1083  if (hint_applied_ && !hints_->empty()) {
1084  return hints_->find(candidate_hint_name) != hints_->end();
1085  }
1086  return false;
1087  }
std::unique_ptr< Hints > hints_
void RelAggregate::setAggExprs ( std::vector< std::unique_ptr< const RexAgg >> &  agg_exprs)
inline

Definition at line 1056 of file RelAlgDagBuilder.h.

1056  {
1057  agg_exprs_ = std::move(agg_exprs);
1058  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
void RelAggregate::setFields ( std::vector< std::string > &  new_fields)
inline

Definition at line 1034 of file RelAlgDagBuilder.h.

1034  {
1035  fields_ = std::move(new_fields);
1036  }
std::vector< std::string > fields_
size_t RelAggregate::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1027 of file RelAlgDagBuilder.h.

1027 { return groupby_count_ + agg_exprs_.size(); }
const size_t groupby_count_
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
std::string RelAggregate::toString ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1060 of file RelAlgDagBuilder.h.

References run_benchmark_import::result, and to_string().

1060  {
1061  std::string result = "(RelAggregate<" +
1062  std::to_string(reinterpret_cast<uint64_t>(this)) + ">(groups: [";
1063  for (size_t group_index = 0; group_index < groupby_count_; ++group_index) {
1064  result += " " + std::to_string(group_index);
1065  }
1066  result += " ] aggs: [";
1067  for (const auto& agg_expr : agg_exprs_) {
1068  result += " " + agg_expr->toString();
1069  }
1070  return result + " ]))";
1071  }
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

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

Definition at line 1098 of file RelAlgDagBuilder.h.

Referenced by deepCopy().

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

Definition at line 1099 of file RelAlgDagBuilder.h.

Referenced by deepCopy().

const size_t RelAggregate::groupby_count_
private

Definition at line 1097 of file RelAlgDagBuilder.h.

Referenced by deepCopy().

bool RelAggregate::hint_applied_
private

Definition at line 1100 of file RelAlgDagBuilder.h.

Referenced by deepCopy().

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

Definition at line 1101 of file RelAlgDagBuilder.h.

Referenced by deepCopy().


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