OmniSciDB  8fa3bf436f
 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 1324 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 1326 of file RelAlgDagBuilder.h.

References RelAlgNode::inputs_.

1330  : collation_(collation), limit_(limit), offset_(offset) {
1331  inputs_.push_back(input);
1332  }
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 1339 of file RelAlgDagBuilder.h.

References collation_.

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

1339 { 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 1374 of file RelAlgDagBuilder.h.

1374  {
1375  return std::make_shared<RelSort>(*this);
1376  }
SortField RelSort::getCollation ( const size_t  i) const
inline

Definition at line 1341 of file RelAlgDagBuilder.h.

References CHECK_LT, collation_, and i.

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

1341  {
1342  CHECK_LT(i, collation_.size());
1343  return collation_[i];
1344  }
std::vector< SortField > collation_
#define CHECK_LT(x, y)
Definition: Logger.h:213

+ Here is the caller graph for this function:

size_t RelSort::getLimit ( ) const
inline

Definition at line 1354 of file RelAlgDagBuilder.h.

References limit_.

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

1354 { return limit_; }
const size_t limit_

+ Here is the caller graph for this function:

size_t RelSort::getOffset ( ) const
inline

Definition at line 1356 of file RelAlgDagBuilder.h.

References offset_.

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

1356 { 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 559 of file RelAlgDagBuilder.cpp.

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

Referenced by operator==().

559  {
560  if (collation_.size() != that.collation_.size()) {
561  return false;
562  }
563 
564  for (size_t i = 0, e = collation_.size(); i < e; ++i) {
565  auto this_sort_key = collation_[i];
566  auto that_sort_key = that.collation_[i];
567  if (this_sort_key.getSortDir() != that_sort_key.getSortDir()) {
568  return false;
569  }
570  if (this_sort_key.getNullsPosition() != that_sort_key.getNullsPosition()) {
571  return false;
572  }
573  auto this_equiv_keys = get_equiv_cols(this, this_sort_key.getField());
574  auto that_equiv_keys = get_equiv_cols(&that, that_sort_key.getField());
575  std::vector<std::pair<const RelAlgNode*, int>> intersect;
576  std::set_intersection(this_equiv_keys.begin(),
577  this_equiv_keys.end(),
578  that_equiv_keys.begin(),
579  that_equiv_keys.end(),
580  std::back_inserter(intersect));
581  if (intersect.empty()) {
582  return false;
583  }
584  }
585  return true;
586 }
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 1352 of file RelAlgDagBuilder.h.

References empty_result_.

Referenced by RelAlgExecutor::executeSort().

1352 { 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 1334 of file RelAlgDagBuilder.h.

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

1334  {
1335  return limit_ == that.limit_ && offset_ == that.offset_ &&
1337  }
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 1346 of file RelAlgDagBuilder.h.

References collation_.

1346  {
1347  collation_ = std::move(collation);
1348  }
std::vector< SortField > collation_
void RelSort::setEmptyResult ( bool  emptyResult)
inline

Definition at line 1350 of file RelAlgDagBuilder.h.

References empty_result_.

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

Implements RelAlgNode.

Definition at line 1372 of file RelAlgDagBuilder.h.

References RelAlgNode::inputs_.

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

Implements RelAlgNode.

Definition at line 1358 of file RelAlgDagBuilder.h.

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

1358  {
1359  return cat(::typeName(this),
1360  "(",
1361  "collation=",
1362  ::toString(collation_),
1363  ", limit=",
1365  ", offset",
1367  ", inputs=",
1368  ::toString(inputs_),
1369  ")");
1370  }
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
std::string typeName(const T *v)
Definition: toString.h:82
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 1382 of file RelAlgDagBuilder.h.

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

const size_t RelSort::limit_
private

Definition at line 1380 of file RelAlgDagBuilder.h.

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

const size_t RelSort::offset_
private

Definition at line 1381 of file RelAlgDagBuilder.h.

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


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