OmniSciDB  8a228a1076
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 (RelAlgInputs inputs={})
 
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
RelAlgInputs inputs_
 
const unsigned id_
 

Detailed Description

Definition at line 1390 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 1392 of file RelAlgDagBuilder.h.

1396  : collation_(collation), limit_(limit), offset_(offset) {
1397  inputs_.push_back(input);
1398  }
const size_t limit_
std::vector< SortField > collation_
const size_t offset_
RelAlgInputs inputs_

Member Function Documentation

◆ collationCount()

size_t RelSort::collationCount ( ) const
inline

Definition at line 1405 of file RelAlgDagBuilder.h.

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

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

◆ deepCopy()

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

Implements RelAlgNode.

Definition at line 1440 of file RelAlgDagBuilder.h.

1440  {
1441  return std::make_shared<RelSort>(*this);
1442  }

◆ getCollation()

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

Definition at line 1407 of file RelAlgDagBuilder.h.

References CHECK_LT.

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

1407  {
1408  CHECK_LT(i, collation_.size());
1409  return collation_[i];
1410  }
std::vector< SortField > collation_
#define CHECK_LT(x, y)
Definition: Logger.h:207
+ Here is the caller graph for this function:

◆ getLimit()

size_t RelSort::getLimit ( ) const
inline

Definition at line 1420 of file RelAlgDagBuilder.h.

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

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

◆ getOffset()

size_t RelSort::getOffset ( ) const
inline

Definition at line 1422 of file RelAlgDagBuilder.h.

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

1422 { 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 548 of file RelAlgDagBuilder.cpp.

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

548  {
549  if (collation_.size() != that.collation_.size()) {
550  return false;
551  }
552 
553  for (size_t i = 0, e = collation_.size(); i < e; ++i) {
554  auto this_sort_key = collation_[i];
555  auto that_sort_key = that.collation_[i];
556  if (this_sort_key.getSortDir() != that_sort_key.getSortDir()) {
557  return false;
558  }
559  if (this_sort_key.getNullsPosition() != that_sort_key.getNullsPosition()) {
560  return false;
561  }
562  auto this_equiv_keys = get_equiv_cols(this, this_sort_key.getField());
563  auto that_equiv_keys = get_equiv_cols(&that, that_sort_key.getField());
564  std::vector<std::pair<const RelAlgNode*, int>> intersect;
565  std::set_intersection(this_equiv_keys.begin(),
566  this_equiv_keys.end(),
567  that_equiv_keys.begin(),
568  that_equiv_keys.end(),
569  std::back_inserter(intersect));
570  if (intersect.empty()) {
571  return false;
572  }
573  }
574  return true;
575 }
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 1418 of file RelAlgDagBuilder.h.

Referenced by RelAlgExecutor::executeSort().

1418 { 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 1400 of file RelAlgDagBuilder.h.

References empty_result_, limit_, and offset_.

1400  {
1401  return limit_ == that.limit_ && offset_ == that.offset_ &&
1403  }
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 1412 of file RelAlgDagBuilder.h.

1412  {
1413  collation_ = std::move(collation);
1414  }
std::vector< SortField > collation_

◆ setEmptyResult()

void RelSort::setEmptyResult ( bool  emptyResult)
inline

Definition at line 1416 of file RelAlgDagBuilder.h.

1416 { empty_result_ = emptyResult; }
bool empty_result_

◆ size()

size_t RelSort::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1438 of file RelAlgDagBuilder.h.

1438 { return inputs_[0]->size(); }
RelAlgInputs inputs_

◆ toString()

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

Implements RelAlgNode.

Definition at line 1424 of file RelAlgDagBuilder.h.

References run_benchmark_import::result, and to_string().

1424  {
1425  std::string result =
1426  "(RelSort<" + std::to_string(reinterpret_cast<uint64_t>(this)) + ">(";
1427  result += "limit: " + std::to_string(limit_) + " ";
1428  result += "offset: " + std::to_string(offset_) + " ";
1429  result += "empty_result: " + std::to_string(empty_result_) + " ";
1430  result += "collation: [ ";
1431  for (const auto& sort_field : collation_) {
1432  result += sort_field.toString() + " ";
1433  }
1434  result += "]";
1435  return result + "))";
1436  }
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 1445 of file RelAlgDagBuilder.h.

Referenced by hasEquivCollationOf().

◆ empty_result_

bool RelSort::empty_result_
private

Definition at line 1448 of file RelAlgDagBuilder.h.

Referenced by operator==().

◆ limit_

const size_t RelSort::limit_
private

Definition at line 1446 of file RelAlgDagBuilder.h.

Referenced by operator==().

◆ offset_

const size_t RelSort::offset_
private

Definition at line 1447 of file RelAlgDagBuilder.h.

Referenced by operator==().


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