OmniSciDB  8a228a1076
RelCompound Class Reference

#include <RelAlgDagBuilder.h>

+ Inheritance diagram for RelCompound:
+ Collaboration diagram for RelCompound:

Public Member Functions

 RelCompound (std::unique_ptr< const RexScalar > &filter_expr, const std::vector< const Rex *> &target_exprs, const size_t groupby_count, const std::vector< const RexAgg *> &agg_exprs, const std::vector< std::string > &fields, std::vector< std::unique_ptr< const RexScalar >> &scalar_sources, const bool is_agg, bool update_disguised_as_select=false, bool delete_disguised_as_select=false, bool varlen_update_required=false, TableDescriptor const *manipulation_target_table=nullptr, ColumnNameList target_columns=ColumnNameList())
 
 RelCompound (RelCompound const &)
 
void replaceInput (std::shared_ptr< const RelAlgNode > old_input, std::shared_ptr< const RelAlgNode > input) override
 
size_t size () const override
 
const RexScalargetFilterExpr () const
 
void setFilterExpr (std::unique_ptr< const RexScalar > &new_expr)
 
const RexgetTargetExpr (const size_t i) const
 
const std::vector< std::string > & getFields () const
 
const std::string getFieldName (const size_t i) const
 
const size_t getScalarSourcesSize () const
 
const RexScalargetScalarSource (const size_t i) const
 
void setScalarSources (std::vector< std::unique_ptr< const RexScalar >> &new_sources)
 
const size_t getGroupByCount () const
 
bool isAggregate () const
 
std::string toString () const override
 
std::shared_ptr< RelAlgNodedeepCopy () const override
 
void addHint (const HintExplained &hint_explained)
 
const bool hasHintEnabled (const std::string &candidate_hint_name) const
 
const HintExplainedgetHintInfo (const std::string &hint_name) const
 
- Public Member Functions inherited from RelAlgNode
 RelAlgNode (RelAlgInputs inputs={})
 
virtual ~RelAlgNode ()
 
void resetQueryExecutionState ()
 
void setContextData (const void *context_data) const
 
void setOutputMetainfo (const std::vector< TargetMetaInfo > &targets_metainfo) const
 
const std::vector< TargetMetaInfo > & getOutputMetainfo () const
 
unsigned getId () const
 
bool hasContextData () const
 
const void * getContextData () 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
 
bool isNop () const
 
void markAsNop ()
 
- Public Member Functions inherited from ModifyManipulationTarget
 ModifyManipulationTarget (bool const update_via_select=false, bool const delete_via_select=false, bool const varlen_update_required=false, TableDescriptor const *table_descriptor=nullptr, ColumnNameList target_columns=ColumnNameList())
 
void setUpdateViaSelectFlag () const
 
void setDeleteViaSelectFlag () const
 
void setVarlenUpdateRequired (bool required) const
 
TableDescriptor const * getModifiedTableDescriptor () const
 
void setModifiedTableDescriptor (TableDescriptor const *td) const
 
auto const isUpdateViaSelect () const
 
auto const isDeleteViaSelect () const
 
auto const isVarlenUpdateRequired () const
 
void setTargetColumns (ColumnNameList const &target_columns) const
 
ColumnNameList const & getTargetColumns () const
 
template<typename VALIDATION_FUNCTOR >
bool validateTargetColumns (VALIDATION_FUNCTOR validator) const
 

Private Attributes

std::unique_ptr< const RexScalarfilter_expr_
 
const size_t groupby_count_
 
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
 
const std::vector< std::string > fields_
 
const bool is_agg_
 
std::vector< std::unique_ptr< const RexScalar > > scalar_sources_
 
const std::vector< const Rex * > target_exprs_
 
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_
 

Detailed Description

Definition at line 1263 of file RelAlgDagBuilder.h.

Constructor & Destructor Documentation

◆ RelCompound() [1/2]

RelCompound::RelCompound ( std::unique_ptr< const RexScalar > &  filter_expr,
const std::vector< const Rex *> &  target_exprs,
const size_t  groupby_count,
const std::vector< const RexAgg *> &  agg_exprs,
const std::vector< std::string > &  fields,
std::vector< std::unique_ptr< const RexScalar >> &  scalar_sources,
const bool  is_agg,
bool  update_disguised_as_select = false,
bool  delete_disguised_as_select = false,
bool  varlen_update_required = false,
TableDescriptor const *  manipulation_target_table = nullptr,
ColumnNameList  target_columns = ColumnNameList() 
)
inline

Definition at line 1268 of file RelAlgDagBuilder.h.

References CHECK_EQ.

