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

#include <RelAlgDag.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 1796 of file RelAlgDag.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 1798 of file RelAlgDag.h.

References RelAlgNode::inputs_.

Referenced by toHash().

1803  : collation_(collation)
1804  , limit_(limit)
1805  , offset_(offset)
1806  , limit_delivered_(limit_delivered) {
1807  inputs_.push_back(input);
1808  }
const size_t limit_
Definition: RelAlgDag.h:1892
bool limit_delivered_
Definition: RelAlgDag.h:1895
std::vector< SortField > collation_
Definition: RelAlgDag.h:1891
const size_t offset_
Definition: RelAlgDag.h:1893
RelAlgInputs inputs_
Definition: RelAlgDag.h:886

+ Here is the caller graph for this function:

Member Function Documentation

size_t RelSort::collationCount ( ) const
inline

Definition at line 1816 of file RelAlgDag.h.

References collation_.

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

1816 { return collation_.size(); }
std::vector< SortField > collation_
Definition: RelAlgDag.h:1891

+ Here is the caller graph for this function:

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

Implements RelAlgNode.

Definition at line 1886 of file RelAlgDag.h.

1886  {
1887  return std::make_shared<RelSort>(*this);
1888  }
SortField RelSort::getCollation ( const size_t  i) const
inline

Definition at line 1818 of file RelAlgDag.h.

References CHECK_LT, and collation_.

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

1818  {
1819  CHECK_LT(i, collation_.size());
1820  return collation_[i];
1821  }
std::vector< SortField > collation_
Definition: RelAlgDag.h:1891
#define CHECK_LT(x, y)
Definition: Logger.h:232

+ Here is the caller graph for this function:

size_t RelSort::getLimit ( ) const
inline

Definition at line 1833 of file RelAlgDag.h.

References limit_.

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

1833 { return limit_; }
const size_t limit_
Definition: RelAlgDag.h:1892

+ Here is the caller graph for this function:

size_t RelSort::getOffset ( ) const
inline

Definition at line 1835 of file RelAlgDag.h.

References offset_.

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

1835 { return offset_; }
const size_t offset_
Definition: RelAlgDag.h:1893

+ Here is the caller graph for this function:

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

Definition at line 779 of file RelAlgDag.cpp.

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

Referenced by operator==().

779  {
780  if (collation_.size() != that.collation_.size()) {
781  return false;
782  }
783 
784  for (size_t i = 0, e = collation_.size(); i < e; ++i) {
785  auto this_sort_key = collation_[i];
786  auto that_sort_key = that.collation_[i];
787  if (this_sort_key.getSortDir() != that_sort_key.getSortDir()) {
788  return false;
789  }
790  if (this_sort_key.getNullsPosition() != that_sort_key.getNullsPosition()) {
791  return false;
792  }
793  auto this_equiv_keys = get_equiv_cols(this, this_sort_key.getField());
794  auto that_equiv_keys = get_equiv_cols(&that, that_sort_key.getField());
795  std::vector<std::pair<const RelAlgNode*, int>> intersect;
796  std::set_intersection(this_equiv_keys.begin(),
797  this_equiv_keys.end(),
798  that_equiv_keys.begin(),
799  that_equiv_keys.end(),
800  std::back_inserter(intersect));
801  if (intersect.empty()) {
802  return false;
803  }
804  }
805  return true;
806 }
std::vector< SortField > collation_
Definition: RelAlgDag.h:1891
std::set< std::pair< const RelAlgNode *, int > > get_equiv_cols(const RelAlgNode *node, const size_t which_col)
Definition: RelAlgDag.cpp:740

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool RelSort::isEmptyResult ( ) const
inline

Definition at line 1829 of file RelAlgDag.h.

References empty_result_.

Referenced by RelAlgExecutor::executeSort().

1829 { return empty_result_; }
bool empty_result_
Definition: RelAlgDag.h:1894

+ Here is the caller graph for this function:

bool RelSort::isLimitDelivered ( ) const
inline

Definition at line 1831 of file RelAlgDag.h.

References limit_delivered_.

Referenced by RelAlgExecutor::createSortInputWorkUnit().

1831 { return limit_delivered_; }
bool limit_delivered_
Definition: RelAlgDag.h:1895

+ Here is the caller graph for this function:

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

Definition at line 1810 of file RelAlgDag.h.

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

1810  {
1811  return limit_ == that.limit_ && offset_ == that.offset_ &&
1812  empty_result_ == that.empty_result_ &&
1814  }
const size_t limit_
Definition: RelAlgDag.h:1892
bool limit_delivered_
Definition: RelAlgDag.h:1895
bool hasEquivCollationOf(const RelSort &that) const
Definition: RelAlgDag.cpp:779
bool empty_result_
Definition: RelAlgDag.h:1894
const size_t offset_
Definition: RelAlgDag.h:1893

+ Here is the call graph for this function:

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

Definition at line 1823 of file RelAlgDag.h.

References collation_.

1823  {
1824  collation_ = std::move(collation);
1825  }
std::vector< SortField > collation_
Definition: RelAlgDag.h:1891
void RelSort::setEmptyResult ( bool  emptyResult)
inline

Definition at line 1827 of file RelAlgDag.h.

References empty_result_.

1827 { empty_result_ = emptyResult; }
bool empty_result_
Definition: RelAlgDag.h:1894
size_t RelSort::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1884 of file RelAlgDag.h.

References RelAlgNode::inputs_.

1884 { return inputs_[0]->size(); }
RelAlgInputs inputs_
Definition: RelAlgDag.h:886
size_t RelSort::toHash ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1865 of file RelAlgDag.h.

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

1865  {
1866  if (!hash_) {
1867  hash_ = typeid(RelSort).hash_code();
1868  for (auto& collation : collation_) {
1869  boost::hash_combine(*hash_, collation.toHash());
1870  }
1871  boost::hash_combine(*hash_, empty_result_);
1872  boost::hash_combine(*hash_, limit_delivered_);
1873  if (limit_delivered_) {
1874  boost::hash_combine(*hash_, limit_);
1875  }
1876  boost::hash_combine(*hash_, offset_);
1877  for (auto& node : inputs_) {
1878  boost::hash_combine(*hash_, node->toHash());
1879  }
1880  }
1881  return *hash_;
1882  }
const size_t limit_
Definition: RelAlgDag.h:1892
bool limit_delivered_
Definition: RelAlgDag.h:1895
bool empty_result_
Definition: RelAlgDag.h:1894
std::vector< SortField > collation_
Definition: RelAlgDag.h:1891
const size_t offset_
Definition: RelAlgDag.h:1893
RelSort(const std::vector< SortField > &collation, const size_t limit, const size_t offset, std::shared_ptr< const RelAlgNode > input, bool limit_delivered)
Definition: RelAlgDag.h:1798
std::optional< size_t > hash_
Definition: RelAlgDag.h:889
RelAlgInputs inputs_
Definition: RelAlgDag.h:886

+ Here is the call graph for this function:

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

Implements RelAlgNode.

Definition at line 1837 of file RelAlgDag.h.

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

1838  {
1839  const std::string limit_info = limit_delivered_ ? std::to_string(limit_) : "N/A";
1840  auto ret = cat(::typeName(this),
1841  "(",
1842  "empty_result: ",
1844  ", collation=",
1845  ::toString(collation_),
1846  ", limit=",
1847  limit_info,
1848  ", offset",
1849  std::to_string(offset_));
1850  if (!config.skip_input_nodes) {
1851  ret += ", inputs=", ::toString(inputs_);
1852  } else {
1853  ret += ", input node id={";
1854  for (auto& input : inputs_) {
1855  auto node_id_in_plan = input->getIdInPlanTree();
1856  auto node_id_str = node_id_in_plan ? std::to_string(*node_id_in_plan)
1857  : std::to_string(input->getId());
1858  ret += node_id_str + " ";
1859  }
1860  ret += "}";
1861  }
1862  return cat(ret, ")");
1863  }
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
Definition: RelAlgDag.h:1837
const size_t limit_
Definition: RelAlgDag.h:1892
std::string cat(Ts &&...args)
bool limit_delivered_
Definition: RelAlgDag.h:1895
bool empty_result_
Definition: RelAlgDag.h:1894
std::string to_string(char const *&&v)
std::vector< SortField > collation_
Definition: RelAlgDag.h:1891
unsigned getId() const
Definition: RelAlgDag.h:814
const size_t offset_
Definition: RelAlgDag.h:1893
std::string typeName(const T *v)
Definition: toString.h:103
RelAlgInputs inputs_
Definition: RelAlgDag.h:886

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

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

const size_t RelSort::limit_
private

Definition at line 1892 of file RelAlgDag.h.

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

bool RelSort::limit_delivered_
private

Definition at line 1895 of file RelAlgDag.h.

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

const size_t RelSort::offset_
private

Definition at line 1893 of file RelAlgDag.h.

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


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