OmniSciDB  c1a53651b2
 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 1320 of file RelAlgDag.h.

Constructor & Destructor Documentation

RelAggregate::RelAggregate ( )
inline

Definition at line 1323 of file RelAlgDag.h.

Referenced by toHash().

1323 : groupby_count_{0}, hint_applied_{false} {}
size_t groupby_count_
Definition: RelAlgDag.h:1442
bool hint_applied_
Definition: RelAlgDag.h:1445

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

References RelAlgNode::inputs_.

1330  : groupby_count_(groupby_count)
1331  , agg_exprs_(std::move(agg_exprs))
1332  , fields_(fields)
1333  , hint_applied_(false)
1334  , hints_(std::make_unique<Hints>()) {
1335  inputs_.push_back(input);
1336  }
size_t groupby_count_
Definition: RelAlgDag.h:1442
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1446
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1443
bool hint_applied_
Definition: RelAlgDag.h:1445
std::vector< std::string > fields_
Definition: RelAlgDag.h:1444
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:1442
void addHint(const ExplainedQueryHint &hint_explained)
Definition: RelAlgDag.h:1416
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1446
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1443
bool hint_applied_
Definition: RelAlgDag.h:1445
std::vector< std::string > fields_
Definition: RelAlgDag.h:1444

+ Here is the call graph for this function:

Member Function Documentation

void RelAggregate::addHint ( const ExplainedQueryHint hint_explained)
inline

Definition at line 1416 of file RelAlgDag.h.

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

Referenced by RelAggregate().

1416  {
1417  if (!hint_applied_) {
1418  hint_applied_ = true;
1419  }
1420  hints_->emplace(hint_explained.getHint(), hint_explained);
1421  }
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1446
bool hint_applied_
Definition: RelAlgDag.h:1445
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 1412 of file RelAlgDag.h.

1412  {
1413  return std::make_shared<RelAggregate>(*this);
1414  }
const std::vector<std::unique_ptr<const RexAgg> >& RelAggregate::getAggExprs ( ) const
inline

Definition at line 1365 of file RelAlgDag.h.

References agg_exprs_.

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

1365  {
1366  return agg_exprs_;
1367  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1443

+ Here is the caller graph for this function:

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

Definition at line 1361 of file RelAlgDag.h.

References agg_exprs_.

1361  {
1362  return std::move(agg_exprs_);
1363  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1443
const size_t RelAggregate::getAggExprsCount ( ) const
inline

Definition at line 1344 of file RelAlgDag.h.

References agg_exprs_.

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

Definition at line 1353 of file RelAlgDag.h.

References agg_exprs_, and run_benchmark_import::result.

1353  {
1354  std::vector<const RexAgg*> result;
1355  for (auto& agg_expr : agg_exprs_) {
1356  result.push_back(agg_expr.release());
1357  }
1358  return result;
1359  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1443
Hints* RelAggregate::getDeliveredHints ( )
inline

Definition at line 1439 of file RelAlgDag.h.

References hints_.

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

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

+ Here is the caller graph for this function:

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

Definition at line 1351 of file RelAlgDag.h.

References fields_.

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

Definition at line 1346 of file RelAlgDag.h.

References fields_.

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

Definition at line 1342 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().

1342 { return groupby_count_; }
size_t groupby_count_
Definition: RelAlgDag.h:1442

+ Here is the caller graph for this function:

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

Definition at line 1430 of file RelAlgDag.h.

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

1430  {
1432  CHECK(!hints_->empty());
1433  CHECK(hasHintEnabled(hint));
1434  return hints_->at(hint);
1435  }
const bool hasHintEnabled(QueryHint candidate_hint) const
Definition: RelAlgDag.h:1423
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1446
bool hint_applied_
Definition: RelAlgDag.h:1445
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

bool RelAggregate::hasDeliveredHint ( )
inline

Definition at line 1437 of file RelAlgDag.h.

References hints_.

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

Definition at line 1423 of file RelAlgDag.h.

References hint_applied_, and hints_.

Referenced by getHintInfo().

1423  {
1424  if (hint_applied_ && !hints_->empty()) {
1425  return hints_->find(candidate_hint) != hints_->end();
1426  }
1427  return false;
1428  }
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1446
bool hint_applied_
Definition: RelAlgDag.h:1445

+ Here is the caller graph for this function:

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

Definition at line 1369 of file RelAlgDag.h.

References agg_exprs_.

1369  {
1370  agg_exprs_ = std::move(agg_exprs);
1371  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1443
void RelAggregate::setFields ( std::vector< std::string > &&  new_fields)
inline

Definition at line 1347 of file RelAlgDag.h.

References fields_.

1347  {
1348  fields_ = std::move(new_fields);
1349  }
std::vector< std::string > fields_
Definition: RelAlgDag.h:1444
size_t RelAggregate::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1340 of file RelAlgDag.h.

References agg_exprs_, and groupby_count_.

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

Implements RelAlgNode.

Definition at line 1397 of file RelAlgDag.h.

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

1397  {
1398  if (!hash_) {
1399  hash_ = typeid(RelAggregate).hash_code();
1400  boost::hash_combine(*hash_, groupby_count_);
1401  for (auto& agg_expr : agg_exprs_) {
1402  boost::hash_combine(*hash_, agg_expr->toHash());
1403  }
1404  for (auto& node : inputs_) {
1405  boost::hash_combine(*hash_, node->toHash());
1406  }
1407  boost::hash_combine(*hash_, ::toString(fields_));
1408  }
1409  return *hash_;
1410  }
size_t groupby_count_
Definition: RelAlgDag.h:1442
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
Definition: RelAlgDag.h:1373
std::optional< size_t > hash_
Definition: RelAlgDag.h:955
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1443
std::vector< std::string > fields_
Definition: RelAlgDag.h:1444
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 1373 of file RelAlgDag.h.

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

Referenced by toHash().

1374  {
1375  auto ret = cat(::typeName(this),
1376  "(",
1378  ", agg_exprs=",
1379  ::toString(agg_exprs_),
1380  ", fields=",
1381  ::toString(fields_));
1382  if (!config.skip_input_nodes) {
1383  ret += ::toString(inputs_);
1384  } else {
1385  ret += ", input node id={";
1386  for (auto& input : inputs_) {
1387  auto node_id_in_plan = input->getIdInPlanTree();
1388  auto node_id_str = node_id_in_plan ? std::to_string(*node_id_in_plan)
1389  : std::to_string(input->getId());
1390  ret += node_id_str + " ";
1391  }
1392  ret += "}";
1393  }
1394  return cat(ret, ")");
1395  }
std::string cat(Ts &&...args)
size_t groupby_count_
Definition: RelAlgDag.h:1442
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
Definition: RelAlgDag.h:1373
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:1443
std::string typeName(const T *v)
Definition: toString.h:103
std::vector< std::string > fields_
Definition: RelAlgDag.h:1444
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 1448 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 1444 of file RelAlgDag.h.

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

size_t RelAggregate::groupby_count_
private

Definition at line 1442 of file RelAlgDag.h.

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

bool RelAggregate::hint_applied_
private

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