OmniSciDB  085a039ca4
 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 limit_delivered)
 
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
 
bool isLimitDelivered () const
 
size_t getLimit () const
 
size_t getOffset () const
 
std::string toString (RelRexToStringConfig config=RelRexToStringConfig::defaults()) 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
 
void setQueryPlanDag (const std::string &extracted_query_plan_dag) const
 
std::string getQueryPlanDag () const
 
size_t getQueryPlanDagHash () const
 
const std::vector
< TargetMetaInfo > & 
getOutputMetainfo () const
 
unsigned getId () const
 
void setIdInPlanTree (size_t id) const
 
std::optional< size_t > getIdInPlanTree () 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_
 
bool limit_delivered_
 

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 > id_in_plan_tree_
 
std::optional< size_t > hash_
 

Detailed Description

Definition at line 1740 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,
bool  limit_delivered 
)
inline

Definition at line 1742 of file RelAlgDagBuilder.h.

References RelAlgNode::inputs_.

Referenced by toHash().

1747  : collation_(collation)
1748  , limit_(limit)
1749  , offset_(offset)
1750  , limit_delivered_(limit_delivered) {
1751  inputs_.push_back(input);
1752  }
const size_t limit_
bool limit_delivered_
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 1760 of file RelAlgDagBuilder.h.

References collation_.

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

1760 { 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 1830 of file RelAlgDagBuilder.h.

1830  {
1831  return std::make_shared<RelSort>(*this);
1832  }
SortField RelSort::getCollation ( const size_t  i) const
inline

Definition at line 1762 of file RelAlgDagBuilder.h.

References CHECK_LT, and collation_.

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

1762  {
1763  CHECK_LT(i, collation_.size());
1764  return collation_[i];
1765  }
std::vector< SortField > collation_
#define CHECK_LT(x, y)
Definition: Logger.h:233

+ Here is the caller graph for this function:

size_t RelSort::getLimit ( ) const
inline

Definition at line 1777 of file RelAlgDagBuilder.h.

References limit_.

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

1777 { return limit_; }
const size_t limit_

+ Here is the caller graph for this function:

size_t RelSort::getOffset ( ) const
inline

Definition at line 1779 of file RelAlgDagBuilder.h.

References offset_.

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

1779 { 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 778 of file RelAlgDagBuilder.cpp.

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

Referenced by operator==().

778  {
779  if (collation_.size() != that.collation_.size()) {
780  return false;
781  }
782 
783  for (size_t i = 0, e = collation_.size(); i < e; ++i) {
784  auto this_sort_key = collation_[i];
785  auto that_sort_key = that.collation_[i];
786  if (this_sort_key.getSortDir() != that_sort_key.getSortDir()) {
787  return false;
788  }
789  if (this_sort_key.getNullsPosition() != that_sort_key.getNullsPosition()) {
790  return false;
791  }
792  auto this_equiv_keys = get_equiv_cols(this, this_sort_key.getField());
793  auto that_equiv_keys = get_equiv_cols(&that, that_sort_key.getField());
794  std::vector<std::pair<const RelAlgNode*, int>> intersect;
795  std::set_intersection(this_equiv_keys.begin(),
796  this_equiv_keys.end(),
797  that_equiv_keys.begin(),
798  that_equiv_keys.end(),
799  std::back_inserter(intersect));
800  if (intersect.empty()) {
801  return false;
802  }
803  }
804  return true;
805 }
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 1773 of file RelAlgDagBuilder.h.

References empty_result_.

Referenced by RelAlgExecutor::executeSort().

1773 { return empty_result_; }
bool empty_result_

+ Here is the caller graph for this function:

bool RelSort::isLimitDelivered ( ) const
inline

Definition at line 1775 of file RelAlgDagBuilder.h.

References limit_delivered_.

Referenced by RelAlgExecutor::createSortInputWorkUnit().

1775 { return limit_delivered_; }
bool limit_delivered_

+ Here is the caller graph for this function:

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

Definition at line 1754 of file RelAlgDagBuilder.h.

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

1754  {
1755  return limit_ == that.limit_ && offset_ == that.offset_ &&
1756  empty_result_ == that.empty_result_ &&
1758  }
const size_t limit_
bool limit_delivered_
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 1767 of file RelAlgDagBuilder.h.

References collation_.

1767  {
1768  collation_ = std::move(collation);
1769  }
std::vector< SortField > collation_
void RelSort::setEmptyResult ( bool  emptyResult)
inline

Definition at line 1771 of file RelAlgDagBuilder.h.

References empty_result_.

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

Implements RelAlgNode.

Definition at line 1828 of file RelAlgDagBuilder.h.

References RelAlgNode::inputs_.

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

Implements RelAlgNode.

Definition at line 1809 of file RelAlgDagBuilder.h.

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

1809  {
1810  if (!hash_) {
1811  hash_ = typeid(RelSort).hash_code();
1812  for (auto& collation : collation_) {
1813  boost::hash_combine(*hash_, collation.toHash());
1814  }
1815  boost::hash_combine(*hash_, empty_result_);
1816  boost::hash_combine(*hash_, limit_delivered_);
1817  if (limit_delivered_) {
1818  boost::hash_combine(*hash_, limit_);
1819  }
1820  boost::hash_combine(*hash_, offset_);
1821  for (auto& node : inputs_) {
1822  boost::hash_combine(*hash_, node->toHash());
1823  }
1824  }
1825  return *hash_;
1826  }
const size_t limit_
bool limit_delivered_
bool empty_result_
std::vector< SortField > collation_
const size_t offset_
RelSort(const std::vector< SortField > &collation, const size_t limit, const size_t offset, std::shared_ptr< const RelAlgNode > input, bool limit_delivered)
std::optional< size_t > hash_
RelAlgInputs inputs_

+ Here is the call graph for this function:

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

Implements RelAlgNode.

Definition at line 1781 of file RelAlgDagBuilder.h.

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

1782  {
1783  const std::string limit_info = limit_delivered_ ? std::to_string(limit_) : "N/A";
1784  auto ret = cat(::typeName(this),
1785  "(",
1786  "empty_result: ",
1788  ", collation=",
1789  ::toString(collation_),
1790  ", limit=",
1791  limit_info,
1792  ", offset",
1793  std::to_string(offset_));
1794  if (!config.skip_input_nodes) {
1795  ret += ", inputs=", ::toString(inputs_);
1796  } else {
1797  ret += ", input node id={";
1798  for (auto& input : inputs_) {
1799  auto node_id_in_plan = input->getIdInPlanTree();
1800  auto node_id_str = node_id_in_plan ? std::to_string(*node_id_in_plan)
1801  : std::to_string(input->getId());
1802  ret += node_id_str + " ";
1803  }
1804  ret += "}";
1805  }
1806  return cat(ret, ")");
1807  }
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
const size_t limit_
std::string cat(Ts &&...args)
bool limit_delivered_
bool empty_result_
std::string to_string(char const *&&v)
std::vector< SortField > collation_
unsigned getId() const
const size_t offset_
std::string typeName(const T *v)
Definition: toString.h:102
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 1838 of file RelAlgDagBuilder.h.

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

const size_t RelSort::limit_
private

Definition at line 1836 of file RelAlgDagBuilder.h.

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

bool RelSort::limit_delivered_
private

Definition at line 1839 of file RelAlgDagBuilder.h.

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

const size_t RelSort::offset_
private

Definition at line 1837 of file RelAlgDagBuilder.h.

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


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