OmniSciDB  a5dc49c757
 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 &)
 
virtual void acceptChildren (Visitor &v) const override
 
virtual void accept (Visitor &v, std::string name) const override
 
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
 
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 ()
 
virtual size_t toHash () const override
 
- 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
 
bool hasContextData () const
 
const RaExecutionDescgetContextData () const
 
const size_t inputCount () const
 
const RelAlgNodegetInput (const size_t idx) const
 
const std::vector< RelAlgNode
const * > 
getInputs () 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
 
- Public Member Functions inherited from RelAlgDagNode
 RelAlgDagNode ()
 
virtual size_t getStepNumber () const
 
virtual void setStepNumber (size_t step) const
 
std::optional< size_t > getIdInPlanTree () const
 
void setIdInPlanTree (size_t id) 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
 
std::size_t hash_value (RelAggregate const &)
 

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 > hash_
 
- Protected Attributes inherited from RelAlgDagNode
size_t step_ {0}
 
std::optional< size_t > id_in_plan_tree_
 

Detailed Description

Definition at line 1468 of file RelAlgDag.h.

Constructor & Destructor Documentation

RelAggregate::RelAggregate ( )
inline

Definition at line 1471 of file RelAlgDag.h.

1471 : groupby_count_{0}, hint_applied_{false} {}
size_t groupby_count_
Definition: RelAlgDag.h:1606
bool hint_applied_
Definition: RelAlgDag.h:1609
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 1474 of file RelAlgDag.h.

References RelAlgNode::inputs_.

1478  : groupby_count_(groupby_count)
1479  , agg_exprs_(std::move(agg_exprs))
1480  , fields_(fields)
1481  , hint_applied_(false)
1482  , hints_(std::make_unique<Hints>()) {
1483  inputs_.push_back(input);
1484  }
size_t groupby_count_
Definition: RelAlgDag.h:1606
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1610
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1607
bool hint_applied_
Definition: RelAlgDag.h:1609
std::vector< std::string > fields_
Definition: RelAlgDag.h:1608
RelAlgInputs inputs_
Definition: RelAlgDag.h:945
RelAggregate::RelAggregate ( RelAggregate const &  rhs)

Definition at line 584 of file RelAlgDag.cpp.

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

585  : RelAlgNode(rhs)
586  , groupby_count_(rhs.groupby_count_)
587  , fields_(rhs.fields_)
588  , hint_applied_(false)
589  , hints_(std::make_unique<Hints>()) {
590  agg_exprs_.reserve(rhs.agg_exprs_.size());
591  for (auto const& agg : rhs.agg_exprs_) {
592  agg_exprs_.push_back(agg->deepCopy());
593  }
594  if (rhs.hint_applied_) {
595  for (auto const& kv : *rhs.hints_) {
596  addHint(kv.second);
597  }
598  }
599 }
RelAlgNode(RelAlgInputs inputs={})
Definition: RelAlgDag.h:830
size_t groupby_count_
Definition: RelAlgDag.h:1606
void addHint(const ExplainedQueryHint &hint_explained)
Definition: RelAlgDag.h:1576
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1610
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1607
bool hint_applied_
Definition: RelAlgDag.h:1609
std::vector< std::string > fields_
Definition: RelAlgDag.h:1608

+ Here is the call graph for this function:

Member Function Documentation

virtual void RelAggregate::accept ( Visitor v,
std::string  name 
) const
inlineoverridevirtual

Implements RelAlgDagNode.

Definition at line 1500 of file RelAlgDag.h.

References acceptChildren(), and RelAlgDagNode::Visitor::visit().

Referenced by TableFunctionsFactory_node.PrintNode::__str__().

1500  {
1501  if (v.visit(this, std::move(name))) {
1502  acceptChildren(v);
1503  }
1504  }
virtual void acceptChildren(Visitor &v) const override
Definition: RelAlgDag.h:1488
string name
Definition: setup.in.py:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual void RelAggregate::acceptChildren ( Visitor v) const
inlineoverridevirtual

Implements RelAlgDagNode.

Definition at line 1488 of file RelAlgDag.h.

References getAggExprs(), RelAlgNode::getInputs(), and anonymous_namespace{Utm.h}::n.

Referenced by accept().

1488  {
1489  for (auto const& n : getAggExprs()) {
1490  if (n) {
1491  n.get()->accept(v, "aggregate");
1492  }
1493  }
1494  for (auto& n : getInputs()) {
1495  if (n) {
1496  n->accept(v, "input");
1497  }
1498  }
1499  }
const std::vector< std::unique_ptr< const RexAgg > > & getAggExprs() const
Definition: RelAlgDag.h:1531
const std::vector< RelAlgNode const * > getInputs() const
Definition: RelAlgDag.h:882
constexpr double n
Definition: Utm.h:38

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void RelAggregate::addHint ( const ExplainedQueryHint hint_explained)
inline

Definition at line 1576 of file RelAlgDag.h.

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

Referenced by RelAggregate().

1576  {
1577  if (!hint_applied_) {
1578  hint_applied_ = true;
1579  }
1580  hints_->emplace(hint_explained.getHint(), hint_explained);
1581  }
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1610
bool hint_applied_
Definition: RelAlgDag.h:1609
const QueryHint getHint() const
Definition: QueryHint.h:167

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

1572  {
1573  return std::make_shared<RelAggregate>(*this);
1574  }
const std::vector<std::unique_ptr<const RexAgg> >& RelAggregate::getAggExprs ( ) const
inline

Definition at line 1531 of file RelAlgDag.h.

References agg_exprs_.

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

