quickstep-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbdeshm...@apache.org
Subject [2/3] incubator-quickstep git commit: Bug fix in initialization of probabilities.
Date Fri, 24 Jun 2016 16:41:05 GMT
Bug fix in initialization of probabilities.


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

Branch: refs/heads/scheduler++
Commit: 68b7a7c6b003b0b7f2d5656072e4bd2e70a9570e
Parents: e11588e
Author: Harshad Deshmukh <hbdeshmukh@apache.org>
Authored: Fri Jun 24 10:57:01 2016 -0500
Committer: Harshad Deshmukh <hbdeshmukh@apache.org>
Committed: Fri Jun 24 10:57:01 2016 -0500

----------------------------------------------------------------------
 query_execution/Learner.cpp                |  7 +++--
 query_execution/tests/Learner_unittest.cpp | 38 +++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/68b7a7c6/query_execution/Learner.cpp
----------------------------------------------------------------------
diff --git a/query_execution/Learner.cpp b/query_execution/Learner.cpp
index 5d877b4..38a773b 100644
--- a/query_execution/Learner.cpp
+++ b/query_execution/Learner.cpp
@@ -184,9 +184,10 @@ void Learner::initializeDefaultProbabilitiesForPriorityLevels() {
   for (auto priority_iter = execution_stats_.cbegin();
        priority_iter != execution_stats_.cend();
        ++priority_iter) {
-    sum_priority_levels += priority_iter->second.size();
-    priority_levels.emplace_back(priority_iter->first);
-    numerators.emplace_back(priority_iter->first);
+    const std::size_t curr_priority_level = priority_iter->first;
+    sum_priority_levels += curr_priority_level;
+    priority_levels.emplace_back(curr_priority_level);
+    numerators.emplace_back(curr_priority_level);
   }
   if (sum_priority_levels > 0) {
     probabilities_of_priority_levels_->addOrUpdateObjectsNewDenominator(

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/68b7a7c6/query_execution/tests/Learner_unittest.cpp
----------------------------------------------------------------------
diff --git a/query_execution/tests/Learner_unittest.cpp b/query_execution/tests/Learner_unittest.cpp
index 74353f0..864bb22 100644
--- a/query_execution/tests/Learner_unittest.cpp
+++ b/query_execution/tests/Learner_unittest.cpp
@@ -84,4 +84,42 @@ TEST(LearnerTest, MultipleQueriesSamePriorityAddRemoveTest) {
   EXPECT_EQ(0u, learner.getNumActiveQueriesInPriorityLevel(kPriorityLevel));
 }
 
+TEST(LearnerTest, MultipleQueriesDifferentPrioritiesAddRemoveTest) {
+  Learner learner;
+  std::unique_ptr<QueryHandle> handle1, handle2;
+  const std::size_t kPriorityLevel1 = 1;
+  const std::size_t kPriorityLevel2 = 2;
+  handle1.reset(new QueryHandle(1, kPriorityLevel1));
+  handle2.reset(new QueryHandle(2, kPriorityLevel2));
+
+  EXPECT_FALSE(learner.hasActiveQueries());
+  EXPECT_EQ(0u, learner.getTotalNumActiveQueries());
+  EXPECT_EQ(0u, learner.getNumActiveQueriesInPriorityLevel(kPriorityLevel1));
+  EXPECT_EQ(0u, learner.getNumActiveQueriesInPriorityLevel(kPriorityLevel2));
+
+  learner.addQuery(*handle1);
+  EXPECT_TRUE(learner.hasActiveQueries());
+  EXPECT_EQ(1u, learner.getTotalNumActiveQueries());
+  EXPECT_EQ(1u, learner.getNumActiveQueriesInPriorityLevel(kPriorityLevel1));
+  EXPECT_EQ(0u, learner.getNumActiveQueriesInPriorityLevel(kPriorityLevel2));
+
+  learner.addQuery(*handle2);
+  EXPECT_TRUE(learner.hasActiveQueries());
+  EXPECT_EQ(2u, learner.getTotalNumActiveQueries());
+  EXPECT_EQ(1u, learner.getNumActiveQueriesInPriorityLevel(kPriorityLevel1));
+  EXPECT_EQ(1u, learner.getNumActiveQueriesInPriorityLevel(kPriorityLevel2));
+
+  learner.removeQuery(handle2->query_id());
+  EXPECT_TRUE(learner.hasActiveQueries());
+  EXPECT_EQ(1u, learner.getTotalNumActiveQueries());
+  EXPECT_EQ(0u, learner.getNumActiveQueriesInPriorityLevel(kPriorityLevel2));
+  EXPECT_EQ(1u, learner.getNumActiveQueriesInPriorityLevel(kPriorityLevel1));
+
+  learner.removeQuery(handle1->query_id());
+  EXPECT_FALSE(learner.hasActiveQueries());
+  EXPECT_EQ(0u, learner.getTotalNumActiveQueries());
+  EXPECT_EQ(0u, learner.getNumActiveQueriesInPriorityLevel(kPriorityLevel1));
+  EXPECT_EQ(0u, learner.getNumActiveQueriesInPriorityLevel(kPriorityLevel2));
+}
+
 }  // namespace quickstep


Mime
View raw message