1280  : ModifyManipulationTarget(update_disguised_as_select,
1281  delete_disguised_as_select,
1282  varlen_update_required,
1283  manipulation_target_table,
1284  target_columns)
1285  , filter_expr_(std::move(filter_expr))
1286  , groupby_count_(groupby_count)
1287  , fields_(fields)
1288  , is_agg_(is_agg)
1289  , scalar_sources_(std::move(scalar_sources))
1290  , target_exprs_(target_exprs)
1291  , hint_applied_(false)
1292  , hints_(std::make_unique<Hints>()) {
1293  CHECK_EQ(fields.size(), target_exprs.size());
1294  for (auto agg_expr : agg_exprs) {
1295  agg_exprs_.emplace_back(agg_expr);
1296  }
1297  }
bool is_agg(const Analyzer::Expr *expr)
#define CHECK_EQ(x, y)
Definition: Logger.h:205
const std::vector< std::string > fields_
std::vector< std::unique_ptr< const RexScalar > > scalar_sources_
const size_t groupby_count_
std::unique_ptr< Hints > hints_
const std::vector< const Rex * > target_exprs_
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
std::unique_ptr< const RexScalar > filter_expr_
ModifyManipulationTarget(bool const update_via_select=false, bool const delete_via_select=false, bool const varlen_update_required=false, TableDescriptor const *table_descriptor=nullptr, ColumnNameList target_columns=ColumnNameList())
const bool is_agg_

◆ RelCompound() [2/2]

RelCompound::RelCompound ( RelCompound const &  rhs)

Definition at line 442 of file RelAlgDagBuilder.cpp.

References addHint(), filter_expr_, hint_applied_, hints_, and RexVisitorBase< T >::visit().

443  : RelAlgNode(rhs)
445  , groupby_count_(rhs.groupby_count_)
446  , agg_exprs_(copyAggExprs(rhs.agg_exprs_))
447  , fields_(rhs.fields_)
448  , is_agg_(rhs.is_agg_)
449  , scalar_sources_(copyRexScalars(rhs.scalar_sources_))
452  rhs.agg_exprs_,
453  rhs.scalar_sources_,
454  rhs.target_exprs_))
455  , hint_applied_(false)
456  , hints_(std::make_unique<Hints>()) {
457  RexDeepCopyVisitor copier;
458  filter_expr_ = rhs.filter_expr_ ? copier.visit(rhs.filter_expr_.get()) : nullptr;
459  if (rhs.hint_applied_) {
460  for (auto const& kv : *rhs.hints_) {
461  addHint(kv.second);
462  }
463  }
464 }
RelAlgNode(RelAlgInputs inputs={})
const std::vector< std::string > fields_
std::vector< std::unique_ptr< const RexScalar > > scalar_sources_
void addHint(const HintExplained &hint_explained)
const size_t groupby_count_
virtual T visit(const RexScalar *rex_scalar) const
Definition: RexVisitor.h:27
std::vector< std::unique_ptr< const RexAgg > > copyAggExprs(std::vector< std::unique_ptr< const RexAgg >> const &agg_exprs)
std::unique_ptr< Hints > hints_
const std::vector< const Rex * > target_exprs_
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
std::unique_ptr< const RexScalar > filter_expr_
std::vector< const Rex * > remapTargetPointers(std::vector< std::unique_ptr< const RexAgg >> const &agg_exprs_new, std::vector< std::unique_ptr< const RexScalar >> const &scalar_sources_new, std::vector< std::unique_ptr< const RexAgg >> const &agg_exprs_old, std::vector< std::unique_ptr< const RexScalar >> const &scalar_sources_old, std::vector< const Rex *> const &target_exprs_old)
ModifyManipulationTarget(bool const update_via_select=false, bool const delete_via_select=false, bool const varlen_update_required=false, TableDescriptor const *table_descriptor=nullptr, ColumnNameList target_columns=ColumnNameList())
std::vector< std::unique_ptr< const RexScalar > > copyRexScalars(std::vector< std::unique_ptr< const RexScalar >> const &scalar_sources)
const bool is_agg_
+ Here is the call graph for this function:

Member Function Documentation

◆ addHint()

void RelCompound::addHint ( const HintExplained hint_explained)
inline

Definition at line 1355 of file RelAlgDagBuilder.h.

References HintExplained::getHintName().

Referenced by RelCompound().

1355  {
1356  if (!hint_applied_) {
1357  hint_applied_ = true;
1358  }
1359  hints_->emplace(hint_explained.getHintName(), hint_explained);
1360  }
const std::string & getHintName() const
std::unique_ptr< Hints > hints_
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deepCopy()

std::shared_ptr<RelAlgNode> RelCompound::deepCopy ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1351 of file RelAlgDagBuilder.h.

