OmniSciDB  c0231cc57d
 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 (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 1218 of file RelAlgDag.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 1221 of file RelAlgDag.h.

References RelAlgNode::inputs_.

Referenced by toHash().

1225  : groupby_count_(groupby_count)
1226  , agg_exprs_(std::move(agg_exprs))
1227  , fields_(fields)
1228  , hint_applied_(false)
1229  , hints_(std::make_unique<Hints>()) {
1230  inputs_.push_back(input);
1231  }
const size_t groupby_count_
Definition: RelAlgDag.h:1337
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1341
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1338
bool hint_applied_
Definition: RelAlgDag.h:1340
std::vector< std::string > fields_
Definition: RelAlgDag.h:1339
RelAlgInputs inputs_
Definition: RelAlgDag.h:886

+ Here is the caller graph for this function:

RelAggregate::RelAggregate ( RelAggregate const &  rhs)

Definition at line 582 of file RelAlgDag.cpp.

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

583  : RelAlgNode(rhs)
584  , groupby_count_(rhs.groupby_count_)
585  , fields_(rhs.fields_)
586  , hint_applied_(false)
587  , hints_(std::make_unique<Hints>()) {
588  agg_exprs_.reserve(rhs.agg_exprs_.size());
589  for (auto const& agg : rhs.agg_exprs_) {
590  agg_exprs_.push_back(agg->deepCopy());
591  }
592  if (rhs.hint_applied_) {
593  for (auto const& kv : *rhs.hints_) {
594  addHint(kv.second);
595  }
596  }
597 }
RelAlgNode(RelAlgInputs inputs={})
Definition: RelAlgDag.h:774
void addHint(const ExplainedQueryHint &hint_explained)
Definition: RelAlgDag.h:1311
const size_t groupby_count_
Definition: RelAlgDag.h:1337
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1341
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1338
bool hint_applied_
Definition: RelAlgDag.h:1340
std::vector< std::string > fields_
Definition: RelAlgDag.h:1339

+ Here is the call graph for this function:

Member Function Documentation

void RelAggregate::addHint ( const ExplainedQueryHint hint_explained)
inline

Definition at line 1311 of file RelAlgDag.h.

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

Referenced by RelAggregate().

1311  {
1312  if (!hint_applied_) {
1313  hint_applied_ = true;
1314  }
1315  hints_->emplace(hint_explained.getHint(), hint_explained);
1316  }
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1341
bool hint_applied_
Definition: RelAlgDag.h:1340
const QueryHint getHint() const
Definition: QueryHint.h:123

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

1307  {
1308  return std::make_shared<RelAggregate>(*this);
1309  }
const std::vector<std::unique_ptr<const RexAgg> >& RelAggregate::getAggExprs ( ) const
inline

Definition at line 1260 of file RelAlgDag.h.

References agg_exprs_.

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

1260  {
1261  return agg_exprs_;
1262  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1338

+ Here is the caller graph for this function:

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

Definition at line 1256 of file RelAlgDag.h.

References agg_exprs_.

1256  {
1257  return std::move(agg_exprs_);
1258  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1338
const size_t RelAggregate::getAggExprsCount ( ) const
inline

Definition at line 1239 of file RelAlgDag.h.

References agg_exprs_.

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

Definition at line 1248 of file RelAlgDag.h.

References agg_exprs_, and run_benchmark_import::result.

1248  {
1249  std::vector<const RexAgg*> result;
1250  for (auto& agg_expr : agg_exprs_) {
1251  result.push_back(agg_expr.release());
1252  }
1253  return result;
1254  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1338
Hints* RelAggregate::getDeliveredHints ( )
inline

Definition at line 1334 of file RelAlgDag.h.

References hints_.

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

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

+ Here is the caller graph for this function:

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

Definition at line 1246 of file RelAlgDag.h.

References fields_.

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

Definition at line 1241 of file RelAlgDag.h.

References fields_.

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

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

1237 { return groupby_count_; }
const size_t groupby_count_
Definition: RelAlgDag.h:1337

+ Here is the caller graph for this function:

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

Definition at line 1325 of file RelAlgDag.h.

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

1325  {
1327  CHECK(!hints_->empty());
1328  CHECK(hasHintEnabled(hint));
1329  return hints_->at(hint);
1330  }
const bool hasHintEnabled(QueryHint candidate_hint) const
Definition: RelAlgDag.h:1318
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1341
bool hint_applied_
Definition: RelAlgDag.h:1340
#define CHECK(condition)
Definition: Logger.h:222

+ Here is the call graph for this function:

bool RelAggregate::hasDeliveredHint ( )
inline

Definition at line 1332 of file RelAlgDag.h.

References hints_.

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

Definition at line 1318 of file RelAlgDag.h.

References hint_applied_, and hints_.

Referenced by getHintInfo().

1318  {
1319  if (hint_applied_ && !hints_->empty()) {
1320  return hints_->find(candidate_hint) != hints_->end();
1321  }
1322  return false;
1323  }
std::unique_ptr< Hints > hints_
Definition: RelAlgDag.h:1341
bool hint_applied_
Definition: RelAlgDag.h:1340

+ Here is the caller graph for this function:

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

Definition at line 1264 of file RelAlgDag.h.

References agg_exprs_.

1264  {
1265  agg_exprs_ = std::move(agg_exprs);
1266  }
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1338
void RelAggregate::setFields ( std::vector< std::string > &&  new_fields)
inline

Definition at line 1242 of file RelAlgDag.h.

References fields_.

1242  {
1243  fields_ = std::move(new_fields);
1244  }
std::vector< std::string > fields_
Definition: RelAlgDag.h:1339
size_t RelAggregate::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1235 of file RelAlgDag.h.

References agg_exprs_, and groupby_count_.

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

Implements RelAlgNode.

Definition at line 1292 of file RelAlgDag.h.

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

1292  {
1293  if (!hash_) {
1294  hash_ = typeid(RelAggregate).hash_code();
1295  boost::hash_combine(*hash_, groupby_count_);
1296  for (auto& agg_expr : agg_exprs_) {
1297  boost::hash_combine(*hash_, agg_expr->toHash());
1298  }
1299  for (auto& node : inputs_) {
1300  boost::hash_combine(*hash_, node->toHash());
1301  }
1302  boost::hash_combine(*hash_, ::toString(fields_));
1303  }
1304  return *hash_;
1305  }
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
Definition: RelAlgDag.h:1268
const size_t groupby_count_
Definition: RelAlgDag.h:1337
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)
Definition: RelAlgDag.h:1221
std::optional< size_t > hash_
Definition: RelAlgDag.h:889
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1338
std::vector< std::string > fields_
Definition: RelAlgDag.h:1339
RelAlgInputs inputs_
Definition: RelAlgDag.h:886

+ Here is the call graph for this function:

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

Implements RelAlgNode.

Definition at line 1268 of file RelAlgDag.h.

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

Referenced by toHash().

1269  {
1270  auto ret = cat(::typeName(this),
1271  "(",
1273  ", agg_exprs=",
1274  ::toString(agg_exprs_),
1275  ", fields=",
1276  ::toString(fields_));
1277  if (!config.skip_input_nodes) {
1278  ret += ::toString(inputs_);
1279  } else {
1280  ret += ", input node id={";
1281  for (auto& input : inputs_) {
1282  auto node_id_in_plan = input->getIdInPlanTree();
1283  auto node_id_str = node_id_in_plan ? std::to_string(*node_id_in_plan)
1284  : std::to_string(input->getId());
1285  ret += node_id_str + " ";
1286  }
1287  ret += "}";
1288  }
1289  return cat(ret, ")");
1290  }
std::string cat(Ts &&...args)
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
Definition: RelAlgDag.h:1268
std::string to_string(char const *&&v)
const size_t groupby_count_
Definition: RelAlgDag.h:1337
unsigned getId() const
Definition: RelAlgDag.h:814
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
Definition: RelAlgDag.h:1338
std::string typeName(const T *v)
Definition: toString.h:103
std::vector< std::string > fields_
Definition: RelAlgDag.h:1339
RelAlgInputs inputs_
Definition: RelAlgDag.h:886

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

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

const size_t RelAggregate::groupby_count_
private

Definition at line 1337 of file RelAlgDag.h.

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

bool RelAggregate::hint_applied_
private

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