quickstep-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbdeshm...@apache.org
Subject incubator-quickstep git commit: Refactored SelectOperator::getAllWorkOrders.
Date Fri, 13 Jan 2017 01:02:00 GMT
Repository: incubator-quickstep
Updated Branches:
  refs/heads/master c8c5d45bd -> 222942320


Refactored SelectOperator::getAllWorkOrders.


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

Branch: refs/heads/master
Commit: 222942320c6f441ca3b1b974de8a7e80babc081f
Parents: c8c5d45
Author: Zuyu Zhang <zuyuz@apache.org>
Authored: Wed Jan 11 18:27:59 2017 -0800
Committer: Zuyu Zhang <zuyuz@apache.org>
Committed: Thu Jan 12 13:48:26 2017 -0800

----------------------------------------------------------------------
 relational_operators/SelectOperator.cpp | 192 +++++++++------------------
 relational_operators/SelectOperator.hpp |  14 --
 2 files changed, 61 insertions(+), 145 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/22294232/relational_operators/SelectOperator.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/SelectOperator.cpp b/relational_operators/SelectOperator.cpp
index 236ee7c..f5c9ee9 100644
--- a/relational_operators/SelectOperator.cpp
+++ b/relational_operators/SelectOperator.cpp
@@ -22,6 +22,7 @@
 #include <memory>
 #include <vector>
 
+#include "catalog/CatalogTypedefs.hpp"
 #include "query_execution/QueryContext.hpp"
 #include "query_execution/WorkOrderProtosContainer.hpp"
 #include "query_execution/WorkOrdersContainer.hpp"
