OmniSciDB  b24e664e58
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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)
 
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 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 1138 of file RelAlgAbstractInterpreter.h.

Constructor & Destructor Documentation

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.

References RelAlgNode::inputs_.

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

size_t RelSort::collationCount ( ) const
inline

Definition at line 1153 of file RelAlgAbstractInterpreter.h.

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

1153 { return collation_.size(); }
std::vector< SortField > collation_

+ Here is the caller graph for this function:

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

Implements RelAlgNode.

Definition at line 354 of file RelAlgAbstractInterpreter.cpp.

References collation_, RelAlgNode::inputs_, isEmptyResult(), limit_, and offset_.

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

+ Here is the call graph for this function:

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

Definition at line 1155 of file RelAlgAbstractInterpreter.h.

References CHECK_LT.

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

1155  {
1156  CHECK_LT(i, collation_.size());
1157  return collation_[i];
1158  }
std::vector< SortField > collation_
#define CHECK_LT(x, y)
Definition: Logger.h:200

+ Here is the caller graph for this function:

size_t RelSort::getLimit ( ) const
inline

Definition at line 1168 of file RelAlgAbstractInterpreter.h.

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

1168 { return limit_; }

+ Here is the caller graph for this function:

size_t RelSort::getOffset ( ) const
inline

Definition at line 1170 of file RelAlgAbstractInterpreter.h.

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

1170 { return offset_; }
const size_t offset_

+ Here is the caller graph for this function:

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

Definition at line 456 of file RelAlgAbstractInterpreter.cpp.

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

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

bool RelSort::isEmptyResult ( ) const
inline

Definition at line 1166 of file RelAlgAbstractInterpreter.h.

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

1166 { return empty_result_; }

+ Here is the caller graph for this function:

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

Definition at line 1148 of file RelAlgAbstractInterpreter.h.

References empty_result_, limit_, and offset_.

1148  {
1149  return limit_ == that.limit_ && offset_ == that.offset_ &&
1151  }
bool hasEquivCollationOf(const RelSort &that) const
const size_t offset_
void RelSort::setCollation ( std::vector< SortField > &&  collation)
inline

Definition at line 1160 of file RelAlgAbstractInterpreter.h.

1160  {
1161  collation_ = std::move(collation);
1162  }
std::vector< SortField > collation_
void RelSort::setEmptyResult ( bool  emptyResult)
inline

Definition at line 1164 of file RelAlgAbstractInterpreter.h.

1164 { empty_result_ = emptyResult; }
size_t RelSort::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1186 of file RelAlgAbstractInterpreter.h.

References RelAlgNode::inputs_.

1186 { return inputs_[0]->size(); }
std::vector< std::shared_ptr< const RelAlgNode > > inputs_
std::string RelSort::toString ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1172 of file RelAlgAbstractInterpreter.h.

References run_benchmark_import::result, and to_string().

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

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

Definition at line 1191 of file RelAlgAbstractInterpreter.h.

Referenced by deepCopy(), and hasEquivCollationOf().

bool RelSort::empty_result_
private

Definition at line 1194 of file RelAlgAbstractInterpreter.h.

Referenced by operator==().

const size_t RelSort::limit_
private

Definition at line 1192 of file RelAlgAbstractInterpreter.h.

Referenced by deepCopy(), and operator==().

const size_t RelSort::offset_
private

Definition at line 1193 of file RelAlgAbstractInterpreter.h.

Referenced by deepCopy(), and operator==().


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