1531  {
1532  return agg_exprs_;
1533  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1607

+ Here is the caller graph for this function:

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

Definition at line 1527 of file RelAlgDag.h.

References agg_exprs_.

1527  {
1528  return std::move(agg_exprs_);
1529  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1607
const size_t RelAggregate::getAggExprsCount ( ) const
inline

Definition at line 1510 of file RelAlgDag.h.

References agg_exprs_.

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

Definition at line 1519 of file RelAlgDag.h.

References agg_exprs_, and run_benchmark_import::result.

1519  {
1520  std::vector<const RexAgg*> result;
1521  for (auto& agg_expr : agg_exprs_) {
1522  result.push_back(agg_expr.release());
1523  }
1524  return result;
1525  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1607
Hints* RelAggregate::getDeliveredHints ( )
inline

Definition at line 1599 of file RelAlgDag.h.

References hints_.

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

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

+ Here is the caller graph for this function:

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

Definition at line 1517 of file RelAlgDag.h.

References fields_.

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

Definition at line 1512 of file RelAlgDag.h.

References fields_.

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

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

1508 { return groupby_count_; }
size_t groupby_count_
Definition: RelAlgDag.h:1606

+ Here is the caller graph for this function:

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

Definition at line 1590 of file RelAlgDag.h.

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

1590  {
1592  CHECK(!hints_->empty());
1593  CHECK(hasHintEnabled(hint));
1594  return hints_->at(hint);
1595  }
const bool hasHintEnabled(QueryHint candidate_hint) const
Definition: RelAlgDag.h:1583
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1610
bool hint_applied_
Definition: RelAlgDag.h:1609
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

bool RelAggregate::hasDeliveredHint ( )
inline

Definition at line 1597 of file RelAlgDag.h.

References hints_.

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

Definition at line 1583 of file RelAlgDag.h.

References hint_applied_, and hints_.

Referenced by getHintInfo().

1583  {
1584  if (hint_applied_ && !hints_->empty()) {
1585  return hints_->find(candidate_hint) != hints_->end();
1586  }
1587  return false;
1588  }
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1610
bool hint_applied_
Definition: RelAlgDag.h:1609

+ Here is the caller graph for this function:

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

Definition at line 1535 of file RelAlgDag.h.

References agg_exprs_.

1535  {
1536  agg_exprs_ = std::move(agg_exprs);
1537  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1607
void RelAggregate::setFields ( std::vector< std::string > &&  new_fields)
inline

Definition at line 1513 of file RelAlgDag.h.

References fields_.

1513  {
1514  fields_ = std::move(new_fields);
1515  }
std::vector< std::string > fields_
Definition: RelAlgDag.h:1608
size_t RelAggregate::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1506 of file RelAlgDag.h.

References agg_exprs_, and groupby_count_.

1506 { return groupby_count_ + agg_exprs_.size(); }
size_t groupby_count_
Definition: RelAlgDag.h:1606
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1607
virtual size_t RelAggregate::toHash ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1601 of file RelAlgDag.h.

References hash_value.

1601 { return hash_value(*this); }
friend std::size_t hash_value(RelAggregate const &)
Definition: RelAlgDag.cpp:3713
std::string RelAggregate::toString ( RelRexToStringConfig  config = RelRexToStringConfig::defaults()) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1539 of file RelAlgDag.h.

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

1540  {
1541  if (!config.attributes_only) {
1542  auto ret = cat(::typeName(this),
1543  "(",
1545  ", agg_exprs=",
1546  ::toString(agg_exprs_),
1547  ", fields=",
1548  ::toString(fields_));
1549  if (!config.skip_input_nodes) {
1550  ret += ::toString(inputs_);
1551  } else {
1552  ret += ", input node id={";
1553  for (auto& input : inputs_) {
1554  auto node_id_in_plan = input->getIdInPlanTree();
1555  auto node_id_str = node_id_in_plan ? std::to_string(*node_id_in_plan)
1556  : std::to_string(input->getId());
1557  ret += node_id_str + " ";
1558  }
1559  ret += "}";
1560  }
1561  return cat(ret, ")");
1562  } else {
1563  return cat(::typeName(this),
1564  "(",
1566  ", fields=",
1567  ::toString(fields_),
1568  ")");
1569  }
1570  }
std::string cat(Ts &&...args)
size_t groupby_count_
Definition: RelAlgDag.h:1606
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
Definition: RelAlgDag.h:1539
std::string to_string(char const *&&v)
unsigned getId() const
Definition: RelAlgDag.h:869
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1607
std::string typeName(const T *v)
Definition: toString.h:106
std::vector< std::string > fields_
Definition: RelAlgDag.h:1608
RelAlgInputs inputs_
Definition: RelAlgDag.h:945

+ Here is the call graph for this function:

Friends And Related Function Documentation

std::size_t hash_value ( RelAggregate const &  rel_agg)
friend

Definition at line 3713 of file RelAlgDag.cpp.

Referenced by toHash().

3713  {
3714  if (rel_agg.hash_) {
3715  return *rel_agg.hash_;
3716  }
3717  rel_agg.hash_ = typeid(RelAggregate).hash_code();
3718  boost::hash_combine(*rel_agg.hash_, rel_agg.groupby_count_);
3719  boost::hash_combine(*rel_agg.hash_, rel_agg.agg_exprs_);
3720  boost::hash_combine(*rel_agg.hash_, rel_agg.fields_);
3721  boost::hash_combine(*rel_agg.hash_, rel_agg.inputs_);
3722  return *rel_agg.hash_;
3723 }
friend struct RelAlgDagSerializer
friend

Definition at line 1612 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 1608 of file RelAlgDag.h.

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

size_t RelAggregate::groupby_count_
private

Definition at line 1606 of file RelAlgDag.h.

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

bool RelAggregate::hint_applied_
private

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