OmniSciDB  cde582ebc3
 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 (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 (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 (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

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

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
const SQLOps op_
 
std::vector< std::unique_ptr
< const RexScalar > > 
operands_
 
const SQLTypeInfo type_
 
- Protected Attributes inherited from Rex
std::optional< size_t > hash_
 

Detailed Description

Definition at line 526 of file RelAlgDag.h.

Constructor & Destructor Documentation

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

Referenced by disambiguatedOperands(), and toHash().

562  : RexFunctionOperator(::toString(kind), operands, ti)
563  , kind_(kind)
564  , partition_keys_(std::move(partition_keys))
565  , order_keys_(std::move(order_keys))
566  , collation_(collation)
567  , frame_start_bound_(frame_start_bound)
568  , frame_end_bound_(frame_end_bound)
569  , is_rows_(is_rows) {}
const SqlWindowFunctionKind kind_
Definition: RelAlgDag.h:678
const RexWindowBound frame_end_bound_
Definition: RelAlgDag.h:683
const std::vector< SortField > collation_
Definition: RelAlgDag.h:681
const RexWindowBound frame_start_bound_
Definition: RelAlgDag.h:682
ConstRexScalarPtrVector order_keys_
Definition: RelAlgDag.h:680
RexFunctionOperator(const std::string &name, ConstRexScalarPtrVector &operands, const SQLTypeInfo &ti)
Definition: RelAlgDag.h:441
ConstRexScalarPtrVector partition_keys_
Definition: RelAlgDag.h:679
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
Definition: RelAlgDag.h:625

+ Here is the caller graph for this function:

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

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

Referenced by RexDeepCopyVisitor::visitWindowFunctionOperator().

612  {
613  return std::unique_ptr<const RexOperator>(
615  operands,
616  partition_keys,
617  order_keys,
618  collation,
621  isRows(),
622  getType()));
623  }
const SQLTypeInfo & getType() const
Definition: RelAlgDag.h:259
const SqlWindowFunctionKind kind_
Definition: RelAlgDag.h:678
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)
Definition: RelAlgDag.h:553
const RexWindowBound & getFrameEndBound() const
Definition: RelAlgDag.h:604
const RexWindowBound & getFrameStartBound() const
Definition: RelAlgDag.h:602
bool isRows() const
Definition: RelAlgDag.h:606

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

References collation_.

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

600 { return collation_; }
const std::vector< SortField > collation_
Definition: RelAlgDag.h:681

+ Here is the caller graph for this function:

const RexWindowBound& RexWindowFunctionOperator::getFrameEndBound ( ) const
inline

Definition at line 604 of file RelAlgDag.h.

References frame_end_bound_.

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

604 { return frame_end_bound_; }
const RexWindowBound frame_end_bound_
Definition: RelAlgDag.h:683

+ Here is the caller graph for this function:

const RexWindowBound& RexWindowFunctionOperator::getFrameStartBound ( ) const
inline

Definition at line 602 of file RelAlgDag.h.

References frame_start_bound_.

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

602 { return frame_start_bound_; }
const RexWindowBound frame_start_bound_
Definition: RelAlgDag.h:682

+ Here is the caller graph for this function:

SqlWindowFunctionKind RexWindowFunctionOperator::getKind ( ) const
inline

Definition at line 571 of file RelAlgDag.h.

References kind_.

Referenced by RelAlgTranslator::translateWindowFunction().

571 { return kind_; }
const SqlWindowFunctionKind kind_
Definition: RelAlgDag.h:678

+ Here is the caller graph for this function:

const ConstRexScalarPtrVector& RexWindowFunctionOperator::getOrderKeys ( ) const
inline

Definition at line 583 of file RelAlgDag.h.

References order_keys_.

Referenced by anonymous_namespace{RelAlgDag.cpp}::PushDownGenericExpressionInWindowFunction::pushDownExpressionInWindowFunction(), RelAlgTranslator::translateWindowFunction(), RelRexDagVisitor::visit(), RexVisitor< std::unordered_set< const RexInput * > >::visitWindowFunctionOperator(), and RexDeepCopyVisitor::visitWindowFunctionOperator().

583 { return order_keys_; }
ConstRexScalarPtrVector order_keys_
Definition: RelAlgDag.h:680

+ Here is the caller graph for this function:

ConstRexScalarPtrVector RexWindowFunctionOperator::getOrderKeysAndRelease ( ) const
inline

Definition at line 579 of file RelAlgDag.h.

References order_keys_.

579  {
580  return std::move(order_keys_);
581  }
ConstRexScalarPtrVector order_keys_
Definition: RelAlgDag.h:680
const ConstRexScalarPtrVector& RexWindowFunctionOperator::getPartitionKeys ( ) const
inline
ConstRexScalarPtrVector RexWindowFunctionOperator::getPartitionKeysAndRelease ( ) const
inline

Definition at line 575 of file RelAlgDag.h.

References partition_keys_.

575  {
576  return std::move(partition_keys_);
577  }
ConstRexScalarPtrVector partition_keys_
Definition: RelAlgDag.h:679
bool RexWindowFunctionOperator::isRows ( ) const
inline

Definition at line 606 of file RelAlgDag.h.

References is_rows_.

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

606 { 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 596 of file RelAlgDag.h.

References RexOperator::operands_.

596  {
597  operands_ = std::move(new_operands);
598  }
std::vector< std::unique_ptr< const RexScalar > > operands_
Definition: RelAlgDag.h:284
void RexWindowFunctionOperator::replaceOrderKey ( size_t  offset,
std::unique_ptr< const RexScalar > &&  new_order_key 
)
inline

Definition at line 591 of file RelAlgDag.h.

References CHECK_LT, and order_keys_.

591  {
592  CHECK_LT(offset, order_keys_.size());
593  order_keys_[offset] = std::move(new_order_key);
594  }
#define CHECK_LT(x, y)
Definition: Logger.h:232
ConstRexScalarPtrVector order_keys_
Definition: RelAlgDag.h:680
void RexWindowFunctionOperator::replacePartitionKey ( size_t  offset,
std::unique_ptr< const RexScalar > &&  new_partition_key 
)
inline

Definition at line 585 of file RelAlgDag.h.

References CHECK_LT, and partition_keys_.

586  {
587  CHECK_LT(offset, partition_keys_.size());
588  partition_keys_[offset] = std::move(new_partition_key);
589  }
#define CHECK_LT(x, y)
Definition: Logger.h:232
ConstRexScalarPtrVector partition_keys_
Definition: RelAlgDag.h:679
size_t RexWindowFunctionOperator::toHash ( ) const
inlineoverridevirtual

Reimplemented from RexFunctionOperator.

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

642  {
643  if (!hash_) {
644  hash_ = typeid(RexWindowFunctionOperator).hash_code();
645  boost::hash_combine(*hash_, getType().get_type_name());
646  boost::hash_combine(*hash_, getName());
647  boost::hash_combine(*hash_, is_rows_);
648  for (auto& collation : collation_) {
649  boost::hash_combine(*hash_, collation.toHash());
650  }
651  for (auto& operand : operands_) {
652  boost::hash_combine(*hash_, operand->toHash());
653  }
654  for (auto& key : partition_keys_) {
655  boost::hash_combine(*hash_, key->toHash());
656  }
657  for (auto& key : order_keys_) {
658  boost::hash_combine(*hash_, key->toHash());
659  }
660  auto get_window_bound_hash =
662  auto h =
663  boost::hash_value(bound.bound_expr ? bound.bound_expr->toHash() : HASH_N);
664  boost::hash_combine(h, bound.unbounded);
665  boost::hash_combine(h, bound.preceding);
666  boost::hash_combine(h, bound.following);
667  boost::hash_combine(h, bound.is_current_row);
668  boost::hash_combine(h, bound.order_key);
669  return h;
670  };
671  boost::hash_combine(*hash_, get_window_bound_hash(frame_start_bound_));
672  boost::hash_combine(*hash_, get_window_bound_hash(frame_end_bound_));
673  }
674  return *hash_;
675  }
const SQLTypeInfo & getType() const
Definition: RelAlgDag.h:259
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)
Definition: RelAlgDag.h:553
const RexWindowBound frame_end_bound_
Definition: RelAlgDag.h:683
static auto const HASH_N
Definition: RelAlgDag.h:44
std::vector< std::unique_ptr< const RexScalar > > operands_
Definition: RelAlgDag.h:284
std::optional< size_t > hash_
Definition: RelAlgDag.h:62
const std::vector< SortField > collation_
Definition: RelAlgDag.h:681
const RexWindowBound frame_start_bound_
Definition: RelAlgDag.h:682
ConstRexScalarPtrVector order_keys_
Definition: RelAlgDag.h:680
ConstRexScalarPtrVector partition_keys_
Definition: RelAlgDag.h:679
const std::string & getName() const
Definition: RelAlgDag.h:452

