taco-db  0.1.0
Sort.h
Go to the documentation of this file.
1 #ifndef PLAN_SORT_H
2 #define PLAN_SORT_H
3 
4 #include "plan/PlanNode.h"
5 #include "expr/ExprNode.h"
6 #include "extsort/ExternalSort.h"
7 
8 namespace taco {
9 
10 class SortState;
11 
19 class Sort: public PlanNode {
20 public:
21  static std::unique_ptr<Sort>
22  Create(std::unique_ptr<PlanNode>&& child,
23  std::vector<std::unique_ptr<ExprNode>>&& sort_exprs,
24  const std::vector<bool>& desc);
25 
26  ~Sort() override;
27 
28  void node_properties_to_string(std::string& buf, int indent) const override;
29 
30  std::unique_ptr<PlanExecState> create_exec_state() const override;
31 
32  const Schema* get_output_schema() const override;
33 
34 private:
35  Sort(std::unique_ptr<PlanNode>&& child,
36  std::vector<std::unique_ptr<ExprNode>>&& sort_exprs,
37  const std::vector<bool>& desc);
38 
39  int sort_compare_func_impl(const char *a, const char *b) const;
40 
42 
43  // You can add your own states here.
44 
45  friend class SortState;
46 };
47 
48 }; // namespace taco
49 
50 #endif
PlanNode is an abstract interface representing physical query plan that does not bound with any parti...
Definition: PlanNode.h:26
A Schema object stores the information for accessing an ordered set of typed fields either from a dis...
Definition: Schema.h:39
SortState is the execution state for sorting.
Definition: SortState.h:19
Sort is the physical plan for sorting operators.
Definition: Sort.h:19
Sort(std::unique_ptr< PlanNode > &&child, std::vector< std::unique_ptr< ExprNode >> &&sort_exprs, const std::vector< bool > &desc)
Definition: Sort.cpp:11
std::unique_ptr< PlanExecState > create_exec_state() const override
Create the corresponding execution state for the physical plan so that it can be used as physical sca...
Definition: Sort.cpp:44
int sort_compare_func_impl(const char *a, const char *b) const
Definition: Sort.cpp:21
const Schema * get_output_schema() const override
Each physical plan should link a schema for its output relation, incidating what fields are included ...
Definition: Sort.cpp:50
void node_properties_to_string(std::string &buf, int indent) const override
Definition: Sort.cpp:39
SortCompareFunction m_cmp
Definition: Sort.h:41
~Sort() override
Definition: Sort.cpp:34
static std::unique_ptr< Sort > Create(std::unique_ptr< PlanNode > &&child, std::vector< std::unique_ptr< ExprNode >> &&sort_exprs, const std::vector< bool > &desc)
Definition: Sort.cpp:27
Definition: datum.h:28
std::function< int(const char *item1, const char *item2)> SortCompareFunction
SortCompareFunction compares item1 and item2 and returns a negative integer if item1 < item2,...
Definition: ExternalSort.h:25