OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RexWindowFunctionOperator Class Reference

#include <RelAlgDag.h>

+ Inheritance diagram for RexWindowFunctionOperator:
+ Collaboration diagram for RexWindowFunctionOperator:

Classes

struct  RexWindowBound
 

Public Member Functions

 RexWindowFunctionOperator ()
 
 RexWindowFunctionOperator (const SqlWindowFunctionKind kind, ConstRexScalarPtrVector &operands, ConstRexScalarPtrVector &partition_keys, ConstRexScalarPtrVector &order_keys, const std::vector< SortField > collation, const RexWindowBound &frame_start_bound, const RexWindowBound &frame_end_bound, const bool is_rows, const SQLTypeInfo &ti)
 
virtual void acceptChildren (Visitor &v) const override
 
virtual void accept (Visitor &v, std::string name) const override
 
SqlWindowFunctionKind getKind () const
 
const ConstRexScalarPtrVectorgetPartitionKeys () const
 
ConstRexScalarPtrVector getPartitionKeysAndRelease () const
 
ConstRexScalarPtrVector getOrderKeysAndRelease () const
 
const ConstRexScalarPtrVectorgetOrderKeys () const
 
void replacePartitionKey (size_t offset, std::unique_ptr< const RexScalar > &&new_partition_key)
 
void replaceOrderKey (size_t offset, std::unique_ptr< const RexScalar > &&new_order_key)
 
void replaceOperands (std::vector< std::unique_ptr< const RexScalar >> &&new_operands)
 
const std::vector< SortField > & getCollation () const
 
const RexWindowBoundgetFrameStartBound () const
 
const RexWindowBoundgetFrameEndBound () const
 
bool isRows () const
 
std::unique_ptr< const
RexOperator
disambiguatedOperands (ConstRexScalarPtrVector &operands, ConstRexScalarPtrVector &partition_keys, ConstRexScalarPtrVector &order_keys, const std::vector< SortField > &collation) const
 
std::string toString (RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
 
virtual size_t toHash () const override
 
- Public Member Functions inherited from RexFunctionOperator
 RexFunctionOperator ()=default
 
 RexFunctionOperator (const std::string &name, ConstRexScalarPtrVector &operands, const SQLTypeInfo &ti)
 
std::unique_ptr< const
RexOperator
getDisambiguated (std::vector< std::unique_ptr< const RexScalar >> &operands) const override
 
const std::string & getName () const
 
- Public Member Functions inherited from RexOperator
 RexOperator ()
 
 RexOperator (const SQLOps op, std::vector< std::unique_ptr< const RexScalar >> &operands, const SQLTypeInfo &type)
 
size_t size () const
 
const RexScalargetOperand (const size_t idx) const
 
const RexScalargetOperandAndRelease (const size_t idx) const
 
SQLOps getOperator () const
 
const SQLTypeInfogetType () const
 
- Public Member Functions inherited from Rex
virtual ~Rex ()
 
virtual size_t getStepNumber () const
 
- Public Member Functions inherited from RelAlgDagNode
 RelAlgDagNode ()
 
virtual void setStepNumber (size_t step) const
 
std::optional< size_t > getIdInPlanTree () const
 
void setIdInPlanTree (size_t id) const
 

Private Attributes

SqlWindowFunctionKind kind_
 
ConstRexScalarPtrVector partition_keys_
 
ConstRexScalarPtrVector order_keys_
 
std::vector< SortFieldcollation_
 
RexWindowBound frame_start_bound_
 
RexWindowBound frame_end_bound_
 
bool is_rows_
 

Friends

struct RelAlgDagSerializer
 
std::size_t hash_value (RexWindowFunctionOperator const &)
 

Additional Inherited Members

- Public Types inherited from RexFunctionOperator
using ConstRexScalarPtr = std::unique_ptr< const RexScalar >
 
using ConstRexScalarPtrVector = std::vector< ConstRexScalarPtr >
 
- Protected Attributes inherited from RexOperator
SQLOps op_
 
std::vector< std::unique_ptr
< const RexScalar > > 
operands_
 
SQLTypeInfo type_
 
- Protected Attributes inherited from Rex
std::optional< size_t > hash_
 
- Protected Attributes inherited from RelAlgDagNode
size_t step_ {0}
 
std::optional< size_t > id_in_plan_tree_
 

Detailed Description

Definition at line 574 of file RelAlgDag.h.

Constructor & Destructor Documentation

RexWindowFunctionOperator::RexWindowFunctionOperator ( )
inline

Definition at line 602 of file RelAlgDag.h.

References INVALID.

Referenced by disambiguatedOperands().

+ Here is the caller graph for this function:

RexWindowFunctionOperator::RexWindowFunctionOperator ( const SqlWindowFunctionKind  kind,
ConstRexScalarPtrVector operands,
ConstRexScalarPtrVector partition_keys,
ConstRexScalarPtrVector order_keys,
const std::vector< SortField collation,
const RexWindowBound frame_start_bound,
const RexWindowBound frame_end_bound,
const bool  is_rows,
const SQLTypeInfo ti 
)
inline

Definition at line 605 of file RelAlgDag.h.

614  : RexFunctionOperator(::toString(kind), operands, ti)
615  , kind_(kind)
616  , partition_keys_(std::move(partition_keys))
617  , order_keys_(std::move(order_keys))
618  , collation_(collation)
619  , frame_start_bound_(frame_start_bound)
620  , frame_end_bound_(frame_end_bound)
621  , is_rows_(is_rows) {}
RexWindowBound frame_start_bound_
Definition: RelAlgDag.h:725
RexFunctionOperator()=default
SqlWindowFunctionKind kind_
Definition: RelAlgDag.h:721
ConstRexScalarPtrVector order_keys_
Definition: RelAlgDag.h:723
std::vector< SortField > collation_
Definition: RelAlgDag.h:724
RexWindowBound frame_end_bound_
Definition: RelAlgDag.h:726
ConstRexScalarPtrVector partition_keys_
Definition: RelAlgDag.h:722
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
Definition: RelAlgDag.h:695

Member Function Documentation

virtual void RexWindowFunctionOperator::accept ( Visitor v,
std::string  name 
) const
inlineoverridevirtual

Reimplemented from RexFunctionOperator.

Definition at line 635 of file RelAlgDag.h.

References acceptChildren(), and RelAlgDagNode::Visitor::visit().

Referenced by TableFunctionsFactory_node.PrintNode::__str__().

635  {
636  if (v.visit(this, std::move(name))) {
637  acceptChildren(v);
638  }
639  }
virtual void acceptChildren(Visitor &v) const override
Definition: RelAlgDag.h:623
string name
Definition: setup.in.py:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual void RexWindowFunctionOperator::acceptChildren ( Visitor v) const
inlineoverridevirtual

Reimplemented from RexFunctionOperator.

Definition at line 623 of file RelAlgDag.h.

References getOrderKeys(), and getPartitionKeys().

Referenced by accept().

623  {
624  for (auto const& partition_key : getPartitionKeys()) {
625  if (partition_key) {
626  partition_key->accept(v, "partition");
627  }
628  }
629  for (auto const& order_key : getOrderKeys()) {
630  if (order_key) {
631  order_key->accept(v, "order");
632  }
633  }
634  }
const ConstRexScalarPtrVector & getPartitionKeys() const
Definition: RelAlgDag.h:643
const ConstRexScalarPtrVector & getOrderKeys() const
Definition: RelAlgDag.h:653

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::unique_ptr<const RexOperator> RexWindowFunctionOperator::disambiguatedOperands ( ConstRexScalarPtrVector operands,
ConstRexScalarPtrVector partition_keys,
ConstRexScalarPtrVector order_keys,
const std::vector< SortField > &  collation 
) const
inline

Definition at line 678 of file RelAlgDag.h.

References getFrameEndBound(), getFrameStartBound(), RexOperator::getType(), isRows(), kind_, and RexWindowFunctionOperator().

Referenced by RexDeepCopyVisitor::visitWindowFunctionOperator().

682  {
683  return std::unique_ptr<const RexOperator>(
685  operands,
686  partition_keys,
687  order_keys,
688  collation,
691  isRows(),
692  getType()));
693  }
const SQLTypeInfo & getType() const
Definition: RelAlgDag.h:378
SqlWindowFunctionKind kind_
Definition: RelAlgDag.h:721
const RexWindowBound & getFrameEndBound() const
Definition: RelAlgDag.h:674
const RexWindowBound & getFrameStartBound() const
Definition: RelAlgDag.h:672
bool isRows() const
Definition: RelAlgDag.h:676

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const std::vector<SortField>& RexWindowFunctionOperator::getCollation ( ) const
inline

Definition at line 670 of file RelAlgDag.h.

References collation_.

