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

#include <RelAlgDag.h>

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

Public Member Functions

 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)
 
 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 (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

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_
 

Friends

struct RelAlgDagSerializer
 

Additional Inherited Members

- Static Public Member Functions inherited from RelAlgNode
static void resetRelAlgFirstId () noexcept
 
- Protected Attributes inherited from RelAlgNode
RelAlgInputs inputs_
 
unsigned id_
 
std::optional< size_t > id_in_plan_tree_
 
std::optional< size_t > hash_
 

Detailed Description

Definition at line 1302 of file RelAlgDag.h.

Constructor & Destructor Documentation

RelAggregate::RelAggregate ( )
inline

Definition at line 1305 of file RelAlgDag.h.

Referenced by toHash().

1305 : groupby_count_{0}, hint_applied_{false} {}
size_t groupby_count_
Definition: RelAlgDag.h:1424
bool hint_applied_
Definition: RelAlgDag.h:1427

+ Here is the caller graph for this function:

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 1308 of file RelAlgDag.h.

References RelAlgNode::inputs_.

1312  : groupby_count_(groupby_count)
1313  , agg_exprs_(std::move(agg_exprs))
1314  , fields_(fields)
1315  , hint_applied_(false)
1316  , hints_(std::make_unique<Hints>()) {
1317  inputs_.push_back(input);
1318  }
size_t groupby_count_
Definition: RelAlgDag.h:1424
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1428
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1425
bool hint_applied_
Definition: RelAlgDag.h:1427
std::vector< std::string > fields_
Definition: RelAlgDag.h:1426
RelAlgInputs inputs_
Definition: RelAlgDag.h:952
RelAggregate::RelAggregate ( RelAggregate const &  rhs)

Definition at line 583 of file RelAlgDag.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={})
Definition: RelAlgDag.h:840
size_t groupby_count_
Definition: RelAlgDag.h:1424
void addHint(const ExplainedQueryHint &hint_explained)
Definition: RelAlgDag.h:1398
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1428
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1425
bool hint_applied_
Definition: RelAlgDag.h:1427
std::vector< std::string > fields_
Definition: RelAlgDag.h:1426

+ Here is the call graph for this function:

Member Function Documentation

void RelAggregate::addHint ( const ExplainedQueryHint hint_explained)
inline

Definition at line 1398 of file RelAlgDag.h.

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

Referenced by RelAggregate().

1398  {
1399  if (!hint_applied_) {
1400  hint_applied_ = true;
1401  }
1402  hints_->emplace(hint_explained.getHint(), hint_explained);
1403  }
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1428
bool hint_applied_
Definition: RelAlgDag.h:1427
const QueryHint getHint() const
Definition: QueryHint.h:154

+ 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 1394 of file RelAlgDag.h.

1394  {
1395  return std::make_shared<RelAggregate>(*this);
1396  }
const std::vector<std::unique_ptr<const RexAgg> >& RelAggregate::getAggExprs ( ) const
inline

Definition at line 1347 of file RelAlgDag.h.

References agg_exprs_.

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