1351  {
1352  return std::make_shared<RelCompound>(*this);
1353  }

◆ getFieldName()

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

Definition at line 1316 of file RelAlgDagBuilder.h.

1316 { return fields_[i]; }
const std::vector< std::string > fields_

◆ getFields()

const std::vector<std::string>& RelCompound::getFields ( ) const
inline

Definition at line 1314 of file RelAlgDagBuilder.h.

1314 { return fields_; }
const std::vector< std::string > fields_

◆ getFilterExpr()

const RexScalar* RelCompound::getFilterExpr ( ) const
inline

Definition at line 1306 of file RelAlgDagBuilder.h.

Referenced by anonymous_namespace{RelAlgExecutor.cpp}::get_used_inputs(), anonymous_namespace{RelAlgExecutor.cpp}::translate_quals(), RelRexDagVisitor::visit(), and anonymous_namespace{QueryPhysicalInputsCollector.cpp}::RelAlgPhysicalInputsVisitor::visitCompound().

1306 { return filter_expr_.get(); }
std::unique_ptr< const RexScalar > filter_expr_
+ Here is the caller graph for this function:

◆ getGroupByCount()

const size_t RelCompound::getGroupByCount ( ) const
inline

Definition at line 1329 of file RelAlgDagBuilder.h.

Referenced by anonymous_namespace{RelAlgExecutor.cpp}::translate_groupby_exprs().

1329 { return groupby_count_; }
const size_t groupby_count_
+ Here is the caller graph for this function:

◆ getHintInfo()

const HintExplained& RelCompound::getHintInfo ( const std::string &  hint_name) const
inline

Definition at line 1369 of file RelAlgDagBuilder.h.

References CHECK.

1369  {
1371  CHECK(!hints_->empty());
1372  CHECK(hasHintEnabled(hint_name));
1373  return hints_->at(hint_name);
1374  }
const bool hasHintEnabled(const std::string &candidate_hint_name) const
std::unique_ptr< Hints > hints_
#define CHECK(condition)
Definition: Logger.h:197

◆ getScalarSource()

const RexScalar* RelCompound::getScalarSource ( const size_t  i) const
inline

Definition at line 1320 of file RelAlgDagBuilder.h.

Referenced by anonymous_namespace{RelAlgExecutor.cpp}::get_used_inputs(), anonymous_namespace{RelAlgExecutor.cpp}::scalar_at(), and anonymous_namespace{QueryPhysicalInputsCollector.cpp}::RelAlgPhysicalInputsVisitor::visitCompound().

1320  {
1321  return scalar_sources_[i].get();
1322  }
std::vector< std::unique_ptr< const RexScalar > > scalar_sources_
+ Here is the caller graph for this function:

◆ getScalarSourcesSize()

const size_t RelCompound::getScalarSourcesSize ( ) const
inline

Definition at line 1318 of file RelAlgDagBuilder.h.

Referenced by anonymous_namespace{RelAlgExecutor.cpp}::get_scalar_sources_size(), anonymous_namespace{RelAlgExecutor.cpp}::get_used_inputs(), and anonymous_namespace{QueryPhysicalInputsCollector.cpp}::RelAlgPhysicalInputsVisitor::visitCompound().

1318 { return scalar_sources_.size(); }
std::vector< std::unique_ptr< const RexScalar > > scalar_sources_
+ Here is the caller graph for this function:

◆ getTargetExpr()

const Rex* RelCompound::getTargetExpr ( const size_t  i) const
inline

Definition at line 1312 of file RelAlgDagBuilder.h.

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

1312 { return target_exprs_[i]; }
const std::vector< const Rex * > target_exprs_
+ Here is the caller graph for this function:

◆ hasHintEnabled()

const bool RelCompound::hasHintEnabled ( const std::string &  candidate_hint_name) const
inline

Definition at line 1362 of file RelAlgDagBuilder.h.

1362  {
1363  if (hint_applied_ && !hints_->empty()) {
1364  return hints_->find(candidate_hint_name) != hints_->end();
1365  }
1366  return false;
1367  }
std::unique_ptr< Hints > hints_

◆ isAggregate()

bool RelCompound::isAggregate ( ) const
inline

Definition at line 1331 of file RelAlgDagBuilder.h.

Referenced by RelAlgExecutor::executeCompound(), and anonymous_namespace{RelAlgExecutor.cpp}::translate_groupby_exprs().

1331 { return is_agg_; }
const bool is_agg_
+ Here is the caller graph for this function:

◆ replaceInput()

void RelCompound::replaceInput ( std::shared_ptr< const RelAlgNode old_input,
std::shared_ptr< const RelAlgNode input 
)
overridevirtual

