You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@quickstep.apache.org by hb...@apache.org on 2016/07/16 22:17:08 UTC

[7/8] incubator-quickstep git commit: Memory estimate from selection output.

Memory estimate from selection output.


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

Branch: refs/heads/memory-estimate
Commit: 8895a7def57a1d780a98c13b7195da890a728b43
Parents: 5f58d92
Author: Harshad Deshmukh <hb...@apache.org>
Authored: Wed Jul 13 14:33:43 2016 -0500
Committer: Harshad Deshmukh <hb...@apache.org>
Committed: Sat Jul 16 16:31:21 2016 -0500

----------------------------------------------------------------------
 query_execution/PriorityPolicyEnforcer.cpp | 1 +
 query_optimizer/CMakeLists.txt             | 1 +
 query_optimizer/ExecutionGenerator.cpp     | 7 +++++++
 query_optimizer/ExecutionGenerator.hpp     | 2 ++
 4 files changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8895a7de/query_execution/PriorityPolicyEnforcer.cpp
----------------------------------------------------------------------
diff --git a/query_execution/PriorityPolicyEnforcer.cpp b/query_execution/PriorityPolicyEnforcer.cpp
index e0290f1..30aa39e 100644
--- a/query_execution/PriorityPolicyEnforcer.cpp
+++ b/query_execution/PriorityPolicyEnforcer.cpp
@@ -78,6 +78,7 @@ bool PriorityPolicyEnforcer::admitQuery(QueryHandle *query_handle) {
       learner_->addQuery(*query_handle);
       query_handle->setAdmissionTime();
       query_id_to_handle_[query_handle->query_id()] = query_handle;
+      LOG(INFO) << "Query " << query_handle->query_id() << " mem estimate: " << query_handle->getEstimatedMaxMemoryInBytes() << " bytes";
       return true;
     } else {
       LOG(ERROR) << "Query with the same ID " << query_id << " exists";

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8895a7de/query_optimizer/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/query_optimizer/CMakeLists.txt b/query_optimizer/CMakeLists.txt
index 8912414..fdc607a 100644
--- a/query_optimizer/CMakeLists.txt
+++ b/query_optimizer/CMakeLists.txt
@@ -77,6 +77,7 @@ target_link_libraries(quickstep_queryoptimizer_ExecutionGenerator
                       quickstep_queryoptimizer_QueryPlan
                       quickstep_queryoptimizer_costmodel_CostModel
                       quickstep_queryoptimizer_costmodel_SimpleCostModel
+                      quickstep_queryoptimizer_costmodel_StarSchemaSimpleCostModel
                       quickstep_queryoptimizer_expressions_AggregateFunction
                       quickstep_queryoptimizer_expressions_Alias
                       quickstep_queryoptimizer_expressions_AttributeReference

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8895a7de/query_optimizer/ExecutionGenerator.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp
index 33708f0..9bb6174 100644
--- a/query_optimizer/ExecutionGenerator.cpp
+++ b/query_optimizer/ExecutionGenerator.cpp
@@ -55,6 +55,7 @@
 #include "query_optimizer/QueryHandle.hpp"
 #include "query_optimizer/QueryPlan.hpp"
 #include "query_optimizer/cost_model/SimpleCostModel.hpp"
+#include "query_optimizer/cost_model/StarSchemaSimpleCostModel.hpp"
 #include "query_optimizer/expressions/AggregateFunction.hpp"
 #include "query_optimizer/expressions/Alias.hpp"
 #include "query_optimizer/expressions/AttributeReference.hpp"
@@ -161,6 +162,8 @@ void ExecutionGenerator::generatePlan(const P::PhysicalPtr &physical_plan) {
 
   cost_model_.reset(
       new cost::SimpleCostModel(top_level_physical_plan_->shared_subplans()));
+  ss_cost_model_.reset(new cost::StarSchemaSimpleCostModel(
+      top_level_physical_plan_->shared_subplans()));
 
   const CatalogRelation *result_relation = nullptr;
 
@@ -329,6 +332,10 @@ void ExecutionGenerator::createTemporaryCatalogRelation(
   const relation_id output_rel_id = optimizer_context_->catalog_database()->addRelation(
       catalog_relation.release());
 
+  const std::size_t estimated_cardinality = ss_cost_model_->estimateCardinality(physical);
+  const std::size_t estimated_tuple_size = (*catalog_relation_output)->getEstimatedByteLength();
+  query_handle_->addMemoryToEstimate(estimated_cardinality * estimated_tuple_size);
+
 #ifdef QUICKSTEP_DISTRIBUTED
   referenced_relation_ids_.insert(output_rel_id);
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8895a7de/query_optimizer/ExecutionGenerator.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/ExecutionGenerator.hpp b/query_optimizer/ExecutionGenerator.hpp
index c7fd018..8cd8283 100644
--- a/query_optimizer/ExecutionGenerator.hpp
+++ b/query_optimizer/ExecutionGenerator.hpp
@@ -415,6 +415,8 @@ class ExecutionGenerator {
    * @brief The cost model to use for creating the execution plan.
    */
   std::unique_ptr<cost::CostModel> cost_model_;
+  // The star schema cost model.
+  std::unique_ptr<cost::CostModel> ss_cost_model_;
 
   physical::TopLevelPlanPtr top_level_physical_plan_;