@@ -43,104 +44,6 @@ namespace quickstep {
 
 class Predicate;
 
-void SelectOperator::addWorkOrders(WorkOrdersContainer *container,
-                                   QueryContext *query_context,
-                                   StorageManager *storage_manager,
-                                   const Predicate *predicate,
-                                   const std::vector<std::unique_ptr<const Scalar>>
*selection,
-                                   InsertDestination *output_destination) {
-  if (input_relation_is_stored_) {
-    for (const block_id input_block_id : input_relation_block_ids_) {
-      container->addNormalWorkOrder(
-          new SelectWorkOrder(
-              query_id_,
-              input_relation_,
-              input_block_id,
-              predicate,
-              simple_projection_,
-              simple_selection_,
-              selection,
-              output_destination,
-              storage_manager,
-              CreateLIPFilterAdaptiveProberHelper(lip_deployment_index_, query_context)),
-          op_index_);
-    }
-  } else {
-    while (num_workorders_generated_ < input_relation_block_ids_.size()) {
-      container->addNormalWorkOrder(
-          new SelectWorkOrder(
-              query_id_,
-              input_relation_,
-              input_relation_block_ids_[num_workorders_generated_],
-              predicate,
-              simple_projection_,
-              simple_selection_,
-              selection,
-              output_destination,
-              storage_manager,
-              CreateLIPFilterAdaptiveProberHelper(lip_deployment_index_, query_context)),
-          op_index_);
-      ++num_workorders_generated_;
-    }
-  }
-}
-
-#ifdef QUICKSTEP_HAVE_LIBNUMA
-void SelectOperator::addPartitionAwareWorkOrders(WorkOrdersContainer *container,
-                                                 QueryContext *query_context,
-                                                 StorageManager *storage_manager,
-                                                 const Predicate *predicate,
-                                                 const std::vector<std::unique_ptr<const
Scalar>> *selection,
-                                                 InsertDestination *output_destination) {
-  DCHECK(placement_scheme_ != nullptr);
-  const std::size_t num_partitions = input_relation_.getPartitionScheme().getPartitionSchemeHeader().getNumPartitions();
-  if (input_relation_is_stored_) {
-    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]) {
-        container->addNormalWorkOrder(
-            new SelectWorkOrder(
-                query_id_,
-                input_relation_,
-                input_block_id,
-                predicate,
-                simple_projection_,
-                simple_selection_,
-                selection,
-                output_destination,
-                storage_manager,
-                CreateLIPFilterAdaptiveProberHelper(lip_deployment_index_, query_context),
-                placement_scheme_->getNUMANodeForBlock(input_block_id)),
-            op_index_);
-      }
-    }
-  } else {
-    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()) {
-        block_id block_in_partition
-            = input_relation_block_ids_in_partition_[part_id][num_workorders_generated_in_partition_[part_id]];
-        container->addNormalWorkOrder(
-            new SelectWorkOrder(
-                query_id_,
-                input_relation_,
-                block_in_partition,
-                predicate,
-                simple_projection_,
-                simple_selection_,
-                selection,
-                output_destination,
-                storage_manager,
-                CreateLIPFilterAdaptiveProberHelper(lip_deployment_index_, query_context),
-                placement_scheme_->getNUMANodeForBlock(block_in_partition)),
-            op_index_);
-        ++num_workorders_generated_in_partition_[part_id];
-      }
-    }
-  }
-}
-#endif
-
 bool SelectOperator::getAllWorkOrders(
     WorkOrdersContainer *container,
     QueryContext *query_context,
@@ -159,48 +62,75 @@ bool SelectOperator::getAllWorkOrders(
       query_context->getInsertDestination(output_destination_index_);
 
   if (input_relation_is_stored_) {
-    if (!started_) {
-      if (input_relation_.hasPartitionScheme()) {
+    if (started_) {
+      return true;
+    }
+
+    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 (const block_id input_block_id : input_relation_block_ids_in_partition_[part_id])
{
+          numa_node_id numa_node = 0;
 #ifdef QUICKSTEP_HAVE_LIBNUMA
-        if (input_relation_.hasNUMAPlacementScheme()) {
-          addPartitionAwareWorkOrders(container,
-                                      query_context,
-                                      storage_manager,
-                                      predicate,
-                                      selection,
-                                      output_destination);
+          if (input_relation_.hasNUMAPlacementScheme()) {
+            numa_node = placement_scheme_->getNUMANodeForBlock(input_block_id);
+          }
+#endif  // QUICKSTEP_HAVE_LIBNUMA
+          container->addNormalWorkOrder(
+              new SelectWorkOrder(query_id_, input_relation_, input_block_id, predicate,
simple_projection_,
+                                  simple_selection_, selection, output_destination, storage_manager,
+                                  CreateLIPFilterAdaptiveProberHelper(lip_deployment_index_,
query_context), numa_node),
+              op_index_);
         }
-#endif
-      } else {
-        addWorkOrders(container,
-                      query_context,
-                      storage_manager,
-                      predicate,
-                      selection,
-                      output_destination);
       }
-      started_ = true;
+    } else {
+      for (const block_id input_block_id : input_relation_block_ids_) {
+        container->addNormalWorkOrder(
+            new SelectWorkOrder(query_id_, input_relation_, input_block_id, predicate, simple_projection_,
+                                simple_selection_, selection, output_destination, storage_manager,
+                                CreateLIPFilterAdaptiveProberHelper(lip_deployment_index_,
query_context)),
+            op_index_);
+      }
     }
-    return started_;
+    started_ = true;
+    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) {
+        while (num_workorders_generated_in_partition_[part_id] <
+               input_relation_block_ids_in_partition_[part_id].size()) {
+          const block_id block_in_partition
+              = input_relation_block_ids_in_partition_[part_id][num_workorders_generated_in_partition_[part_id]];
+
+          numa_node_id numa_node = 0;
 #ifdef QUICKSTEP_HAVE_LIBNUMA
-        if (input_relation_.hasNUMAPlacementScheme()) {
-          addPartitionAwareWorkOrders(container,
-                                      query_context,
-                                      storage_manager,
-                                      predicate,
-                                      selection,
-                                      output_destination);
+          if (input_relation_.hasNUMAPlacementScheme()) {
+            numa_node = placement_scheme_->getNUMANodeForBlock(block_in_partition);
+          }
+#endif  // QUICKSTEP_HAVE_LIBNUMA
+          container->addNormalWorkOrder(
+              new SelectWorkOrder(query_id_, input_relation_, block_in_partition, predicate,
simple_projection_,
+                                  simple_selection_, selection, output_destination, storage_manager,
+                                  CreateLIPFilterAdaptiveProberHelper(lip_deployment_index_,
query_context), numa_node),
+              op_index_);
+          ++num_workorders_generated_in_partition_[part_id];
         }
-#endif
+      }
     } else {
-        addWorkOrders(container,
-                      query_context,
-                      storage_manager,
-                      predicate,
-                      selection,
-                      output_destination);
+      while (num_workorders_generated_ < input_relation_block_ids_.size()) {
+        container->addNormalWorkOrder(
+            new SelectWorkOrder(query_id_, input_relation_, input_relation_block_ids_[num_workorders_generated_],
+                                predicate, simple_projection_, simple_selection_, selection,
output_destination,
+                                storage_manager,
+                                CreateLIPFilterAdaptiveProberHelper(lip_deployment_index_,
query_context)),
+            op_index_);
+        ++num_workorders_generated_;
+      }
     }
     return done_feeding_input_relation_;
   }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/22294232/relational_operators/SelectOperator.hpp
----------------------------------------------------------------------
diff --git a/relational_operators/SelectOperator.hpp b/relational_operators/SelectOperator.hpp
index 2ace458..6741f45 100644
--- a/relational_operators/SelectOperator.hpp
+++ b/relational_operators/SelectOperator.hpp
@@ -248,20 +248,6 @@ class SelectOperator : public RelationalOperator {
     return output_relation_.getID();
   }
 
-  void addWorkOrders(WorkOrdersContainer *container,
-                     QueryContext *query_context,
-                     StorageManager *storage_manager,
-                     const Predicate *predicate,
-                     const std::vector<std::unique_ptr<const Scalar>> *selection,
-                     InsertDestination *output_destination);
-
-  void addPartitionAwareWorkOrders(WorkOrdersContainer *container,
-                                   QueryContext *query_context,
-                                   StorageManager *storage_manager,
-                                   const Predicate *predicate,
-                                   const std::vector<std::unique_ptr<const Scalar>>
*selection,
-                                   InsertDestination *output_destination);
-
  private:
   /**
    * @brief Create Work Order proto.


Mime
View raw message