OmniSciDB  085a039ca4
 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 (RelRexToStringConfig config=RelRexToStringConfig::defaults()) 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
 
void setQueryPlanDag (const std::string &extracted_query_plan_dag) const
 
std::string getQueryPlanDag () const
 
size_t getQueryPlanDagHash () const
 
const std::vector
< TargetMetaInfo > & 
getOutputMetainfo () const
 
unsigned getId () const
 
void setIdInPlanTree (size_t id) const
 
std::optional< size_t > getIdInPlanTree () 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 > id_in_plan_tree_
 
std::optional< size_t > hash_
 

Detailed Description

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

References RelAlgNode::inputs_.

Referenced by toHash().

1169  : groupby_count_(groupby_count)
1170  , agg_exprs_(std::move(agg_exprs))
1171  , fields_(fields)
1172  , hint_applied_(false)
1173  , hints_(std::make_unique<Hints>()) {
1174  inputs_.push_back(input);
1175  }
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 583 of file RelAlgDagBuilder.cpp.

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

584  : RelAlgNode(rhs)
585  , groupby_count_(rhs.groupby_count_)
586  , fields_(rhs.fields_)
587  , hint_applied_(false)
588  , hints_(std::make_unique<Hints>()) {
589  agg_exprs_.reserve(rhs.agg_exprs_.size());
590  for (auto const& agg : rhs.agg_exprs_) {
591  agg_exprs_.push_back(agg->deepCopy());
592  }
593  if (rhs.hint_applied_) {
594  for (auto const& kv : *rhs.hints_) {
595  addHint(kv.second);
596  }
597  }
598 }
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 1255 of file RelAlgDagBuilder.h.

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

Referenced by RelAggregate().

1255  {
1256  if (!hint_applied_) {
1257  hint_applied_ = true;
1258  }
1259  hints_->emplace(hint_explained.getHint(), hint_explained);
1260  }
std::unique_ptr< Hints > hints_
const QueryHint getHint() const
Definition: QueryHint.h:121

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

1251  {
1252  return std::make_shared<RelAggregate>(*this);
1253  }
const std::vector<std::unique_ptr<const RexAgg> >& RelAggregate::getAggExprs ( ) const
inline

Definition at line 1204 of file RelAlgDagBuilder.h.

References agg_exprs_.

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

1204  {
1205  return agg_exprs_;
1206  }
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 1200 of file RelAlgDagBuilder.h.

References agg_exprs_.

1200  {
1201  return std::move(agg_exprs_);
1202  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
const size_t RelAggregate::getAggExprsCount ( ) const
inline

Definition at line 1183 of file RelAlgDagBuilder.h.

References agg_exprs_.

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

Definition at line 1192 of file RelAlgDagBuilder.h.

References agg_exprs_, and run_benchmark_import::result.

1192  {
1193  std::vector<const RexAgg*> result;
1194  for (auto& agg_expr : agg_exprs_) {
1195  result.push_back(agg_expr.release());
1196  }
1197  return result;
1198  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Hints* RelAggregate::getDeliveredHints ( )
inline

Definition at line 1278 of file RelAlgDagBuilder.h.

References hints_.

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

1278 { 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 1190 of file RelAlgDagBuilder.h.

References fields_.

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

Definition at line 1185 of file RelAlgDagBuilder.h.

References fields_.

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

Definition at line 1181 of file RelAlgDagBuilder.h.

References groupby_count_.

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

1181 { 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 1269 of file RelAlgDagBuilder.h.

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

1269  {
1271  CHECK(!hints_->empty());
1272  CHECK(hasHintEnabled(hint));
1273  return hints_->at(hint);
1274  }
const bool hasHintEnabled(QueryHint candidate_hint) const
std::unique_ptr< Hints > hints_
#define CHECK(condition)
Definition: Logger.h:223

+ Here is the call graph for this function:

bool RelAggregate::hasDeliveredHint ( )
inline

Definition at line 1276 of file RelAlgDagBuilder.h.

References hints_.

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

Definition at line 1262 of file RelAlgDagBuilder.h.

References hint_applied_, and hints_.

Referenced by getHintInfo().

1262  {
1263  if (hint_applied_ && !hints_->empty()) {
1264  return hints_->find(candidate_hint) != hints_->end();
1265  }
1266  return false;
1267  }
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 1208 of file RelAlgDagBuilder.h.

References agg_exprs_.

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

Definition at line 1186 of file RelAlgDagBuilder.h.

References fields_.

1186  {
1187  fields_ = std::move(new_fields);
1188  }
std::vector< std::string > fields_
size_t RelAggregate::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1179 of file RelAlgDagBuilder.h.

References agg_exprs_, and groupby_count_.

1179 { 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 1236 of file RelAlgDagBuilder.h.

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

1236  {
1237  if (!hash_) {
1238  hash_ = typeid(RelAggregate).hash_code();
1239  boost::hash_combine(*hash_, groupby_count_);
1240  for (auto& agg_expr : agg_exprs_) {
1241  boost::hash_combine(*hash_, agg_expr->toHash());
1242  }
1243  for (auto& node : inputs_) {
1244  boost::hash_combine(*hash_, node->toHash());
1245  }
1246  boost::hash_combine(*hash_, ::toString(fields_));
1247  }
1248  return *hash_;
1249  }
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) 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 ( RelRexToStringConfig  config = RelRexToStringConfig::defaults()) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1212 of file RelAlgDagBuilder.h.

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

Referenced by toHash().

1213  {
1214  auto ret = cat(::typeName(this),
1215  "(",
1217  ", agg_exprs=",
1218  ::toString(agg_exprs_),
1219  ", fields=",
1220  ::toString(fields_));
1221  if (!config.skip_input_nodes) {
1222  ret += ::toString(inputs_);
1223  } else {
1224  ret += ", input node id={";
1225  for (auto& input : inputs_) {
1226  auto node_id_in_plan = input->getIdInPlanTree();
1227  auto node_id_str = node_id_in_plan ? std::to_string(*node_id_in_plan)
1228  : std::to_string(input->getId());
1229  ret += node_id_str + " ";
1230  }
1231  ret += "}";
1232  }
1233  return cat(ret, ")");
1234  }
std::string cat(Ts &&...args)
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
std::string to_string(char const *&&v)
const size_t groupby_count_
unsigned getId() const
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
std::string typeName(const T *v)
Definition: toString.h:102
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 1283 of file RelAlgDagBuilder.h.

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

const size_t RelAggregate::groupby_count_
private

Definition at line 1281 of file RelAlgDagBuilder.h.

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

bool RelAggregate::hint_applied_
private

Definition at line 1284 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: