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:05 UTC

[4/8] incubator-quickstep git commit: Learner keeps a STL set of priority levels.

Learner keeps a STL set of priority levels.


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

Branch: refs/heads/memory-estimate
Commit: 8caae5a0f87b8e3dfc19c08af6a1595d5dd24048
Parents: 884a50e
Author: Harshad Deshmukh <hb...@apache.org>
Authored: Fri Jul 15 16:30:46 2016 -0500
Committer: Harshad Deshmukh <hb...@apache.org>
Committed: Fri Jul 15 16:30:46 2016 -0500

----------------------------------------------------------------------
 query_execution/Learner.cpp | 21 ++-------------------
 query_execution/Learner.hpp | 12 +++++++-----
 2 files changed, 9 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8caae5a0/query_execution/Learner.cpp
----------------------------------------------------------------------
diff --git a/query_execution/Learner.cpp b/query_execution/Learner.cpp
index 264e84e..272d582 100644
--- a/query_execution/Learner.cpp
+++ b/query_execution/Learner.cpp
@@ -40,8 +40,7 @@ DEFINE_uint64(max_past_entries_learner,
               "The maximum number of past WorkOrder execution statistics"
               " entries for a query");
 
-Learner::Learner()
-    : highest_priority_level_(kInvalidPriorityLevel) {
+Learner::Learner() {
   probabilities_of_priority_levels_.reset(new ProbabilityStore());
   // Format: Query ID, Operator ID, Worker ID, Time in micros, WO execution end timestamp.
   LOG(INFO) << "Query ID|Operator ID|Worker ID|Time in microseconds|Workorder end timestamp";
@@ -232,23 +231,7 @@ void Learner::checkAndRemovePriorityLevel(const std::size_t priority_level) {
     default_probabilities_.erase(priority_level);
     // NOTE(harshad) : Not using this cache as it gets confusing.
     // has_feedback_from_all_queries_.erase(priority_level);
-    if (hasActiveQueries()) {
-      if (static_cast<int>(priority_level) == highest_priority_level_) {
-        // The priority level to be removed is the highest priority level.
-        std::size_t new_highest_priority_level = 0;
-        // Find the new highest priority level.
-        for (auto priority_level_it = execution_stats_.cbegin();
-             priority_level_it != execution_stats_.cend();
-             ++priority_level_it) {
-          if (priority_level_it->first > new_highest_priority_level) {
-            new_highest_priority_level = priority_level_it->first;
-          }
-        }
-        highest_priority_level_ = static_cast<int>(new_highest_priority_level);
-      }
-    } else {
-      highest_priority_level_ = kInvalidPriorityLevel;
-    }
+    priority_levels_set_.erase(priority_level);
   }
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8caae5a0/query_execution/Learner.hpp
----------------------------------------------------------------------
diff --git a/query_execution/Learner.hpp b/query_execution/Learner.hpp
index f61e4f9..36f1509 100644
--- a/query_execution/Learner.hpp
+++ b/query_execution/Learner.hpp
@@ -162,7 +162,11 @@ class Learner {
    *         kInvalidPriorityLevel.
    **/
   inline const int getHighestPriorityLevel() const {
-    return highest_priority_level_;
+    if (!priority_levels_set_.empty()) {
+      return static_cast<int>(*priority_levels_set_.rbegin());
+    } else {
+      return kInvalidPriorityLevel;
+    }
   }
 
   /**
@@ -325,9 +329,7 @@ class Learner {
     if (!isPriorityLevelPresent(priority_level)) {
       current_probabilities_[priority_level].reset(new ProbabilityStore());
       execution_stats_.emplace(priority_level, std::vector<std::pair<std::size_t, std::unique_ptr<ExecutionStats>>>());
-      if (static_cast<int>(priority_level) > highest_priority_level_) {
-        highest_priority_level_ = priority_level;
-      }
+      priority_levels_set_.insert(priority_level);
     }
   }
 
@@ -555,7 +557,7 @@ class Learner {
   // feedback from all the queries in the given priority level.
   // std::unordered_map<std::size_t, bool> has_feedback_from_all_queries_;
 
-  int highest_priority_level_;
+  std::set<std::size_t> priority_levels_set_;
 
   DISALLOW_COPY_AND_ASSIGN(Learner);
 };