OmniSciDB  04ee39c94c
RelCompound Class Reference

#include <RelAlgAbstractInterpreter.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())
 
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
 
- Public Member Functions inherited from RelAlgNode
 RelAlgNode ()
 
virtual ~RelAlgNode ()
 
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
 
int getTargetColumnCount () 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 std::vector< const Rex * > target_exprs_
 
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_
 

Additional Inherited Members

- Static Public Member Functions inherited from RelAlgNode
static void resetRelAlgFirstId () noexcept
 
- Protected Attributes inherited from RelAlgNode
std::vector< std::shared_ptr< const RelAlgNode > > inputs_
 
const unsigned id_
 

Detailed Description

Definition at line 1040 of file RelAlgAbstractInterpreter.h.

Constructor & Destructor Documentation

◆ RelCompound()

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 1045 of file RelAlgAbstractInterpreter.h.

References CHECK_EQ.

1057  : ModifyManipulationTarget(update_disguised_as_select,
1058  delete_disguised_as_select,
1059  varlen_update_required,
1060  manipulation_target_table,
1061  target_columns)
1062  , filter_expr_(std::move(filter_expr))
1063  , target_exprs_(target_exprs)
1064  , groupby_count_(groupby_count)
1065  , fields_(fields)
1066  , is_agg_(is_agg)
1067  , scalar_sources_(std::move(scalar_sources)) {
1068  CHECK_EQ(fields.size(), target_exprs.size());
1069  for (auto agg_expr : agg_exprs) {
1070  agg_exprs_.emplace_back(agg_expr);
1071  }
1072  }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
const std::vector< std::string > fields_
std::vector< std::unique_ptr< const RexScalar > > scalar_sources_
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())

Member Function Documentation

◆ deepCopy()

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

Implements RelAlgNode.

Definition at line 311 of file RelAlgAbstractInterpreter.cpp.

References CHECK, RelAlgNode::inputs_, and RexVisitorBase< T >::visit().

311  {
312  RexDeepCopyVisitor copier;
313  auto filter_copy = filter_expr_ ? copier.visit(filter_expr_.get()) : nullptr;
314  std::unordered_map<const Rex*, const Rex*> old_to_new_target;
315  std::vector<const RexAgg*> aggs_copy;
316  for (auto& agg : agg_exprs_) {
317  auto copy = agg->deepCopy();
318  old_to_new_target.insert(std::make_pair(agg.get(), copy.get()));
319  aggs_copy.push_back(copy.release());
320  }
321  std::vector<std::unique_ptr<const RexScalar>> sources_copy;
322  for (size_t i = 0; i < scalar_sources_.size(); ++i) {
323  auto copy = copier.visit(scalar_sources_[i].get());
324  old_to_new_target.insert(std::make_pair(scalar_sources_[i].get(), copy.get()));
325  sources_copy.push_back(std::move(copy));
326  }
327  std::vector<const Rex*> target_exprs_copy;
328  for (auto target : target_exprs_) {
329  auto target_it = old_to_new_target.find(target);
330  CHECK(target_it != old_to_new_target.end());
331  target_exprs_copy.push_back(target_it->second);
332  }
333  auto new_compound = std::make_shared<RelCompound>(filter_copy,
334  target_exprs_copy,
336  aggs_copy,
337  fields_,
338  sources_copy,
339  is_agg_);
340  new_compound->addManagedInput(inputs_[0]);
341  return new_compound;
342 }
std::vector< std::shared_ptr< const RelAlgNode > > inputs_
const std::vector< std::string > fields_
std::vector< std::unique_ptr< const RexScalar > > scalar_sources_
virtual T visit(const RexScalar *rex_scalar) const
Definition: RexVisitor.h:27
const std::vector< const Rex * > target_exprs_
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
std::unique_ptr< const RexScalar > filter_expr_
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the call graph for this function:

◆ getFieldName()

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

