OmniSciDB  d2f719934e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RelSort Class Reference

#include <RelAlgDagBuilder.h>

+ Inheritance diagram for RelSort:
+ Collaboration diagram for RelSort:

Public Member Functions

 RelSort (const std::vector< SortField > &collation, const size_t limit, const size_t offset, std::shared_ptr< const RelAlgNode > input)
 
bool operator== (const RelSort &that) const
 
size_t collationCount () const
 
SortField getCollation (const size_t i) const
 
void setCollation (std::vector< SortField > &&collation)
 
void setEmptyResult (bool emptyResult)
 
bool isEmptyResult () const
 
size_t getLimit () const
 
size_t getOffset () const
 
std::string toString () const override
 
size_t toHash () const override
 
size_t size () const override
 
std::shared_ptr< RelAlgNodedeepCopy () const override
 
- Public Member Functions inherited from RelAlgNode
 RelAlgNode (RelAlgInputs inputs={})
 
virtual ~RelAlgNode ()
 
void resetQueryExecutionState ()
 
void setContextData (const RaExecutionDesc *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 RaExecutionDescgetContextData () 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
 
virtual void replaceInput (std::shared_ptr< const RelAlgNode > old_input, std::shared_ptr< const RelAlgNode > input)
 
void setRelNodeDagId (const size_t id) const
 
size_t getRelNodeDagId () const
 
bool isNop () const
 
void markAsNop ()
 
void clearContextData () const
 

Private Member Functions

bool hasEquivCollationOf (const RelSort &that) const
 

Private Attributes

std::vector< SortFieldcollation_
 
const size_t limit_
 
const size_t offset_
 
bool empty_result_
 

Additional Inherited Members

- Static Public Member Functions inherited from RelAlgNode
static void resetRelAlgFirstId () noexcept
 
- Protected Attributes inherited from RelAlgNode
RelAlgInputs inputs_
 
const unsigned id_
 
std::optional< size_t > hash_
 

Detailed Description

Definition at line 1641 of file RelAlgDagBuilder.h.

Constructor & Destructor Documentation

RelSort::RelSort ( const std::vector< SortField > &  collation,
const size_t  limit,
const size_t  offset,
std::shared_ptr< const RelAlgNode input 
)
inline

Definition at line 1643 of file RelAlgDagBuilder.h.

References RelAlgNode::inputs_.

Referenced by toHash().

1647  : collation_(collation), limit_(limit), offset_(offset) {
1648  inputs_.push_back(input);
1649  }
const size_t limit_
std::vector< SortField > collation_
const size_t offset_
RelAlgInputs inputs_

+ Here is the caller graph for this function:

Member Function Documentation

size_t RelSort::collationCount ( ) const
inline

Definition at line 1656 of file RelAlgDagBuilder.h.

References collation_.

Referenced by RelAlgExecutor::createSortInputWorkUnit(), RelAlgExecutor::executeSort(), and anonymous_namespace{RelAlgExecutor.cpp}::get_order_entries().

1656 { return collation_.size(); }
std::vector< SortField > collation_

+ Here is the caller graph for this function:

std::shared_ptr<RelAlgNode> RelSort::deepCopy ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1709 of file RelAlgDagBuilder.h.

1709  {
1710  return std::make_shared<RelSort>(*this);
1711  }
SortField RelSort::getCollation ( const size_t  i) const
inline

Definition at line 1658 of file RelAlgDagBuilder.h.

References CHECK_LT, collation_, and i.

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

1658  {
1659  CHECK_LT(i, collation_.size());
1660  return collation_[i];
1661  }
std::vector< SortField > collation_
#define CHECK_LT(x, y)
Definition: Logger.h:221

+ Here is the caller graph for this function:

size_t RelSort::getLimit ( ) const
inline

Definition at line 1671 of file RelAlgDagBuilder.h.

References limit_.

Referenced by RelAlgExecutor::createSortInputWorkUnit(), and RelAlgExecutor::executeSort().

1671 { return limit_; }
const size_t limit_

+ Here is the caller graph for this function:

size_t RelSort::getOffset ( ) const
inline

Definition at line 1673 of file RelAlgDagBuilder.h.

References offset_.

Referenced by RelAlgExecutor::createSortInputWorkUnit(), and RelAlgExecutor::executeSort().

1673 { return offset_; }
const size_t offset_

+ Here is the caller graph for this function:

bool RelSort::hasEquivCollationOf ( const RelSort that) const
private

Definition at line 559 of file RelAlgDagBuilder.cpp.

References collation_, anonymous_namespace{RelAlgDagBuilder.cpp}::get_equiv_cols(), and i.

Referenced by operator==().

559  {
560  if (collation_.size() != that.collation_.size()) {
561  return false;
562  }
563 
564  for (size_t i = 0, e = collation_.size(); i < e; ++i) {
565  auto this_sort_key = collation_[i];
566  auto that_sort_key = that.collation_[i];
567  if (this_sort_key.getSortDir() != that_sort_key.getSortDir()) {
568  return false;
569  }
570  if (this_sort_key.getNullsPosition() != that_sort_key.getNullsPosition()) {
571  return false;
572  }
573  auto this_equiv_keys = get_equiv_cols(this, this_sort_key.getField());
574  auto that_equiv_keys = get_equiv_cols(&that, that_sort_key.getField());
575  std::vector<std::pair<const RelAlgNode*, int>> intersect;
576  std::set_intersection(this_equiv_keys.begin(),
577  this_equiv_keys.end(),
578  that_equiv_keys.begin(),
579  that_equiv_keys.end(),
580  std::back_inserter(intersect));
581  if (intersect.empty()) {
582  return false;
583  }
584  }
585  return true;
586 }
std::vector< SortField > collation_
std::set< std::pair< const RelAlgNode *, int > > get_equiv_cols(const RelAlgNode *node, const size_t which_col)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool RelSort::isEmptyResult ( ) const
inline

Definition at line 1669 of file RelAlgDagBuilder.h.

References empty_result_.

Referenced by RelAlgExecutor::executeSort().

1669 { return empty_result_; }
bool empty_result_

+ Here is the caller graph for this function:

bool RelSort::operator== ( const RelSort that) const
inline

Definition at line 1651 of file RelAlgDagBuilder.h.

References empty_result_, hasEquivCollationOf(), limit_, and offset_.

1651  {
1652  return limit_ == that.limit_ && offset_ == that.offset_ &&
1654  }
const size_t limit_
bool hasEquivCollationOf(const RelSort &that) const
bool empty_result_
const size_t offset_

+ Here is the call graph for this function:

void RelSort::setCollation ( std::vector< SortField > &&  collation)
inline

Definition at line 1663 of file RelAlgDagBuilder.h.

References collation_.

1663  {
1664  collation_ = std::move(collation);
1665  }
std::vector< SortField > collation_
void RelSort::setEmptyResult ( bool  emptyResult)
inline

Definition at line 1667 of file RelAlgDagBuilder.h.

References empty_result_.

1667 { empty_result_ = emptyResult; }
bool empty_result_
size_t RelSort::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1707 of file RelAlgDagBuilder.h.

References RelAlgNode::inputs_.

1707 { return inputs_[0]->size(); }
RelAlgInputs inputs_
size_t RelSort::toHash ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1691 of file RelAlgDagBuilder.h.

References collation_, empty_result_, RelAlgNode::hash_, RelAlgNode::inputs_, limit_, offset_, and RelSort().

1691  {
1692  if (!hash_) {
1693  hash_ = typeid(RelSort).hash_code();
1694  for (auto& collation : collation_) {
1695  boost::hash_combine(*hash_, collation.toHash());
1696  }
1697  boost::hash_combine(*hash_, empty_result_);
1698  boost::hash_combine(*hash_, limit_);
1699  boost::hash_combine(*hash_, offset_);
1700  for (auto& node : inputs_) {
1701  boost::hash_combine(*hash_, node->toHash());
1702  }
1703  }
1704  return *hash_;
1705  }
const size_t limit_
bool empty_result_
std::vector< SortField > collation_
const size_t offset_
std::optional< size_t > hash_
RelSort(const std::vector< SortField > &collation, const size_t limit, const size_t offset, std::shared_ptr< const RelAlgNode > input)
RelAlgInputs inputs_

+ Here is the call graph for this function:

std::string RelSort::toString ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1675 of file RelAlgDagBuilder.h.

References cat(), collation_, empty_result_, RelAlgNode::inputs_, limit_, offset_, to_string(), and typeName().

1675  {
1676  return cat(::typeName(this),
1677  "(",
1678  "empty_result: ",
1680  ", collation=",
1681  ::toString(collation_),
1682  ", limit=",
1684  ", offset",
1686  ", inputs=",
1687  ::toString(inputs_),
1688  ")");
1689  }
const size_t limit_
std::string cat(Ts &&...args)
bool empty_result_
std::string to_string(char const *&&v)
std::vector< SortField > collation_
const size_t offset_
std::string toString() const override
std::string typeName(const T *v)
Definition: toString.h:93
RelAlgInputs inputs_

+ Here is the call graph for this function:

Member Data Documentation

std::vector<SortField> RelSort::collation_
private
bool RelSort::empty_result_
private

Definition at line 1717 of file RelAlgDagBuilder.h.

Referenced by isEmptyResult(), operator==(), setEmptyResult(), toHash(), and toString().

const size_t RelSort::limit_
private

Definition at line 1715 of file RelAlgDagBuilder.h.

Referenced by getLimit(), operator==(), toHash(), and toString().

const size_t RelSort::offset_
private

Definition at line 1716 of file RelAlgDagBuilder.h.

Referenced by getOffset(), operator==(), toHash(), and toString().


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