OmniSciDB  a987f07e93
 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)
 
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
 
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 ()
 

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
 

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_
 

Detailed Description

Definition at line 576 of file RelAlgDag.h.

Constructor & Destructor Documentation

RexWindowFunctionOperator::RexWindowFunctionOperator ( )
inline

Definition at line 604 of file RelAlgDag.h.

References INVALID.

Referenced by disambiguatedOperands(), and toHash().

+ 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 607 of file RelAlgDag.h.

616  : RexFunctionOperator(::toString(kind), operands, ti)
617  , kind_(kind)
618  , partition_keys_(std::move(partition_keys))
619  , order_keys_(std::move(order_keys))
620  , collation_(collation)
621  , frame_start_bound_(frame_start_bound)
622  , frame_end_bound_(frame_end_bound)
623  , is_rows_(is_rows) {}
RexWindowBound frame_start_bound_
Definition: RelAlgDag.h:736
RexFunctionOperator()=default
SqlWindowFunctionKind kind_
Definition: RelAlgDag.h:732
ConstRexScalarPtrVector order_keys_
Definition: RelAlgDag.h:734
std::vector< SortField > collation_
Definition: RelAlgDag.h:735
RexWindowBound frame_end_bound_
Definition: RelAlgDag.h:737
ConstRexScalarPtrVector partition_keys_
Definition: RelAlgDag.h:733
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
Definition: RelAlgDag.h:679

Member Function Documentation

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 662 of file RelAlgDag.h.

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

Referenced by RexDeepCopyVisitor::visitWindowFunctionOperator().

666  {
667  return std::unique_ptr<const RexOperator>(
669  operands,
670  partition_keys,
671  order_keys,
672  collation,
675  isRows(),
676  getType()));
677  }
const SQLTypeInfo & getType() const
Definition: RelAlgDag.h:284
SqlWindowFunctionKind kind_
Definition: RelAlgDag.h:732
const RexWindowBound & getFrameEndBound() const
Definition: RelAlgDag.h:658
const RexWindowBound & getFrameStartBound() const
Definition: RelAlgDag.h:656
bool isRows() const
Definition: RelAlgDag.h:660

+ 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 654 of file RelAlgDag.h.

References collation_.

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

654 { return collation_; }
std::vector< SortField > collation_
Definition: RelAlgDag.h:735

+ Here is the caller graph for this function:

const RexWindowBound& RexWindowFunctionOperator::getFrameEndBound ( ) const
inline

Definition at line 658 of file RelAlgDag.h.

References frame_end_bound_.

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

658 { return frame_end_bound_; }
RexWindowBound frame_end_bound_
Definition: RelAlgDag.h:737

+ Here is the caller graph for this function:

const RexWindowBound& RexWindowFunctionOperator::getFrameStartBound ( ) const
inline

Definition at line 656 of file RelAlgDag.h.

References frame_start_bound_.

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

656 { return frame_start_bound_; }
RexWindowBound frame_start_bound_
Definition: RelAlgDag.h:736

+ Here is the caller graph for this function:

SqlWindowFunctionKind RexWindowFunctionOperator::getKind ( ) const
inline

Definition at line 625 of file RelAlgDag.h.

References kind_.

Referenced by RelAlgTranslator::translateWindowFunction().

625 { return kind_; }
SqlWindowFunctionKind kind_
Definition: RelAlgDag.h:732

+ Here is the caller graph for this function:

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

Definition at line 633 of file RelAlgDag.h.

References order_keys_.

633  {
634  return std::move(order_keys_);
635  }
ConstRexScalarPtrVector order_keys_
Definition: RelAlgDag.h:734
ConstRexScalarPtrVector RexWindowFunctionOperator::getPartitionKeysAndRelease ( ) const
inline

Definition at line 629 of file RelAlgDag.h.

References partition_keys_.

629  {
630  return std::move(partition_keys_);
631  }
ConstRexScalarPtrVector partition_keys_
Definition: RelAlgDag.h:733
bool RexWindowFunctionOperator::isRows ( ) const
inline

Definition at line 660 of file RelAlgDag.h.

References is_rows_.

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