+ Here is the call graph for this function:

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

Reimplemented from RexFunctionOperator.

Definition at line 625 of file RelAlgDag.h.

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

626  {
627  auto ret = cat(::typeName(this), "(", getName(), ", operands=");
628  for (auto& operand : operands_) {
629  ret += operand->toString(config) + " ";
630  }
631  ret += ", partition_keys=";
632  for (auto& key : partition_keys_) {
633  ret += key->toString(config) + " ";
634  }
635  ret += ", order_keys=";
636  for (auto& key : order_keys_) {
637  ret += key->toString(config) + " ";
638  }
639  return cat(ret, ")");
640  }
std::string cat(Ts &&...args)
std::vector< std::unique_ptr< const RexScalar > > operands_
Definition: RelAlgDag.h:284
ConstRexScalarPtrVector order_keys_
Definition: RelAlgDag.h:680
std::string typeName(const T *v)
Definition: toString.h:102
ConstRexScalarPtrVector partition_keys_
Definition: RelAlgDag.h:679
const std::string & getName() const
Definition: RelAlgDag.h:452

+ Here is the call graph for this function:

Member Data Documentation

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

Definition at line 681 of file RelAlgDag.h.

Referenced by getCollation(), and toHash().

const RexWindowBound RexWindowFunctionOperator::frame_end_bound_
private

Definition at line 683 of file RelAlgDag.h.

Referenced by getFrameEndBound(), and toHash().

const RexWindowBound RexWindowFunctionOperator::frame_start_bound_
private

Definition at line 682 of file RelAlgDag.h.

Referenced by getFrameStartBound(), and toHash().

const bool RexWindowFunctionOperator::is_rows_
private

Definition at line 684 of file RelAlgDag.h.

Referenced by isRows(), and toHash().

const SqlWindowFunctionKind RexWindowFunctionOperator::kind_
private

Definition at line 678 of file RelAlgDag.h.

Referenced by disambiguatedOperands(), and getKind().

ConstRexScalarPtrVector RexWindowFunctionOperator::order_keys_
mutableprivate

Definition at line 680 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: