OmniSciDB  c1a53651b2
 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 ()
 
 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 (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_
 
size_t limit_
 
size_t offset_
 
bool empty_result_
 
bool limit_delivered_
 

Friends

struct RelAlgDagSerializer
 

Additional Inherited Members

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

Detailed Description

Definition at line 1929 of file RelAlgDag.h.

Constructor & Destructor Documentation

RelSort::RelSort ( )
inline

Definition at line 1932 of file RelAlgDag.h.

Referenced by toHash().

1932 : limit_{0}, offset_{0}, empty_result_{false}, limit_delivered_{false} {}
bool limit_delivered_
Definition: RelAlgDag.h:2031
size_t limit_
Definition: RelAlgDag.h:2028
bool empty_result_
Definition: RelAlgDag.h:2030
size_t offset_
Definition: RelAlgDag.h:2029

+ Here is the caller graph for this function:

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

References RelAlgNode::inputs_.

1939  : collation_(collation)
1940  , limit_(limit)
1941  , offset_(offset)
1942  , limit_delivered_(limit_delivered) {
1943  inputs_.push_back(input);
1944  }
bool limit_delivered_
Definition: RelAlgDag.h:2031
size_t limit_
Definition: RelAlgDag.h:2028
std::vector< SortField > collation_
Definition: RelAlgDag.h:2027
size_t offset_
Definition: RelAlgDag.h:2029
RelAlgInputs inputs_
Definition: RelAlgDag.h:952

Member Function Documentation

size_t RelSort::collationCount ( ) const
inline

Definition at line 1952 of file RelAlgDag.h.

References collation_.

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

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

+ Here is the caller graph for this function:

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

Implements RelAlgNode.

Definition at line 2022 of file RelAlgDag.h.

2022  {
2023  return std::make_shared<RelSort>(*this);
2024  }
SortField RelSort::getCollation ( const size_t  i) const
inline

Definition at line 1954 of file RelAlgDag.h.

References CHECK_LT, and collation_.

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

1954  {
1955  CHECK_LT(i, collation_.size());
1956  return collation_[i];
1957  }
std::vector< SortField > collation_
Definition: RelAlgDag.h:2027
#define CHECK_LT(x, y)
Definition: Logger.h:303

+ Here is the caller graph for this function:

size_t RelSort::getLimit ( ) const
inline

Definition at line 1969 of file RelAlgDag.h.

References limit_.

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

1969 { return limit_; }
size_t limit_
Definition: RelAlgDag.h:2028

+ Here is the caller graph for this function:

size_t RelSort::getOffset ( ) const
inline

Definition at line 1971 of file RelAlgDag.h.

References offset_.

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

1971 { return offset_; }
size_t offset_
Definition: RelAlgDag.h:2029

+ Here is the caller graph for this function:

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

Definition at line 802 of file RelAlgDag.cpp.

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

Referenced by operator==().

802  {
803  if (collation_.size() != that.collation_.size()) {
804  return false;
805  }
806 
807  for (size_t i = 0, e = collation_.size(); i < e; ++i) {
808  auto this_sort_key = collation_[i];
809  auto that_sort_key = that.collation_[i];
810  if (this_sort_key.getSortDir() != that_sort_key.getSortDir()) {
811  return false;
812  }
813  if (this_sort_key.getNullsPosition() != that_sort_key.getNullsPosition()) {
814  return false;
815  }
816  auto this_equiv_keys = get_equiv_cols(this, this_sort_key.getField());
817  auto that_equiv_keys = get_equiv_cols(&that, that_sort_key.getField());
818  std::vector<std::pair<const RelAlgNode*, int>> intersect;
819  std::set_intersection(this_equiv_keys.begin(),
820  this_equiv_keys.end(),
821  that_equiv_keys.begin(),
822  that_equiv_keys.end(),
823  std::back_inserter(intersect));
824  if (intersect.empty()) {
825  return false;
826  }
827  }
828  return true;
829 }
std::vector< SortField > collation_
Definition: RelAlgDag.h:2027
std::set< std::pair< const RelAlgNode *, int > > get_equiv_cols(const RelAlgNode *node, const size_t which_col)
Definition: RelAlgDag.cpp:763

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool RelSort::isEmptyResult ( ) const
inline

Definition at line 1965 of file RelAlgDag.h.

References empty_result_.

Referenced by RelAlgExecutor::executeSort().

1965 { return empty_result_; }
bool empty_result_
Definition: RelAlgDag.h:2030

+ Here is the caller graph for this function:

bool RelSort::isLimitDelivered ( ) const
inline

Definition at line 1967 of file RelAlgDag.h.

References limit_delivered_.

Referenced by RelAlgExecutor::createSortInputWorkUnit().

1967 { return limit_delivered_; }
bool limit_delivered_
Definition: RelAlgDag.h:2031

+ Here is the caller graph for this function:

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

Definition at line 1946 of file RelAlgDag.h.

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

1946  {
1947  return limit_ == that.limit_ && offset_ == that.offset_ &&
1948  empty_result_ == that.empty_result_ &&
1950  }
bool limit_delivered_
Definition: RelAlgDag.h:2031
bool hasEquivCollationOf(const RelSort &that) const
Definition: RelAlgDag.cpp:802
size_t limit_
Definition: RelAlgDag.h:2028
bool empty_result_
Definition: RelAlgDag.h:2030
size_t offset_
Definition: RelAlgDag.h:2029

+ Here is the call graph for this function:

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

Definition at line 1959 of file RelAlgDag.h.

References collation_.

1959  {
1960  collation_ = std::move(collation);
1961  }
std::vector< SortField > collation_
Definition: RelAlgDag.h:2027
void RelSort::setEmptyResult ( bool  emptyResult)
inline

Definition at line 1963 of file RelAlgDag.h.

References empty_result_.

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

Implements RelAlgNode.

Definition at line 2020 of file RelAlgDag.h.

References RelAlgNode::inputs_.

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

Implements RelAlgNode.

Definition at line 2001 of file RelAlgDag.h.

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

2001  {
2002  if (!hash_) {
2003  hash_ = typeid(RelSort).hash_code();
2004  for (auto& collation : collation_) {
2005  boost::hash_combine(*hash_, collation.toHash());
2006  }
2007  boost::hash_combine(*hash_, empty_result_);
2008  boost::hash_combine(*hash_, limit_delivered_);
2009  if (limit_delivered_) {
2010  boost::hash_combine(*hash_, limit_);
2011  }
2012  boost::hash_combine(*hash_, offset_);
2013  for (auto& node : inputs_) {
2014  boost::hash_combine(*hash_, node->toHash());
2015  }
2016  }
2017  return *hash_;
2018  }
bool limit_delivered_
Definition: RelAlgDag.h:2031
size_t limit_
Definition: RelAlgDag.h:2028
bool empty_result_
Definition: RelAlgDag.h:2030
std::vector< SortField > collation_
Definition: RelAlgDag.h:2027
std::optional< size_t > hash_
Definition: RelAlgDag.h:955
size_t offset_
Definition: RelAlgDag.h:2029
RelAlgInputs inputs_
Definition: RelAlgDag.h:952

+ Here is the call graph for this function:

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

Implements RelAlgNode.

Definition at line 1973 of file RelAlgDag.h.

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

1974  {
1975  const std::string limit_info = limit_delivered_ ? std::to_string(limit_) : "N/A";
1976  auto ret = cat(::typeName(this),
1977  "(",
1978  "empty_result: ",
1980  ", collation=",
1981  ::toString(collation_),
1982  ", limit=",
1983  limit_info,
1984  ", offset",
1985  std::to_string(offset_));
1986  if (!config.skip_input_nodes) {
1987  ret += ", inputs=", ::toString(inputs_);
1988  } else {
1989  ret += ", input node id={";
1990  for (auto& input : inputs_) {
1991  auto node_id_in_plan = input->getIdInPlanTree();
1992  auto node_id_str = node_id_in_plan ? std::to_string(*node_id_in_plan)
1993  : std::to_string(input->getId());
1994  ret += node_id_str + " ";
1995  }
1996  ret += "}";
1997  }
1998  return cat(ret, ")");
1999  }
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
Definition: RelAlgDag.h:1973
std::string cat(Ts &&...args)
bool limit_delivered_
Definition: RelAlgDag.h:2031
size_t limit_
Definition: RelAlgDag.h:2028
bool empty_result_
Definition: RelAlgDag.h:2030
std::string to_string(char const *&&v)
std::vector< SortField > collation_
Definition: RelAlgDag.h:2027
unsigned getId() const
Definition: RelAlgDag.h:880
size_t offset_
Definition: RelAlgDag.h:2029
std::string typeName(const T *v)
Definition: toString.h:103
RelAlgInputs inputs_
Definition: RelAlgDag.h:952

+ Here is the call graph for this function:

Friends And Related Function Documentation

friend struct RelAlgDagSerializer
friend

Definition at line 2035 of file RelAlgDag.h.

Member Data Documentation

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

Definition at line 2030 of file RelAlgDag.h.

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

size_t RelSort::limit_
private

Definition at line 2028 of file RelAlgDag.h.

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

bool RelSort::limit_delivered_
private

Definition at line 2031 of file RelAlgDag.h.

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

size_t RelSort::offset_
private

Definition at line 2029 of file RelAlgDag.h.

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


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