Referenced by RelAlgTranslator::translateWindowFunction(), and RexDeepCopyVisitor::visitWindowFunctionOperator().

670 { return collation_; }
std::vector< SortField > collation_
Definition: RelAlgDag.h:724

+ Here is the caller graph for this function:

const RexWindowBound& RexWindowFunctionOperator::getFrameEndBound ( ) const
inline

Definition at line 674 of file RelAlgDag.h.

References frame_end_bound_.

Referenced by disambiguatedOperands(), and RelAlgTranslator::translateWindowFunction().

674 { return frame_end_bound_; }
RexWindowBound frame_end_bound_
Definition: RelAlgDag.h:726

+ Here is the caller graph for this function:

const RexWindowBound& RexWindowFunctionOperator::getFrameStartBound ( ) const
inline

Definition at line 672 of file RelAlgDag.h.

References frame_start_bound_.

Referenced by disambiguatedOperands(), and RelAlgTranslator::translateWindowFunction().

672 { return frame_start_bound_; }
RexWindowBound frame_start_bound_
Definition: RelAlgDag.h:725

+ Here is the caller graph for this function:

SqlWindowFunctionKind RexWindowFunctionOperator::getKind ( ) const
inline

Definition at line 641 of file RelAlgDag.h.

References kind_.

Referenced by RelAlgTranslator::translateWindowFunction().

641 { return kind_; }
SqlWindowFunctionKind kind_
Definition: RelAlgDag.h:721

+ Here is the caller graph for this function:

const ConstRexScalarPtrVector& RexWindowFunctionOperator::getOrderKeys ( ) const
inline
ConstRexScalarPtrVector RexWindowFunctionOperator::getOrderKeysAndRelease ( ) const
inline

Definition at line 649 of file RelAlgDag.h.

References order_keys_.

649  {
650  return std::move(order_keys_);
651  }
ConstRexScalarPtrVector order_keys_
Definition: RelAlgDag.h:723
ConstRexScalarPtrVector RexWindowFunctionOperator::getPartitionKeysAndRelease ( ) const
inline

Definition at line 645 of file RelAlgDag.h.

References partition_keys_.

645  {
646  return std::move(partition_keys_);
647  }
ConstRexScalarPtrVector partition_keys_
Definition: RelAlgDag.h:722
bool RexWindowFunctionOperator::isRows ( ) const
inline

Definition at line 676 of file RelAlgDag.h.

References is_rows_.

Referenced by disambiguatedOperands(), and RelAlgTranslator::translateWindowFunction().

676 { return is_rows_; }

+ Here is the caller graph for this function:

void RexWindowFunctionOperator::replaceOperands ( std::vector< std::unique_ptr< const RexScalar >> &&  new_operands)
inline

Definition at line 666 of file RelAlgDag.h.

References RexOperator::operands_.

666  {
667  operands_ = std::move(new_operands);
668  }
std::vector< std::unique_ptr< const RexScalar > > operands_
Definition: RelAlgDag.h:400
void RexWindowFunctionOperator::replaceOrderKey ( size_t  offset,
std::unique_ptr< const RexScalar > &&  new_order_key 
)
inline

Definition at line 661 of file RelAlgDag.h.

References CHECK_LT, and order_keys_.

661  {
662  CHECK_LT(offset, order_keys_.size());
663  order_keys_[offset] = std::move(new_order_key);
664  }
#define CHECK_LT(x, y)
Definition: Logger.h:303
ConstRexScalarPtrVector order_keys_
Definition: RelAlgDag.h:723
void RexWindowFunctionOperator::replacePartitionKey ( size_t  offset,
std::unique_ptr< const RexScalar > &&  new_partition_key 
)
inline

Definition at line 655 of file RelAlgDag.h.

References CHECK_LT, and partition_keys_.

656  {
657  CHECK_LT(offset, partition_keys_.size());
658  partition_keys_[offset] = std::move(new_partition_key);
659  }
#define CHECK_LT(x, y)
Definition: Logger.h:303
ConstRexScalarPtrVector partition_keys_
Definition: RelAlgDag.h:722
virtual size_t RexWindowFunctionOperator::toHash ( ) const
inlineoverridevirtual

Reimplemented from RexFunctionOperator.

Definition at line 716 of file RelAlgDag.h.

References hash_value.

716 { return hash_value(*this); }
friend std::size_t hash_value(RexWindowFunctionOperator const &)
Definition: RelAlgDag.cpp:3599
std::string RexWindowFunctionOperator::toString ( RelRexToStringConfig  config = RelRexToStringConfig::defaults()) const
inlineoverridevirtual