Reimplemented from RelAlgNode.

Definition at line 325 of file RelAlgDagBuilder.cpp.

References RelAlgNode::replaceInput().

326  {
327  RelAlgNode::replaceInput(old_input, input);
328  RexRebindInputsVisitor rebind_inputs(old_input.get(), input.get());
329  for (const auto& scalar_source : scalar_sources_) {
330  rebind_inputs.visit(scalar_source.get());
331  }
332  if (filter_expr_) {
333  rebind_inputs.visit(filter_expr_.get());
334  }
335 }
std::vector< std::unique_ptr< const RexScalar > > scalar_sources_
virtual void replaceInput(std::shared_ptr< const RelAlgNode > old_input, std::shared_ptr< const RelAlgNode > input)
std::unique_ptr< const RexScalar > filter_expr_
+ Here is the call graph for this function:

◆ setFilterExpr()

void RelCompound::setFilterExpr ( std::unique_ptr< const RexScalar > &  new_expr)
inline

Definition at line 1308 of file RelAlgDagBuilder.h.

1308  {
1309  filter_expr_ = std::move(new_expr);
1310  }
std::unique_ptr< const RexScalar > filter_expr_

◆ setScalarSources()

void RelCompound::setScalarSources ( std::vector< std::unique_ptr< const RexScalar >> &  new_sources)
inline

Definition at line 1324 of file RelAlgDagBuilder.h.

References CHECK_EQ.

1324  {
1325  CHECK_EQ(new_sources.size(), scalar_sources_.size());
1326  scalar_sources_ = std::move(new_sources);
1327  }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
std::vector< std::unique_ptr< const RexScalar > > scalar_sources_

◆ size()

size_t RelCompound::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1304 of file RelAlgDagBuilder.h.

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

1304 { return target_exprs_.size(); }
const std::vector< const Rex * > target_exprs_
+ Here is the caller graph for this function:

◆ toString()

std::string RelCompound::toString ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1333 of file RelAlgDagBuilder.h.

References run_benchmark_import::result, and to_string().

1333  {
1334  std::string result =
1335  "(RelCompound<" + std::to_string(reinterpret_cast<uint64_t>(this)) + ">(";
1336  result += (filter_expr_ ? filter_expr_->toString() : "null") + " ";
1337  for (const auto target_expr : target_exprs_) {
1338  result += target_expr->toString() + " ";
1339  }
1340  result += "groups: [";
1341  for (size_t group_index = 0; group_index < groupby_count_; ++group_index) {
1342  result += " " + std::to_string(group_index);
1343  }
1344  result += " ] sources: [";
1345  for (const auto& scalar_source : scalar_sources_) {
1346  result += " " + scalar_source->toString();
1347  }
1348  return result + " ]))";
1349  }
std::vector< std::unique_ptr< const RexScalar > > scalar_sources_
std::string to_string(char const *&&v)
const size_t groupby_count_
const std::vector< const Rex * > target_exprs_
std::unique_ptr< const RexScalar > filter_expr_
+ Here is the call graph for this function:

Member Data Documentation

◆ agg_exprs_

std::vector<std::unique_ptr<const RexAgg> > RelCompound::agg_exprs_
private

Definition at line 1379 of file RelAlgDagBuilder.h.

◆ fields_

const std::vector<std::string> RelCompound::fields_
private

Definition at line 1380 of file RelAlgDagBuilder.h.

◆ filter_expr_

std::unique_ptr<const RexScalar> RelCompound::filter_expr_
private

Definition at line 1377 of file RelAlgDagBuilder.h.

Referenced by RelCompound().

◆ groupby_count_

const size_t RelCompound::groupby_count_
private

Definition at line 1378 of file RelAlgDagBuilder.h.

◆ hint_applied_

bool RelCompound::hint_applied_
private

Definition at line 1386 of file RelAlgDagBuilder.h.

Referenced by RelCompound().

◆ hints_

std::unique_ptr<Hints> RelCompound::hints_
private

Definition at line 1387 of file RelAlgDagBuilder.h.

Referenced by RelCompound().

◆ is_agg_

const bool RelCompound::is_agg_
private

Definition at line 1381 of file RelAlgDagBuilder.h.

◆ scalar_sources_

std::vector<std::unique_ptr<const RexScalar> > RelCompound::scalar_sources_
private

Definition at line 1383 of file RelAlgDagBuilder.h.

◆ target_exprs_

const std::vector<const Rex*> RelCompound::target_exprs_
private

Definition at line 1385 of file RelAlgDagBuilder.h.

Referenced by RelTableFunction::replaceInput().


The documentation for this class was generated from the following files: