You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@quickstep.apache.org by zu...@apache.org on 2016/06/27 21:33:51 UTC

[16/18] incubator-quickstep git commit: Added the move semantic in optimizer::logical::Sort

Added the move semantic in optimizer::logical::Sort


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/f66f4bd1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/f66f4bd1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/f66f4bd1

Branch: refs/heads/travis-grpc
Commit: f66f4bd19cf1a34c3ee2e6acb91f75b92c037927
Parents: c0c13f6
Author: shixuan-fan <sh...@apache.org>
Authored: Mon Jun 27 15:50:56 2016 +0000
Committer: Zuyu Zhang <zu...@apache.org>
Committed: Mon Jun 27 14:14:48 2016 -0700

----------------------------------------------------------------------
 query_optimizer/logical/Sort.hpp      | 26 ++++++++++++++++++++++++++
 query_optimizer/resolver/Resolver.cpp | 18 +++++++++---------
 2 files changed, 35 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/f66f4bd1/query_optimizer/logical/Sort.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/logical/Sort.hpp b/query_optimizer/logical/Sort.hpp
index c20ce0f..2233151 100644
--- a/query_optimizer/logical/Sort.hpp
+++ b/query_optimizer/logical/Sort.hpp
@@ -113,6 +113,19 @@ class Sort : public Logical {
                             limit));
   }
 
+  static SortPtr Create(
+      const LogicalPtr &input,
+      std::vector<expressions::AttributeReferencePtr> &&sort_attributes,
+      std::vector<bool> &&sort_ascending,
+      std::vector<bool> &&nulls_first_flags,
+      const int limit) {
+    return SortPtr(new Sort(input,
+                            std::move(sort_attributes),
+                            std::move(sort_ascending),
+                            std::move(nulls_first_flags),
+                            limit));
+  }
+
  protected:
   void getFieldStringItems(
       std::vector<std::string> *inline_field_names,
@@ -137,6 +150,19 @@ class Sort : public Logical {
     addChild(input_);
   }
 
+  Sort(const LogicalPtr &input,
+       std::vector<expressions::AttributeReferencePtr> &&sort_attributes,
+       std::vector<bool> &&sort_ascending,
+       std::vector<bool> &&nulls_first_flags,
+       const int limit)
+      : input_(input),
+        sort_attributes_(std::move(sort_attributes)),
+        sort_ascending_(std::move(sort_ascending)),
+        nulls_first_flags_(std::move(nulls_first_flags)),
+        limit_(limit) {
+    addChild(input_);
+  }
+
   LogicalPtr input_;
   std::vector<expressions::AttributeReferencePtr> sort_attributes_;
   // Has 1:1 matching with <sort_expressions_>.

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/f66f4bd1/query_optimizer/resolver/Resolver.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/resolver/Resolver.cpp b/query_optimizer/resolver/Resolver.cpp
index f880ce7..1eb6d86 100644
--- a/query_optimizer/resolver/Resolver.cpp
+++ b/query_optimizer/resolver/Resolver.cpp
@@ -1270,16 +1270,16 @@ L::LogicalPtr Resolver::resolveSelect(
     if (select_query.limit() != nullptr) {
       logical_plan =
           L::Sort::Create(logical_plan,
-                          order_by_attributes,
-                          order_by_directions,
-                          nulls_first,
+                          std::move(order_by_attributes),
+                          std::move(order_by_directions),
+                          std::move(nulls_first),
                           select_query.limit()->limit_expression()->long_value());
     } else {
       logical_plan =
           L::Sort::Create(logical_plan,
-                          order_by_attributes,
-                          order_by_directions,
-                          nulls_first,
+                          std::move(order_by_attributes),
+                          std::move(order_by_directions),
+                          std::move(nulls_first),
                           -1 /* limit */);
     }
   } else if (select_query.limit() != nullptr) {
@@ -1880,9 +1880,9 @@ L::LogicalPtr Resolver::resolveSortInWindow(
 
   L::LogicalPtr sorted_logical_plan =
       L::Sort::Create(logical_plan,
-                      sort_attributes,
-                      sort_directions,
-                      sort_nulls_first,
+                      std::move(sort_attributes),
+                      std::move(sort_directions),
+                      std::move(sort_nulls_first),
                       -1 /* limit */);
 
   return sorted_logical_plan;