Reimplemented from RexFunctionOperator.

Definition at line 695 of file RelAlgDag.h.

References cat(), RexFunctionOperator::getName(), RexOperator::operands_, order_keys_, partition_keys_, and typeName().

696  {
697  if (!config.attributes_only) {
698  auto ret = cat(::typeName(this), "(", getName(), ", operands=");
699  for (auto& operand : operands_) {
700  ret += operand->toString(config) + " ";
701  }
702  ret += ", partition_keys=";
703  for (auto& key : partition_keys_) {
704  ret += key->toString(config) + " ";
705  }
706  ret += ", order_keys=";
707  for (auto& key : order_keys_) {
708  ret += key->toString(config) + " ";
709  }
710  return cat(ret, ")");
711  } else {
712  return cat(::typeName(this), "(", getName(), ")");
713  }
714  }
std::string cat(Ts &&...args)
std::vector< std::unique_ptr< const RexScalar > > operands_
Definition: RelAlgDag.h:400
ConstRexScalarPtrVector order_keys_
Definition: RelAlgDag.h:723
std::string typeName(const T *v)
Definition: toString.h:106
ConstRexScalarPtrVector partition_keys_
Definition: RelAlgDag.h:722
const std::string & getName() const
Definition: RelAlgDag.h:506

+ Here is the call graph for this function:

Friends And Related Function Documentation

std::size_t hash_value ( RexWindowFunctionOperator const &  rex_window)
friend

Definition at line 3599 of file RelAlgDag.cpp.

Referenced by toHash().

3599  {
3600  if (rex_window.hash_) {
3601  return *rex_window.hash_;
3602  }
3603  rex_window.hash_ = typeid(RexWindowFunctionOperator).hash_code();
3604  boost::hash_combine(*rex_window.hash_, rex_window.getType().get_type_name());
3605  boost::hash_combine(*rex_window.hash_, rex_window.getName());
3606  boost::hash_combine(*rex_window.hash_, rex_window.is_rows_);
3607  boost::hash_combine(*rex_window.hash_, rex_window.collation_);
3608  boost::hash_combine(*rex_window.hash_, rex_window.operands_);
3609  boost::hash_combine(*rex_window.hash_, rex_window.partition_keys_);
3610  boost::hash_combine(*rex_window.hash_, rex_window.order_keys_);
3611  auto get_window_bound_hash =
3613  auto h = boost::hash_value(bound.bound_expr);
3614  boost::hash_combine(h, bound.unbounded);
3615  boost::hash_combine(h, bound.preceding);
3616  boost::hash_combine(h, bound.following);
3617  boost::hash_combine(h, bound.is_current_row);
3618  boost::hash_combine(h, bound.order_key);
3619  return h;
3620  };
3621  boost::hash_combine(*rex_window.hash_,
3622  get_window_bound_hash(rex_window.frame_start_bound_));
3623  boost::hash_combine(*rex_window.hash_,
3624  get_window_bound_hash(rex_window.frame_end_bound_));
3625  return *rex_window.hash_;
3626 }
std::size_t hash_value(RexAbstractInput const &rex_ab_input)
Definition: RelAlgDag.cpp:3525
friend struct RelAlgDagSerializer
friend

Definition at line 729 of file RelAlgDag.h.

Member Data Documentation

std::vector<SortField> RexWindowFunctionOperator::collation_
private

Definition at line 724 of file RelAlgDag.h.

Referenced by getCollation(), and hash_value().

RexWindowBound RexWindowFunctionOperator::frame_end_bound_
private

Definition at line 726 of file RelAlgDag.h.

Referenced by getFrameEndBound(), and hash_value().

RexWindowBound RexWindowFunctionOperator::frame_start_bound_
private

Definition at line 725 of file RelAlgDag.h.

Referenced by getFrameStartBound(), and hash_value().

bool RexWindowFunctionOperator::is_rows_
private

Definition at line 727 of file RelAlgDag.h.

Referenced by hash_value(), and isRows().

SqlWindowFunctionKind RexWindowFunctionOperator::kind_
private

Definition at line 721 of file RelAlgDag.h.

Referenced by disambiguatedOperands(), and getKind().

ConstRexScalarPtrVector RexWindowFunctionOperator::order_keys_
mutableprivate
ConstRexScalarPtrVector RexWindowFunctionOperator::partition_keys_
mutableprivate

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