OmniSciDB  a987f07e93
 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 1909 of file RelAlgDag.h.

Constructor & Destructor Documentation

RelSort::RelSort ( )
inline

Definition at line 1912 of file RelAlgDag.h.

Referenced by toHash().

1912 : limit_{0}, offset_{0}, empty_result_{false}, limit_delivered_{false} {}
bool limit_delivered_
Definition: RelAlgDag.h:2011
size_t limit_
Definition: RelAlgDag.h:2008
bool empty_result_
Definition: RelAlgDag.h:2010
size_t offset_
Definition: RelAlgDag.h:2009

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

References RelAlgNode::inputs_.

1919  : collation_(collation)
1920  , limit_(limit)
1921  , offset_(offset)
1922  , limit_delivered_(limit_delivered) {
1923  inputs_.push_back(input);
1924  }
bool limit_delivered_
Definition: RelAlgDag.h:2011
size_t limit_
Definition: RelAlgDag.h:2008
std::vector< SortField > collation_
Definition: RelAlgDag.h:2007
size_t offset_
Definition: RelAlgDag.h:2009
RelAlgInputs inputs_
Definition: RelAlgDag.h:952

Member Function Documentation

size_t RelSort::collationCount ( ) const
inline

Definition at line 1932 of file RelAlgDag.h.

References collation_.

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

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

+ Here is the caller graph for this function:

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

Implements RelAlgNode.

Definition at line 2002 of file RelAlgDag.h.

2002  {
2003  return std::make_shared<RelSort>(*this);
2004  }
SortField RelSort::getCollation ( const size_t  i) const
inline

Definition at line 1934 of file RelAlgDag.h.

References CHECK_LT, and collation_.

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

1934  {
1935  CHECK_LT(i, collation_.size());
1936  return collation_[i];
1937  }
std::vector< SortField > collation_
Definition: RelAlgDag.h:2007
#define CHECK_LT(x, y)
Definition: Logger.h:299

+ Here is the caller graph for this function:

size_t RelSort::getLimit ( ) const
inline

Definition at line 1949 of file RelAlgDag.h.

References limit_.

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

1949 { return limit_; }
size_t limit_
Definition: RelAlgDag.h:2008

+ Here is the caller graph for this function:

size_t RelSort::getOffset ( ) const
inline

Definition at line 1951 of file RelAlgDag.h.

References offset_.

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

1951 { return offset_; }
size_t offset_
Definition: RelAlgDag.h:2009

+ 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:2007
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 1945 of file RelAlgDag.h.

References empty_result_.

Referenced by RelAlgExecutor::executeSort().

1945 { return empty_result_; }
bool empty_result_
Definition: RelAlgDag.h:2010

+ Here is the caller graph for this function:

bool RelSort::isLimitDelivered ( ) const
inline

Definition at line 1947 of file RelAlgDag.h.

References limit_delivered_.

Referenced by RelAlgExecutor::createSortInputWorkUnit().

1947 { return limit_delivered_; }
bool limit_delivered_
Definition: RelAlgDag.h:2011

+ Here is the caller graph for this function:

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

Definition at line 1926 of file RelAlgDag.h.

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

1926  {
1927  return limit_ == that.limit_ && offset_ == that.offset_ &&
1928  empty_result_ == that.empty_result_ &&
1930  }
bool limit_delivered_
Definition: RelAlgDag.h:2011
bool hasEquivCollationOf(const RelSort &that) const
Definition: RelAlgDag.cpp:802
size_t limit_
Definition: RelAlgDag.h:2008
bool empty_result_
Definition: RelAlgDag.h:2010
size_t offset_
Definition: RelAlgDag.h:2009

+ Here is the call graph for this function:

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

Definition at line 1939 of file RelAlgDag.h.

References collation_.

1939  {
1940  collation_ = std::move(collation);
1941  }
std::vector< SortField > collation_
Definition: RelAlgDag.h:2007
void RelSort::setEmptyResult ( bool  emptyResult)
inline

Definition at line 1943 of file RelAlgDag.h.

References empty_result_.

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

Implements RelAlgNode.

Definition at line 2000 of file RelAlgDag.h.

References RelAlgNode::inputs_.

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

Implements RelAlgNode.

Definition at line 1981 of file RelAlgDag.h.

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

1981  {
1982  if (!hash_) {
1983  hash_ = typeid(RelSort).hash_code();
1984  for (auto& collation : collation_) {
1985  boost::hash_combine(*hash_, collation.toHash());
1986  }
1987  boost::hash_combine(*hash_, empty_result_);
1988  boost::hash_combine(*hash_, limit_delivered_);
1989  if (limit_delivered_) {
1990  boost::hash_combine(*hash_, limit_);
1991  }
1992  boost::hash_combine(*hash_, offset_);
1993  for (auto& node : inputs_) {
1994  boost::hash_combine(*hash_, node->toHash());
1995  }
1996  }
1997  return *hash_;
1998  }
bool limit_delivered_
Definition: RelAlgDag.h:2011
size_t limit_
Definition: RelAlgDag.h:2008
bool empty_result_
Definition: RelAlgDag.h:2010
std::vector< SortField > collation_
Definition: RelAlgDag.h:2007
std::optional< size_t > hash_
Definition: RelAlgDag.h:955
size_t offset_
Definition: RelAlgDag.h:2009
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 1953 of file RelAlgDag.h.

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

1954  {
1955  const std::string limit_info = limit_delivered_ ? std::to_string(limit_) : "N/A";
1956  auto ret = cat(::typeName(this),
1957  "(",
1958  "empty_result: ",
1960  ", collation=",
1961  ::toString(collation_),
1962  ", limit=",
1963  limit_info,
1964  ", offset",
1965  std::to_string(offset_));
1966  if (!config.skip_input_nodes) {
1967  ret += ", inputs=", ::toString(inputs_);
1968  } else {
1969  ret += ", input node id={";
1970  for (auto& input : inputs_) {
1971  auto node_id_in_plan = input->getIdInPlanTree();
1972  auto node_id_str = node_id_in_plan ? std::to_string(*node_id_in_plan)
1973  : std::to_string(input->getId());
1974  ret += node_id_str + " ";
1975  }
1976  ret += "}";
1977  }
1978  return cat(ret, ")");
1979  }
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
Definition: RelAlgDag.h:1953
std::string cat(Ts &&...args)
bool limit_delivered_
Definition: RelAlgDag.h:2011
size_t limit_
Definition: RelAlgDag.h:2008
bool empty_result_
Definition: RelAlgDag.h:2010
std::string to_string(char const *&&v)
std::vector< SortField > collation_
Definition: RelAlgDag.h:2007
unsigned getId() const
Definition: RelAlgDag.h:880
size_t offset_
Definition: RelAlgDag.h:2009
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 2015 of file RelAlgDag.h.

Member Data Documentation

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

Definition at line 2010 of file RelAlgDag.h.

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

size_t RelSort::limit_
private

Definition at line 2008 of file RelAlgDag.h.

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

bool RelSort::limit_delivered_
private

Definition at line 2011 of file RelAlgDag.h.

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

size_t RelSort::offset_
private

Definition at line 2009 of file RelAlgDag.h.

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


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