OmniSciDB  b24e664e58
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 ( 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  }
bool is_agg(const Analyzer::Expr *expr)
#define CHECK_EQ(x, y)
Definition: Logger.h:198
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

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

Implements RelAlgNode.

Definition at line 321 of file RelAlgAbstractInterpreter.cpp.

References agg_exprs_, CHECK(), fields_, filter_expr_, groupby_count_, RelAlgNode::inputs_, is_agg_, scalar_sources_, target_exprs_, and RexVisitorBase< T >::visit().

321  {
322  RexDeepCopyVisitor copier;
323  auto filter_copy = filter_expr_ ? copier.visit(filter_expr_.get()) : nullptr;
324  std::unordered_map<const Rex*, const Rex*> old_to_new_target;
325  std::vector<const RexAgg*> aggs_copy;
326  for (auto& agg : agg_exprs_) {
327  auto copy = agg->deepCopy();
328  old_to_new_target.insert(std::make_pair(agg.get(), copy.get()));
329  aggs_copy.push_back(copy.release());
330  }
331  std::vector<std::unique_ptr<const RexScalar>> sources_copy;
332  for (size_t i = 0; i < scalar_sources_.size(); ++i) {
333  auto copy = copier.visit(scalar_sources_[i].get());
334  old_to_new_target.insert(std::make_pair(scalar_sources_[i].get(), copy.get()));
335  sources_copy.push_back(std::move(copy));
336  }
337  std::vector<const Rex*> target_exprs_copy;
338  for (auto target : target_exprs_) {
339  auto target_it = old_to_new_target.find(target);
340  CHECK(target_it != old_to_new_target.end());
341  target_exprs_copy.push_back(target_it->second);
342  }
343  auto new_compound = std::make_shared<RelCompound>(filter_copy,
344  target_exprs_copy,
346  aggs_copy,
347  fields_,
348  sources_copy,
349  is_agg_);
350  new_compound->addManagedInput(inputs_[0]);
351  return new_compound;
352 }
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
CHECK(cgen_state)
const std::vector< const Rex * > target_exprs_
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
std::unique_ptr< const RexScalar > filter_expr_

+ Here is the call graph for this function:

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_
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_
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:

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:

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:

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:

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:

bool RelCompound::isAggregate ( ) const
inline

Definition at line 1104 of file RelAlgAbstractInterpreter.h.

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

1104 { return is_agg_; }

+ Here is the caller graph for this function:

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

Reimplemented from RelAlgNode.

Definition at line 279 of file RelAlgAbstractInterpreter.cpp.

References filter_expr_, RelAlgNode::replaceInput(), and scalar_sources_.

280  {
281  RelAlgNode::replaceInput(old_input, input);
282  RexRebindInputsVisitor rebind_inputs(old_input.get(), input.get());
283  for (const auto& scalar_source : scalar_sources_) {
284  rebind_inputs.visit(scalar_source.get());
285  }
286  if (filter_expr_) {
287  rebind_inputs.visit(filter_expr_.get());
288  }
289 }
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:

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_
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:198
std::vector< std::unique_ptr< const RexScalar > > scalar_sources_
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:

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

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

Definition at line 1130 of file RelAlgAbstractInterpreter.h.

Referenced by deepCopy().

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

Definition at line 1131 of file RelAlgAbstractInterpreter.h.

Referenced by deepCopy().

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

Definition at line 1127 of file RelAlgAbstractInterpreter.h.

Referenced by deepCopy(), and replaceInput().

const size_t RelCompound::groupby_count_
private

Definition at line 1129 of file RelAlgAbstractInterpreter.h.

Referenced by deepCopy().

const bool RelCompound::is_agg_
private

Definition at line 1132 of file RelAlgAbstractInterpreter.h.

Referenced by deepCopy().

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

Definition at line 1134 of file RelAlgAbstractInterpreter.h.

Referenced by deepCopy(), and replaceInput().

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

Definition at line 1128 of file RelAlgAbstractInterpreter.h.

Referenced by deepCopy().


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