OmniSciDB  d2f719934e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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)
 
 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
 
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
 
virtual void replaceInput (std::shared_ptr< const RelAlgNode > old_input, std::shared_ptr< const RelAlgNode > input)
 
void setRelNodeDagId (const size_t id) const
 
size_t getRelNodeDagId () const
 
bool isNop () const
 
void markAsNop ()
 
void clearContextData () const
 

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_
 
std::optional< size_t > hash_
 

Detailed Description

Definition at line 1098 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 1101 of file RelAlgDagBuilder.h.

References RelAlgNode::inputs_.

Referenced by toHash().

1105  : groupby_count_(groupby_count)
1106  , agg_exprs_(std::move(agg_exprs))
1107  , fields_(fields)
1108  , hint_applied_(false)
1109  , hints_(std::make_unique<Hints>()) {
1110  inputs_.push_back(input);
1111  }
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_

+ Here is the caller graph for this function:

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 ExplainedQueryHint &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

void RelAggregate::addHint ( const ExplainedQueryHint hint_explained)
inline

Definition at line 1180 of file RelAlgDagBuilder.h.

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

Referenced by RelAggregate().

1180  {
1181  if (!hint_applied_) {
1182  hint_applied_ = true;
1183  }
1184  hints_->emplace(hint_explained.getHint(), hint_explained);
1185  }
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> RelAggregate::deepCopy ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1176 of file RelAlgDagBuilder.h.

1176  {
1177  return std::make_shared<RelAggregate>(*this);
1178  }
const std::vector<std::unique_ptr<const RexAgg> >& RelAggregate::getAggExprs ( ) const
inline

Definition at line 1140 of file RelAlgDagBuilder.h.

References agg_exprs_.

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

1140  {
1141  return agg_exprs_;
1142  }
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 1136 of file RelAlgDagBuilder.h.

References agg_exprs_.

1136  {
1137  return std::move(agg_exprs_);
1138  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
const size_t RelAggregate::getAggExprsCount ( ) const
inline

Definition at line 1119 of file RelAlgDagBuilder.h.

References agg_exprs_.

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

Definition at line 1128 of file RelAlgDagBuilder.h.

References agg_exprs_, and run_benchmark_import::result.

1128  {
1129  std::vector<const RexAgg*> result;
1130  for (auto& agg_expr : agg_exprs_) {
1131  result.push_back(agg_expr.release());
1132  }
1133  return result;
1134  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Hints* RelAggregate::getDeliveredHints ( )
inline

Definition at line 1203 of file RelAlgDagBuilder.h.

References hints_.

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

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

+ Here is the caller graph for this function:

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

Definition at line 1126 of file RelAlgDagBuilder.h.

References fields_, and i.

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

Definition at line 1121 of file RelAlgDagBuilder.h.

References fields_.

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

Definition at line 1117 of file RelAlgDagBuilder.h.

References groupby_count_.

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

1117 { return groupby_count_; }
const size_t groupby_count_

+ Here is the caller graph for this function:

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

Definition at line 1194 of file RelAlgDagBuilder.h.

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

1194  {
1196  CHECK(!hints_->empty());
1197  CHECK(hasHintEnabled(hint));
1198  return hints_->at(hint);
1199  }
const bool hasHintEnabled(QueryHint candidate_hint) const
std::unique_ptr< Hints > hints_
#define CHECK(condition)
Definition: Logger.h:211

+ Here is the call graph for this function:

bool RelAggregate::hasDeliveredHint ( )
inline

Definition at line 1201 of file RelAlgDagBuilder.h.

References hints_.

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

Definition at line 1187 of file RelAlgDagBuilder.h.

References hint_applied_, and hints_.

Referenced by getHintInfo().

1187  {
1188  if (hint_applied_ && !hints_->empty()) {
1189  return hints_->find(candidate_hint) != hints_->end();
1190  }
1191  return false;
1192  }
std::unique_ptr< Hints > hints_

+ Here is the caller graph for this function:

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

Definition at line 1144 of file RelAlgDagBuilder.h.

References agg_exprs_.

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

Definition at line 1122 of file RelAlgDagBuilder.h.

References fields_.

1122  {
1123  fields_ = std::move(new_fields);
1124  }
std::vector< std::string > fields_
size_t RelAggregate::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1115 of file RelAlgDagBuilder.h.

References agg_exprs_, and groupby_count_.

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

Implements RelAlgNode.

Definition at line 1161 of file RelAlgDagBuilder.h.

References agg_exprs_, fields_, groupby_count_, RelAlgNode::hash_, RelAlgNode::inputs_, RelAggregate(), and toString().

1161  {
1162  if (!hash_) {
1163  hash_ = typeid(RelAggregate).hash_code();
1164  boost::hash_combine(*hash_, groupby_count_);
1165  for (auto& agg_expr : agg_exprs_) {
1166  boost::hash_combine(*hash_, agg_expr->toHash());
1167  }
1168  for (auto& node : inputs_) {
1169  boost::hash_combine(*hash_, node->toHash());
1170  }
1171  boost::hash_combine(*hash_, ::toString(fields_));
1172  }
1173  return *hash_;
1174  }
std::string toString() const override
const size_t groupby_count_
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)
std::optional< size_t > hash_
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
std::vector< std::string > fields_
RelAlgInputs inputs_

+ Here is the call graph for this function:

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

Implements RelAlgNode.

Definition at line 1148 of file RelAlgDagBuilder.h.

References agg_exprs_, cat(), fields_, groupby_count_, RelAlgNode::inputs_, to_string(), and typeName().

Referenced by toHash().

1148  {
1149  return cat(::typeName(this),
1150  "(",
1152  ", agg_exprs=",
1153  ::toString(agg_exprs_),
1154  ", fields=",
1155  ::toString(fields_),
1156  ", inputs=",
1157  ::toString(inputs_),
1158  ")");
1159  }
std::string cat(Ts &&...args)
std::string toString() const override
std::string to_string(char const *&&v)
const size_t groupby_count_
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
std::string typeName(const T *v)
Definition: toString.h:93
std::vector< std::string > fields_
RelAlgInputs inputs_

+ 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> > RelAggregate::agg_exprs_
private
std::vector<std::string> RelAggregate::fields_
private

Definition at line 1208 of file RelAlgDagBuilder.h.

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

const size_t RelAggregate::groupby_count_
private

Definition at line 1206 of file RelAlgDagBuilder.h.

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

bool RelAggregate::hint_applied_
private

Definition at line 1209 of file RelAlgDagBuilder.h.

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

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

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