OmniSciDB  bf83d84833
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 ()
 
void clearContextData () const
 

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 1380 of file RelAlgDagBuilder.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 1382 of file RelAlgDagBuilder.h.

References RelAlgNode::inputs_.

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

Member Function Documentation

size_t RelSort::collationCount ( ) const
inline

Definition at line 1395 of file RelAlgDagBuilder.h.

References collation_.

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

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

+ Here is the caller graph for this function:

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

Implements RelAlgNode.

Definition at line 1430 of file RelAlgDagBuilder.h.

1430  {
1431  return std::make_shared<RelSort>(*this);
1432  }
SortField RelSort::getCollation ( const size_t  i) const
inline

Definition at line 1397 of file RelAlgDagBuilder.h.

References CHECK_LT, and collation_.

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

1397  {
1398  CHECK_LT(i, collation_.size());
1399  return collation_[i];
1400  }
std::vector< SortField > collation_
#define CHECK_LT(x, y)
Definition: Logger.h:207

+ Here is the caller graph for this function:

size_t RelSort::getLimit ( ) const
inline

Definition at line 1410 of file RelAlgDagBuilder.h.

References limit_.

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

1410 { return limit_; }
const size_t limit_

+ Here is the caller graph for this function:

size_t RelSort::getOffset ( ) const
inline

Definition at line 1412 of file RelAlgDagBuilder.h.

References offset_.

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

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

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

Referenced by operator==().

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:

+ Here is the caller graph for this function:

bool RelSort::isEmptyResult ( ) const
inline

Definition at line 1408 of file RelAlgDagBuilder.h.

References empty_result_.

Referenced by RelAlgExecutor::executeSort().

1408 { return empty_result_; }
bool empty_result_

+ Here is the caller graph for this function:

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

Definition at line 1390 of file RelAlgDagBuilder.h.

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

1390  {
1391  return limit_ == that.limit_ && offset_ == that.offset_ &&
1393  }
const size_t limit_
bool hasEquivCollationOf(const RelSort &that) const
bool empty_result_
const size_t offset_

+ Here is the call graph for this function:

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

Definition at line 1402 of file RelAlgDagBuilder.h.

References collation_.

1402  {
1403  collation_ = std::move(collation);
1404  }
std::vector< SortField > collation_
void RelSort::setEmptyResult ( bool  emptyResult)
inline

Definition at line 1406 of file RelAlgDagBuilder.h.

References empty_result_.

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

Implements RelAlgNode.

Definition at line 1428 of file RelAlgDagBuilder.h.

References RelAlgNode::inputs_.

1428 { return inputs_[0]->size(); }
RelAlgInputs inputs_
std::string RelSort::toString ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1414 of file RelAlgDagBuilder.h.

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

1414  {
1415  return cat(::typeName(this),
1416  "(",
1417  "collation=",
1418  ::toString(collation_),
1419  ", limit=",
1421  ", offset",
1423  ", inputs=",
1424  ::toString(inputs_),
1425  ")");
1426  }
const size_t limit_
std::string cat(Ts &&...args)
std::string to_string(char const *&&v)
std::vector< SortField > collation_
const size_t offset_
std::string toString() const override
RelAlgInputs inputs_

+ Here is the call graph for this function:

Member Data Documentation

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

Definition at line 1438 of file RelAlgDagBuilder.h.

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

const size_t RelSort::limit_
private

Definition at line 1436 of file RelAlgDagBuilder.h.

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

const size_t RelSort::offset_
private

Definition at line 1437 of file RelAlgDagBuilder.h.

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


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