1347  {
1348  return agg_exprs_;
1349  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1425

+ Here is the caller graph for this function:

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

Definition at line 1343 of file RelAlgDag.h.

References agg_exprs_.

1343  {
1344  return std::move(agg_exprs_);
1345  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1425
const size_t RelAggregate::getAggExprsCount ( ) const
inline

Definition at line 1326 of file RelAlgDag.h.

References agg_exprs_.

1326 { return agg_exprs_.size(); }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1425
std::vector<const RexAgg*> RelAggregate::getAggregatesAndRelease ( )
inline

Definition at line 1335 of file RelAlgDag.h.

References agg_exprs_, and run_benchmark_import::result.

1335  {
1336  std::vector<const RexAgg*> result;
1337  for (auto& agg_expr : agg_exprs_) {
1338  result.push_back(agg_expr.release());
1339  }
1340  return result;
1341  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1425
Hints* RelAggregate::getDeliveredHints ( )
inline

Definition at line 1421 of file RelAlgDag.h.

References hints_.

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

1421 { return hints_.get(); }
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1428

+ Here is the caller graph for this function:

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

Definition at line 1333 of file RelAlgDag.h.

References fields_.

1333 { return fields_[i]; }
std::vector< std::string > fields_
Definition: RelAlgDag.h:1426
const std::vector<std::string>& RelAggregate::getFields ( ) const
inline

Definition at line 1328 of file RelAlgDag.h.

References fields_.

1328 { return fields_; }
std::vector< std::string > fields_
Definition: RelAlgDag.h:1426
const size_t RelAggregate::getGroupByCount ( ) const
inline

Definition at line 1324 of file RelAlgDag.h.

References groupby_count_.

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

1324 { return groupby_count_; }
size_t groupby_count_
Definition: RelAlgDag.h:1424

+ Here is the caller graph for this function:

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

Definition at line 1412 of file RelAlgDag.h.

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

1412  {
1414  CHECK(!hints_->empty());
1415  CHECK(hasHintEnabled(hint));
1416  return hints_->at(hint);
1417  }
const bool hasHintEnabled(QueryHint candidate_hint) const
Definition: RelAlgDag.h:1405
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1428
bool hint_applied_
Definition: RelAlgDag.h:1427
#define CHECK(condition)
Definition: Logger.h:289

+ Here is the call graph for this function:

bool RelAggregate::hasDeliveredHint ( )
inline

Definition at line 1419 of file RelAlgDag.h.

References hints_.

1419 { return !hints_->empty(); }
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1428
const bool RelAggregate::hasHintEnabled ( QueryHint  candidate_hint) const
inline

Definition at line 1405 of file RelAlgDag.h.

References hint_applied_, and hints_.

Referenced by getHintInfo().

1405  {
1406  if (hint_applied_ && !hints_->empty()) {
1407  return hints_->find(candidate_hint) != hints_->end();
1408  }
1409  return false;
1410  }
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1428
bool hint_applied_
Definition: RelAlgDag.h:1427

+ Here is the caller graph for this function:

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

Definition at line 1351 of file RelAlgDag.h.

References agg_exprs_.

1351  {
1352  agg_exprs_ = std::move(agg_exprs);
1353  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1425
void RelAggregate::setFields ( std::vector< std::string > &&  new_fields)
inline

Definition at line 1329 of file RelAlgDag.h.

References fields_.

1329  {
1330  fields_ = std::move(new_fields);
1331  }
std::vector< std::string > fields_
Definition: RelAlgDag.h:1426
size_t RelAggregate::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1322 of file RelAlgDag.h.

References agg_exprs_, and groupby_count_.

1322 { return groupby_count_ + agg_exprs_.size(); }
size_t groupby_count_
Definition: RelAlgDag.h:1424
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1425
size_t RelAggregate::toHash ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1379 of file RelAlgDag.h.

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

1379  {
1380  if (!hash_) {
1381  hash_ = typeid(RelAggregate).hash_code();
1382  boost::hash_combine(*hash_, groupby_count_);
1383  for (auto& agg_expr : agg_exprs_) {
1384  boost::hash_combine(*hash_, agg_expr->toHash());
1385  }
1386  for (auto& node : inputs_) {
1387  boost::hash_combine(*hash_, node->toHash());
1388  }
1389  boost::hash_combine(*hash_, ::toString(fields_));
1390  }
1391  return *hash_;
1392  }
size_t groupby_count_
Definition: RelAlgDag.h:1424
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
Definition: RelAlgDag.h:1355
std::optional< size_t > hash_
Definition: RelAlgDag.h:955
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1425
std::vector< std::string > fields_
Definition: RelAlgDag.h:1426
RelAlgInputs inputs_
Definition: RelAlgDag.h:952

+ Here is the call graph for this function:

std::string RelAggregate::toString ( RelRexToStringConfig  config = RelRexToStringConfig::defaults()) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1355 of file RelAlgDag.h.

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

Referenced by toHash().

1356  {
1357  auto ret = cat(::typeName(this),
1358  "(",
1360  ", agg_exprs=",
1361  ::toString(agg_exprs_),
1362  ", fields=",
1363  ::toString(fields_));
1364  if (!config.skip_input_nodes) {
1365  ret += ::toString(inputs_);
1366  } else {
1367  ret += ", input node id={";
1368  for (auto& input : inputs_) {
1369  auto node_id_in_plan = input->getIdInPlanTree();
1370  auto node_id_str = node_id_in_plan ? std::to_string(*node_id_in_plan)
1371  : std::to_string(input->getId());
1372  ret += node_id_str + " ";
1373  }
1374  ret += "}";
1375  }
1376  return cat(ret, ")");
1377  }
std::string cat(Ts &&...args)
size_t groupby_count_
Definition: RelAlgDag.h:1424
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
Definition: RelAlgDag.h:1355
std::string to_string(char const *&&v)
unsigned getId() const
Definition: RelAlgDag.h:880
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1425
std::string typeName(const T *v)
Definition: toString.h:103
std::vector< std::string > fields_
Definition: RelAlgDag.h:1426
RelAlgInputs inputs_
Definition: RelAlgDag.h:952

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Friends And Related Function Documentation

friend struct RelAlgDagSerializer
friend

Definition at line 1430 of file RelAlgDag.h.

Member Data Documentation

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

Definition at line 1426 of file RelAlgDag.h.

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

size_t RelAggregate::groupby_count_
private

Definition at line 1424 of file RelAlgDag.h.

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

bool RelAggregate::hint_applied_
private

Definition at line 1427 of file RelAlgDag.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: