OmniSciDB  29e35f4d58
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 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
 
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 resetQueryExecutionState ()
 
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_
 
bool empty_result_
 

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

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

Member Function Documentation

◆ collationCount()

size_t RelSort::collationCount ( ) const
inline

Definition at line 1155 of file RelAlgDagBuilder.h.

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

1155 { 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 357 of file RelAlgDagBuilder.cpp.

References RelAlgNode::inputs_.

357  {
358  auto ret = std::make_shared<RelSort>(collation_, limit_, offset_, inputs_[0]);
359  ret->setEmptyResult(isEmptyResult());
360  return ret;
361 }
std::vector< std::shared_ptr< const RelAlgNode > > inputs_
const size_t limit_
std::vector< SortField > collation_
const size_t offset_
bool isEmptyResult() const

◆ getCollation()

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

Definition at line 1157 of file RelAlgDagBuilder.h.

References CHECK_LT.

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

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

◆ getLimit()

size_t RelSort::getLimit ( ) const
inline

Definition at line 1170 of file RelAlgDagBuilder.h.

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

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

◆ getOffset()

size_t RelSort::getOffset ( ) const
inline

Definition at line 1172 of file RelAlgDagBuilder.h.

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

1172 { 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 459 of file RelAlgDagBuilder.cpp.

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

459  {
460  if (collation_.size() != that.collation_.size()) {
461  return false;
462  }
463 
464  for (size_t i = 0, e = collation_.size(); i < e; ++i) {
465  auto this_sort_key = collation_[i];
466  auto that_sort_key = that.collation_[i];
467  if (this_sort_key.getSortDir() != that_sort_key.getSortDir()) {
468  return false;
469  }
470  if (this_sort_key.getNullsPosition() != that_sort_key.getNullsPosition()) {
471  return false;
472  }
473  auto this_equiv_keys = get_equiv_cols(this, this_sort_key.getField());
474  auto that_equiv_keys = get_equiv_cols(&that, that_sort_key.getField());
475  std::vector<std::pair<const RelAlgNode*, int>> intersect;
476  std::set_intersection(this_equiv_keys.begin(),
477  this_equiv_keys.end(),
478  that_equiv_keys.begin(),
479  that_equiv_keys.end(),
480  std::back_inserter(intersect));
481  if (intersect.empty()) {
482  return false;
483  }
484  }
485  return true;
486 }
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:

◆ isEmptyResult()

bool RelSort::isEmptyResult ( ) const
inline

Definition at line 1168 of file RelAlgDagBuilder.h.

Referenced by RelAlgExecutor::executeSort().

1168 { return empty_result_; }
bool empty_result_
+ Here is the caller graph for this function:

◆ operator==()

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

Definition at line 1150 of file RelAlgDagBuilder.h.

References empty_result_, limit_, and offset_.

1150  {
1151  return limit_ == that.limit_ && offset_ == that.offset_ &&
1153  }
const size_t limit_
bool empty_result_
bool hasEquivCollationOf(const RelSort &that) const
const size_t offset_

◆ setCollation()

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

Definition at line 1162 of file RelAlgDagBuilder.h.

1162  {
1163  collation_ = std::move(collation);
1164  }
std::vector< SortField > collation_

◆ setEmptyResult()

void RelSort::setEmptyResult ( bool  emptyResult)
inline

Definition at line 1166 of file RelAlgDagBuilder.h.

1166 { empty_result_ = emptyResult; }
bool empty_result_

◆ size()

size_t RelSort::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1188 of file RelAlgDagBuilder.h.

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

◆ toString()

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

Implements RelAlgNode.

Definition at line 1174 of file RelAlgDagBuilder.h.

References run_benchmark_import::result, and to_string().

1174  {
1175  std::string result =
1176  "(RelSort<" + std::to_string(reinterpret_cast<uint64_t>(this)) + ">(";
1177  result += "limit: " + std::to_string(limit_) + " ";
1178  result += "offset: " + std::to_string(offset_) + " ";
1179  result += "empty_result: " + std::to_string(empty_result_) + " ";
1180  result += "collation: [ ";
1181  for (const auto& sort_field : collation_) {
1182  result += sort_field.toString() + " ";
1183  }
1184  result += "]";
1185  return result + ")";
1186  }
const size_t limit_
bool empty_result_
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 1193 of file RelAlgDagBuilder.h.

Referenced by hasEquivCollationOf().

◆ empty_result_

bool RelSort::empty_result_
private

Definition at line 1196 of file RelAlgDagBuilder.h.

Referenced by operator==().

◆ limit_

const size_t RelSort::limit_
private

Definition at line 1194 of file RelAlgDagBuilder.h.

Referenced by operator==().

◆ offset_

const size_t RelSort::offset_
private

Definition at line 1195 of file RelAlgDagBuilder.h.

Referenced by operator==().


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