OmniSciDB  04ee39c94c
RelSort Class Reference

#include <RelAlgAbstractInterpreter.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)
 
size_t getLimit () const
 
size_t getOffset () const
 
std::string toString () const override
 
size_t size () const override
 
std::shared_ptr< RelAlgNodedeepCopy () const override
 
- Public Member Functions inherited from RelAlgNode
 RelAlgNode ()
 
virtual ~RelAlgNode ()
 
void setContextData (const void *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 void * getContextData () 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)
 
bool isNop () const
 
void markAsNop ()
 

Private Member Functions

bool hasEquivCollationOf (const RelSort &that) const
 

Private Attributes

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

Additional Inherited Members

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

Detailed Description

Definition at line 1138 of file RelAlgAbstractInterpreter.h.

Constructor & Destructor Documentation

◆ RelSort()

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 1140 of file RelAlgAbstractInterpreter.h.

1144  : collation_(collation), limit_(limit), offset_(offset) {
1145  inputs_.push_back(input);
1146  }
std::vector< std::shared_ptr< const RelAlgNode > > inputs_
std::vector< SortField > collation_
const size_t offset_

Member Function Documentation

◆ collationCount()

size_t RelSort::collationCount ( ) const
inline

Definition at line 1152 of file RelAlgAbstractInterpreter.h.

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

1152 { return collation_.size(); }
std::vector< SortField > collation_
+ Here is the caller graph for this function:

◆ deepCopy()

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

Implements RelAlgNode.

Definition at line 344 of file RelAlgAbstractInterpreter.cpp.

References RelAlgNode::inputs_.

344  {
345  return std::make_shared<RelSort>(collation_, limit_, offset_, inputs_[0]);
346 }
std::vector< std::shared_ptr< const RelAlgNode > > inputs_
std::vector< SortField > collation_
const size_t offset_

◆ getCollation()

SortField RelSort::getCollation ( const size_t  i) const
inline

Definition at line 1154 of file RelAlgAbstractInterpreter.h.

References CHECK_LT.

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

1154  {
1155  CHECK_LT(i, collation_.size());
1156  return collation_[i];
1157  }
std::vector< SortField > collation_
#define CHECK_LT(x, y)
Definition: Logger.h:197
+ Here is the caller graph for this function:

◆ getLimit()

size_t RelSort::getLimit ( ) const
inline

Definition at line 1163 of file RelAlgAbstractInterpreter.h.

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

1163 { return limit_; }
+ Here is the caller graph for this function:

◆ getOffset()

size_t RelSort::getOffset ( ) const
inline

Definition at line 1165 of file RelAlgAbstractInterpreter.h.

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

1165 { return offset_; }
const size_t offset_
+ Here is the caller graph for this function:

◆ hasEquivCollationOf()

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

Definition at line 399 of file RelAlgAbstractInterpreter.cpp.

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

399  {
400  if (collation_.size() != that.collation_.size()) {
401  return false;
402  }
403 
404  for (size_t i = 0, e = collation_.size(); i < e; ++i) {
405  auto this_sort_key = collation_[i];
406  auto that_sort_key = that.collation_[i];
407  if (this_sort_key.getSortDir() != that_sort_key.getSortDir()) {
408  return false;
409  }
410  if (this_sort_key.getNullsPosition() != that_sort_key.getNullsPosition()) {
411  return false;
412  }
413  auto this_equiv_keys = get_equiv_cols(this, this_sort_key.getField());
414  auto that_equiv_keys = get_equiv_cols(&that, that_sort_key.getField());
415  std::vector<std::pair<const RelAlgNode*, int>> intersect;
416  std::set_intersection(this_equiv_keys.begin(),
417  this_equiv_keys.end(),
418  that_equiv_keys.begin(),
419  that_equiv_keys.end(),
420  std::back_inserter(intersect));
421  if (intersect.empty()) {
422  return false;
423  }
424  }
425  return true;
426 }
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:

◆ operator==()

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

Definition at line 1148 of file RelAlgAbstractInterpreter.h.

References limit_, and offset_.

1148  {
1149  return limit_ == that.limit_ && offset_ == that.offset_ && hasEquivCollationOf(that);
1150  }
bool hasEquivCollationOf(const RelSort &that) const
const size_t offset_

◆ setCollation()

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

Definition at line 1159 of file RelAlgAbstractInterpreter.h.

1159  {
1160  collation_ = std::move(collation);
1161  }
std::vector< SortField > collation_

◆ size()

size_t RelSort::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1180 of file RelAlgAbstractInterpreter.h.

1180 { return inputs_[0]->size(); }
std::vector< std::shared_ptr< const RelAlgNode > > inputs_

◆ toString()

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

Implements RelAlgNode.

Definition at line 1167 of file RelAlgAbstractInterpreter.h.

References run-benchmark-import::result, and to_string().

1167  {
1168  std::string result =
1169  "(RelSort<" + std::to_string(reinterpret_cast<uint64_t>(this)) + ">(";
1170  result += "limit: " + std::to_string(limit_) + " ";
1171  result += "offset: " + std::to_string(offset_) + " ";
1172  result += "collation: [ ";
1173  for (const auto& sort_field : collation_) {
1174  result += sort_field.toString() + " ";
1175  }
1176  result += "]";
1177  return result + ")";
1178  }
std::string to_string(char const *&&v)
std::vector< SortField > collation_
const size_t offset_
+ Here is the call graph for this function:

Member Data Documentation

◆ collation_

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

Definition at line 1185 of file RelAlgAbstractInterpreter.h.

Referenced by hasEquivCollationOf().

◆ limit_

const size_t RelSort::limit_
private

Definition at line 1186 of file RelAlgAbstractInterpreter.h.

Referenced by operator==().

◆ offset_

const size_t RelSort::offset_
private

Definition at line 1187 of file RelAlgAbstractInterpreter.h.

Referenced by operator==().


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