OmniSciDB  0fdbebe030
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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())
 
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 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
 
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 1051 of file RelAlgDagBuilder.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 1056 of file RelAlgDagBuilder.h.

References CHECK_EQ.

1068  : ModifyManipulationTarget(update_disguised_as_select,
1069  delete_disguised_as_select,
1070  varlen_update_required,
1071  manipulation_target_table,
1072  target_columns)
1073  , filter_expr_(std::move(filter_expr))
1074  , target_exprs_(target_exprs)
1075  , groupby_count_(groupby_count)
1076  , fields_(fields)
1077  , is_agg_(is_agg)
1078  , scalar_sources_(std::move(scalar_sources)) {
1079  CHECK_EQ(fields.size(), target_exprs.size());
1080  for (auto agg_expr : agg_exprs) {
1081  agg_exprs_.emplace_back(agg_expr);
1082  }
1083  }
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_
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_

Member Function Documentation

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

Implements RelAlgNode.

Definition at line 368 of file RelAlgDagBuilder.cpp.

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

368  {
369  RexDeepCopyVisitor copier;
370  auto filter_copy = filter_expr_ ? copier.visit(filter_expr_.get()) : nullptr;
371  std::unordered_map<const Rex*, const Rex*> old_to_new_target;
372  std::vector<const RexAgg*> aggs_copy;
373  for (auto& agg : agg_exprs_) {
374  auto copy = agg->deepCopy();
375  old_to_new_target.insert(std::make_pair(agg.get(), copy.get()));
376  aggs_copy.push_back(copy.release());
377  }
378  std::vector<std::unique_ptr<const RexScalar>> sources_copy;
379  for (size_t i = 0; i < scalar_sources_.size(); ++i) {
380  auto copy = copier.visit(scalar_sources_[i].get());
381  old_to_new_target.insert(std::make_pair(scalar_sources_[i].get(), copy.get()));
382  sources_copy.push_back(std::move(copy));
383  }
384  std::vector<const Rex*> target_exprs_copy;
385  for (auto target : target_exprs_) {
386  auto target_it = old_to_new_target.find(target);
387  CHECK(target_it != old_to_new_target.end());
388  target_exprs_copy.push_back(target_it->second);
389  }
390  auto new_compound = std::make_shared<RelCompound>(filter_copy,
391  target_exprs_copy,
393  aggs_copy,
394  fields_,
395  sources_copy,
396  is_agg_);
397  new_compound->addManagedInput(inputs_[0]);
398  return new_compound;
399 }
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 size_t groupby_count_
const std::vector< const Rex * > target_exprs_
std::vector< std::unique_ptr< const RexAgg > > agg_exprs_
std::unique_ptr< const RexScalar > filter_expr_
const bool is_agg_

+ Here is the call graph for this function:

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

Definition at line 1100 of file RelAlgDagBuilder.h.

1100 { return fields_[i]; }
const std::vector< std::string > fields_
const std::vector<std::string>& RelCompound::getFields ( ) const
inline

Definition at line 1098 of file RelAlgDagBuilder.h.

1098 { return fields_; }
const std::vector< std::string > fields_
const RexScalar* RelCompound::getFilterExpr ( ) const
inline

Definition at line 1090 of file RelAlgDagBuilder.h.

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

1090 { 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 1113 of file RelAlgDagBuilder.h.

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

1113 { return groupby_count_; }
const size_t groupby_count_

+ Here is the caller graph for this function:

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

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

1104  {
1105  return scalar_sources_[i].get();
1106  }
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 1102 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().

1102 { 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 1096 of file RelAlgDagBuilder.h.

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

1096 { 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 1115 of file RelAlgDagBuilder.h.

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

1115 { return is_agg_; }
const bool 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 314 of file RelAlgDagBuilder.cpp.

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

315  {
316  RelAlgNode::replaceInput(old_input, input);
317  RexRebindInputsVisitor rebind_inputs(old_input.get(), input.get());
318  for (const auto& scalar_source : scalar_sources_) {
319  rebind_inputs.visit(scalar_source.get());
320  }
321  if (filter_expr_) {
322  rebind_inputs.visit(filter_expr_.get());
323  }
324 }
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 1092 of file RelAlgDagBuilder.h.

1092  {
1093  filter_expr_ = std::move(new_expr);
1094  }
std::unique_ptr< const RexScalar > filter_expr_
void RelCompound::setScalarSources ( std::vector< std::unique_ptr< const RexScalar >> &  new_sources)
inline

Definition at line 1108 of file RelAlgDagBuilder.h.

References CHECK_EQ.

1108  {
1109  CHECK_EQ(new_sources.size(), scalar_sources_.size());
1110  scalar_sources_ = std::move(new_sources);
1111  }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
std::vector< std::unique_ptr< const RexScalar > > scalar_sources_
size_t RelCompound::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1088 of file RelAlgDagBuilder.h.

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

1088 { 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 1117 of file RelAlgDagBuilder.h.

References run_benchmark_import::result, and to_string().

1117  {
1118  std::string result =
1119  "(RelCompound<" + std::to_string(reinterpret_cast<uint64_t>(this)) + ">(";
1120  result += (filter_expr_ ? filter_expr_->toString() : "null") + " ";
1121  for (const auto target_expr : target_exprs_) {
1122  result += target_expr->toString() + " ";
1123  }
1124  result += "groups: [";
1125  for (size_t group_index = 0; group_index < groupby_count_; ++group_index) {
1126  result += " " + std::to_string(group_index);
1127  }
1128  result += " ] sources: [";
1129  for (const auto& scalar_source : scalar_sources_) {
1130  result += " " + scalar_source->toString();
1131  }
1132  return result + " ])";
1133  }
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

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

Definition at line 1141 of file RelAlgDagBuilder.h.

Referenced by deepCopy().

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

Definition at line 1142 of file RelAlgDagBuilder.h.

Referenced by deepCopy().

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

Definition at line 1138 of file RelAlgDagBuilder.h.

Referenced by deepCopy(), and replaceInput().

const size_t RelCompound::groupby_count_
private

Definition at line 1140 of file RelAlgDagBuilder.h.

Referenced by deepCopy().

const bool RelCompound::is_agg_
private

Definition at line 1143 of file RelAlgDagBuilder.h.

Referenced by deepCopy().

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

Definition at line 1145 of file RelAlgDagBuilder.h.

Referenced by deepCopy(), and replaceInput().

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

Definition at line 1139 of file RelAlgDagBuilder.h.

Referenced by deepCopy().


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