660 { 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 650 of file RelAlgDag.h.

References RexOperator::operands_.

650  {
651  operands_ = std::move(new_operands);
652  }
std::vector< std::unique_ptr< const RexScalar > > operands_
Definition: RelAlgDag.h:309
void RexWindowFunctionOperator::replaceOrderKey ( size_t  offset,
std::unique_ptr< const RexScalar > &&  new_order_key 
)
inline

Definition at line 645 of file RelAlgDag.h.

References CHECK_LT, and order_keys_.

645  {
646  CHECK_LT(offset, order_keys_.size());
647  order_keys_[offset] = std::move(new_order_key);
648  }
#define CHECK_LT(x, y)
Definition: Logger.h:299
ConstRexScalarPtrVector order_keys_
Definition: RelAlgDag.h:734
void RexWindowFunctionOperator::replacePartitionKey ( size_t  offset,
std::unique_ptr< const RexScalar > &&  new_partition_key 
)
inline

Definition at line 639 of file RelAlgDag.h.

References CHECK_LT, and partition_keys_.

640  {
641  CHECK_LT(offset, partition_keys_.size());
642  partition_keys_[offset] = std::move(new_partition_key);
643  }
#define CHECK_LT(x, y)
Definition: Logger.h:299
ConstRexScalarPtrVector partition_keys_
Definition: RelAlgDag.h:733
size_t RexWindowFunctionOperator::toHash ( ) const
inlineoverridevirtual

Reimplemented from RexFunctionOperator.

Definition at line 696 of file RelAlgDag.h.

References collation_, frame_end_bound_, frame_start_bound_, RexFunctionOperator::getName(), RexOperator::getType(), Rex::hash_, HASH_N, is_rows_, RexOperator::operands_, order_keys_, partition_keys_, and RexWindowFunctionOperator().

696  {
697  if (!hash_) {
698  hash_ = typeid(RexWindowFunctionOperator).hash_code();
699  boost::hash_combine(*hash_, getType().get_type_name());
700  boost::hash_combine(*hash_, getName());
701  boost::hash_combine(*hash_, is_rows_);
702  for (auto& collation : collation_) {
703  boost::hash_combine(*hash_, collation.toHash());
704  }
705  for (auto& operand : operands_) {
706  boost::hash_combine(*hash_, operand->toHash());
707  }
708  for (auto& key : partition_keys_) {
709  boost::hash_combine(*hash_, key->toHash());
710  }
711  for (auto& key : order_keys_) {
712  boost::hash_combine(*hash_, key->toHash());
713  }
714  auto get_window_bound_hash =
716  auto h =
717  boost::hash_value(bound.bound_expr ? bound.bound_expr->toHash() : HASH_N);
718  boost::hash_combine(h, bound.unbounded);
719  boost::hash_combine(h, bound.preceding);
720  boost::hash_combine(h, bound.following);
721  boost::hash_combine(h, bound.is_current_row);
722  boost::hash_combine(h, bound.order_key);
723  return h;
724  };
725  boost::hash_combine(*hash_, get_window_bound_hash(frame_start_bound_));
726  boost::hash_combine(*hash_, get_window_bound_hash(frame_end_bound_));
727  }
728  return *hash_;
729  }
RexWindowBound frame_start_bound_
Definition: RelAlgDag.h:736
const SQLTypeInfo & getType() const
Definition: RelAlgDag.h:284
static auto const HASH_N
Definition: RelAlgDag.h:44
std::vector< std::unique_ptr< const RexScalar > > operands_
Definition: RelAlgDag.h:309
std::optional< size_t > hash_
Definition: RelAlgDag.h:62
ConstRexScalarPtrVector order_keys_
Definition: RelAlgDag.h:734
std::vector< SortField > collation_
Definition: RelAlgDag.h:735
RexWindowBound frame_end_bound_
Definition: RelAlgDag.h:737
ConstRexScalarPtrVector partition_keys_
Definition: RelAlgDag.h:733
const std::string & getName() const
Definition: RelAlgDag.h:500

+ Here is the call graph for this function:

std::string RexWindowFunctionOperator::toString ( RelRexToStringConfig  config = RelRexToStringConfig::defaults()) const
inlineoverridevirtual

Reimplemented from RexFunctionOperator.

Definition at line 679 of file RelAlgDag.h.

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

680  {
681  auto ret = cat(::typeName(this), "(", getName(), ", operands=");
682  for (auto& operand : operands_) {
683  ret += operand->toString(config) + " ";
684  }
685  ret += ", partition_keys=";
686  for (auto& key : partition_keys_) {
687  ret += key->toString(config) + " ";
688  }
689  ret += ", order_keys=";
690  for (auto& key : order_keys_) {
691  ret += key->toString(config) + " ";
692  }
693  return cat(ret, ")");
694  }
std::string cat(Ts &&...args)
std::vector< std::unique_ptr< const RexScalar > > operands_
Definition: RelAlgDag.h:309
ConstRexScalarPtrVector order_keys_
Definition: RelAlgDag.h:734
std::string typeName(const T *v)
Definition: toString.h:103
ConstRexScalarPtrVector partition_keys_
Definition: RelAlgDag.h:733
const std::string & getName() const
Definition: RelAlgDag.h:500

+ Here is the call graph for this function:

Friends And Related Function Documentation

friend struct RelAlgDagSerializer
friend

Definition at line 740 of file RelAlgDag.h.

Member Data Documentation

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

Definition at line 735 of file RelAlgDag.h.

Referenced by getCollation(), and toHash().

RexWindowBound RexWindowFunctionOperator::frame_end_bound_
private

Definition at line 737 of file RelAlgDag.h.

Referenced by getFrameEndBound(), and toHash().

RexWindowBound RexWindowFunctionOperator::frame_start_bound_
private

Definition at line 736 of file RelAlgDag.h.

Referenced by getFrameStartBound(), and toHash().

bool RexWindowFunctionOperator::is_rows_
private

Definition at line 738 of file RelAlgDag.h.

Referenced by isRows(), and toHash().

SqlWindowFunctionKind RexWindowFunctionOperator::kind_
private

Definition at line 732 of file RelAlgDag.h.

Referenced by disambiguatedOperands(), and getKind().

ConstRexScalarPtrVector RexWindowFunctionOperator::order_keys_
mutableprivate

Definition at line 734 of file RelAlgDag.h.

Referenced by getOrderKeys(), getOrderKeysAndRelease(), replaceOrderKey(), toHash(), and toString().

ConstRexScalarPtrVector RexWindowFunctionOperator::partition_keys_
mutableprivate

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