Definition at line 1089 of file RelAlgAbstractInterpreter.h.

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

◆ getFields()

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

Definition at line 1087 of file RelAlgAbstractInterpreter.h.

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

◆ getFilterExpr()

const RexScalar* RelCompound::getFilterExpr ( ) const
inline

Definition at line 1079 of file RelAlgAbstractInterpreter.h.

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

1079 { 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 1102 of file RelAlgAbstractInterpreter.h.

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

1102 { return groupby_count_; }
+ Here is the caller graph for this function:

◆ getScalarSource()

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

Definition at line 1093 of file RelAlgAbstractInterpreter.h.

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

1093  {
1094  return scalar_sources_[i].get();
1095  }
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 1091 of file RelAlgAbstractInterpreter.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().

1091 { 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 1085 of file RelAlgAbstractInterpreter.h.

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

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

◆ isAggregate()

bool RelCompound::isAggregate ( ) const
inline

Definition at line 1104 of file RelAlgAbstractInterpreter.h.

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

1104 { return 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 269 of file RelAlgAbstractInterpreter.cpp.

References RelAlgNode::replaceInput().

270  {
271  RelAlgNode::replaceInput(old_input, input);
272  RexRebindInputsVisitor rebind_inputs(old_input.get(), input.get());
273  for (const auto& scalar_source : scalar_sources_) {
274  rebind_inputs.visit(scalar_source.get());
275  }
276  if (filter_expr_) {
277  rebind_inputs.visit(filter_expr_.get());
278  }
279 }
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 1081 of file RelAlgAbstractInterpreter.h.

1081  {
1082  filter_expr_ = std::move(new_expr);
1083  }
std::unique_ptr< const RexScalar > filter_expr_

◆ setScalarSources()

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

Definition at line 1097 of file RelAlgAbstractInterpreter.h.

References CHECK_EQ.

1097  {
1098  CHECK_EQ(new_sources.size(), scalar_sources_.size());
1099  scalar_sources_ = std::move(new_sources);
1100  }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
std::vector< std::unique_ptr< const RexScalar > > scalar_sources_

◆ size()

size_t RelCompound::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1077 of file RelAlgAbstractInterpreter.h.

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

1077 { 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 1106 of file RelAlgAbstractInterpreter.h.

References run-benchmark-import::result, and to_string().

1106  {
1107  std::string result =
1108  "(RelCompound<" + std::to_string(reinterpret_cast<uint64_t>(this)) + ">(";
1109  result += (filter_expr_ ? filter_expr_->toString() : "null") + " ";
1110  for (const auto target_expr : target_exprs_) {
1111  result += target_expr->toString() + " ";
1112  }
1113  result += "groups: [";
1114  for (size_t group_index = 0; group_index < groupby_count_; ++group_index) {
1115  result += " " + std::to_string(group_index);
1116  }
1117  result += " ] sources: [";
1118  for (const auto& scalar_source : scalar_sources_) {
1119  result += " " + scalar_source->toString();
1120  }
1121  return result + " ])";
1122  }
std::vector< std::unique_ptr< const RexScalar > > scalar_sources_
std::string to_string(char const *&&v)
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 1130 of file RelAlgAbstractInterpreter.h.

◆ fields_

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

Definition at line 1131 of file RelAlgAbstractInterpreter.h.

◆ filter_expr_

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

Definition at line 1127 of file RelAlgAbstractInterpreter.h.

◆ groupby_count_

const size_t RelCompound::groupby_count_
private

Definition at line 1129 of file RelAlgAbstractInterpreter.h.

◆ is_agg_

const bool RelCompound::is_agg_
private

Definition at line 1132 of file RelAlgAbstractInterpreter.h.

◆ scalar_sources_

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

Definition at line 1134 of file RelAlgAbstractInterpreter.h.

◆ target_exprs_

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

Definition at line 1128 of file RelAlgAbstractInterpreter.h.


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