quickstep-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jianq...@apache.org
Subject [13/22] incubator-quickstep git commit: Refactored SelectorOperator regarding partitions.
Date Thu, 26 Jan 2017 02:34:34 GMT
Refactored SelectorOperator regarding partitions.


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

Branch: refs/heads/exact-filter
Commit: 60e34060a8a9e82330442fa32b3f7030fa3a615d
Parents: e26cc1e
Author: Zuyu Zhang <zuyuz@apache.org>
Authored: Tue Jan 17 18:38:25 2017 -0800
Committer: Zuyu Zhang <zuyuz@apache.org>
Committed: Tue Jan 17 18:38:25 2017 -0800

----------------------------------------------------------------------
 relational_operators/SelectOperator.cpp | 10 +----
 relational_operators/SelectOperator.hpp | 62 +++++++++++++---------------
 2 files changed, 31 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/60e34060/relational_operators/SelectOperator.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/SelectOperator.cpp b/relational_operators/SelectOperator.cpp
index d2759c4..5419cf8 100644
--- a/relational_operators/SelectOperator.cpp
+++ b/relational_operators/SelectOperator.cpp
@@ -67,10 +67,7 @@ bool SelectOperator::getAllWorkOrders(
     }
 
     if (input_relation_.hasPartitionScheme()) {
-      const std::size_t num_partitions =
-          input_relation_.getPartitionScheme()->getPartitionSchemeHeader().getNumPartitions();
-
-      for (std::size_t part_id = 0; part_id < num_partitions; ++part_id) {
+      for (std::size_t part_id = 0; part_id < num_partitions_; ++part_id) {
         for (const block_id input_block_id : input_relation_block_ids_in_partition_[part_id])
{
           numa_node_id numa_node = 0;
 #ifdef QUICKSTEP_HAVE_LIBNUMA
@@ -98,10 +95,7 @@ bool SelectOperator::getAllWorkOrders(
     return true;
   } else {
     if (input_relation_.hasPartitionScheme()) {
-      const std::size_t num_partitions =
-          input_relation_.getPartitionScheme()->getPartitionSchemeHeader().getNumPartitions();
-
-      for (std::size_t part_id = 0; part_id < num_partitions; ++part_id) {
+      for (std::size_t part_id = 0; part_id < num_partitions_; ++part_id) {
         while (num_workorders_generated_in_partition_[part_id] <
                input_relation_block_ids_in_partition_[part_id].size()) {
           const block_id block_in_partition

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/60e34060/relational_operators/SelectOperator.hpp
----------------------------------------------------------------------
diff --git a/relational_operators/SelectOperator.hpp b/relational_operators/SelectOperator.hpp
index 989eaac..9c0767b 100644
--- a/relational_operators/SelectOperator.hpp
+++ b/relational_operators/SelectOperator.hpp
@@ -100,9 +100,6 @@ class SelectOperator : public RelationalOperator {
         output_destination_index_(output_destination_index),
         predicate_index_(predicate_index),
         selection_index_(selection_index),
-        input_relation_block_ids_(input_relation_is_stored
-                                      ? input_relation.getBlocksSnapshot()
-                                      : std::vector<block_id>()),
         num_workorders_generated_(0),
         simple_projection_(false),
         input_relation_is_stored_(input_relation_is_stored),
@@ -112,20 +109,20 @@ class SelectOperator : public RelationalOperator {
 #endif
     if (input_relation.hasPartitionScheme()) {
       const PartitionScheme &part_scheme = *input_relation.getPartitionScheme();
-      const PartitionSchemeHeader &part_scheme_header = part_scheme.getPartitionSchemeHeader();
-      const std::size_t num_partitions = part_scheme_header.getNumPartitions();
-      input_relation_block_ids_in_partition_.resize(num_partitions);
-      num_workorders_generated_in_partition_.resize(num_partitions);
-      num_workorders_generated_in_partition_.assign(num_partitions, 0);
-      for (std::size_t part_id = 0; part_id < num_partitions; ++part_id) {
-        if (input_relation_is_stored) {
-          input_relation_block_ids_in_partition_[part_id] =
-              part_scheme.getBlocksInPartition(part_id);
-        } else {
-          input_relation_block_ids_in_partition_[part_id] =
-              std::vector<block_id>();
+      num_partitions_ = part_scheme.getPartitionSchemeHeader().getNumPartitions();
+
+      num_workorders_generated_in_partition_.resize(num_partitions_);
+
+      if (input_relation_is_stored) {
+        for (std::size_t part_id = 0; part_id < num_partitions_; ++part_id) {
+          input_relation_block_ids_in_partition_.push_back(
+              part_scheme.getBlocksInPartition(part_id));
         }
+      } else {
+        input_relation_block_ids_in_partition_.resize(num_partitions_);
       }
+    } else if (input_relation_is_stored) {
+      input_relation_block_ids_ = input_relation.getBlocksSnapshot();
     }
   }
 
@@ -163,9 +160,6 @@ class SelectOperator : public RelationalOperator {
         predicate_index_(predicate_index),
         selection_index_(QueryContext::kInvalidScalarGroupId),
         simple_selection_(std::move(selection)),
-        input_relation_block_ids_(input_relation_is_stored
-                                      ? input_relation.getBlocksSnapshot()
-                                      : std::vector<block_id>()),
         num_workorders_generated_(0),
         simple_projection_(true),
         input_relation_is_stored_(input_relation_is_stored),
@@ -175,20 +169,20 @@ class SelectOperator : public RelationalOperator {
 #endif
     if (input_relation.hasPartitionScheme()) {
       const PartitionScheme &part_scheme = *input_relation.getPartitionScheme();
-      const PartitionSchemeHeader &part_scheme_header = part_scheme.getPartitionSchemeHeader();
-      const std::size_t num_partitions = part_scheme_header.getNumPartitions();
-      input_relation_block_ids_in_partition_.resize(num_partitions);
-      num_workorders_generated_in_partition_.resize(num_partitions);
-      num_workorders_generated_in_partition_.assign(num_partitions, 0);
-      for (std::size_t part_id = 0; part_id < num_partitions; ++part_id) {
-        if (input_relation_is_stored) {
-          input_relation_block_ids_in_partition_[part_id] =
-              part_scheme.getBlocksInPartition(part_id);
-        } else {
-          input_relation_block_ids_in_partition_[part_id] =
-              std::vector<block_id>();
+      num_partitions_ = part_scheme.getPartitionSchemeHeader().getNumPartitions();
+
+      num_workorders_generated_in_partition_.resize(num_partitions_);
+
+      if (input_relation_is_stored) {
+        for (std::size_t part_id = 0; part_id < num_partitions_; ++part_id) {
+          input_relation_block_ids_in_partition_.push_back(
+              part_scheme.getBlocksInPartition(part_id));
         }
+      } else {
+        input_relation_block_ids_in_partition_.resize(num_partitions_);
       }
+    } else if (input_relation_is_stored) {
+      input_relation_block_ids_ = input_relation.getBlocksSnapshot();
     }
   }
 
@@ -245,14 +239,16 @@ class SelectOperator : public RelationalOperator {
   const std::vector<attribute_id> simple_selection_;
 
   std::vector<block_id> input_relation_block_ids_;
+  // A single workorder is generated for each block of input relation.
+  std::vector<block_id>::size_type num_workorders_generated_;
+
+  // Used for the partition case only.
   // A vector of vectors V where V[i] indicates the list of block IDs of the
   // input relation that belong to the partition i.
   std::vector<std::vector<block_id>> input_relation_block_ids_in_partition_;
-
-  // A single workorder is generated for each block of input relation.
-  std::vector<block_id>::size_type num_workorders_generated_;
   // A single workorder is generated for each block in each partition of input relation.
   std::vector<std::size_t> num_workorders_generated_in_partition_;
+  std::size_t num_partitions_;
 
   const bool simple_projection_;
   const bool input_relation_is_stored_;


Mime
View raw message