aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zma...@apache.org
Subject aurora git commit: Do not create a set inside DbTaskStore#fetchTasks.
Date Fri, 19 Feb 2016 20:49:23 GMT
Repository: aurora
Updated Branches:
  refs/heads/master 9d642dcfa -> 8501d8219


Do not create a set inside DbTaskStore#fetchTasks.

The TaskStore interface allows for an Iterable to be returned. Taking advantage
of this and returning the list MyBatis creates results in a performance
improvement.

Reviewed at https://reviews.apache.org/r/43643/


Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/8501d821
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/8501d821
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/8501d821

Branch: refs/heads/master
Commit: 8501d821973bacb1411915fe7a39ef95de82864f
Parents: 9d642dc
Author: Zameer Manji <zmanji@apache.org>
Authored: Fri Feb 19 12:49:02 2016 -0800
Committer: Zameer Manji <zmanji@apache.org>
Committed: Fri Feb 19 12:49:02 2016 -0800

----------------------------------------------------------------------
 .../org/apache/aurora/scheduler/storage/db/DbTaskStore.java | 4 ++--
 .../aurora/scheduler/storage/AbstractTaskStoreTest.java     | 9 ++++++++-
 2 files changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/8501d821/src/main/java/org/apache/aurora/scheduler/storage/db/DbTaskStore.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/DbTaskStore.java b/src/main/java/org/apache/aurora/scheduler/storage/db/DbTaskStore.java
index b899d0f..078dd8b 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/DbTaskStore.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/db/DbTaskStore.java
@@ -89,13 +89,13 @@ class DbTaskStore implements TaskStore.Mutable {
 
   @Timed("db_storage_fetch_tasks")
   @Override
-  public ImmutableSet<IScheduledTask> fetchTasks(Builder query) {
+  public Iterable<IScheduledTask> fetchTasks(Builder query) {
     requireNonNull(query);
 
     // TODO(wfarner): Consider making slow query logging more reusable, or pushing it down
into the
     //                database.
     long start = clock.nowNanos();
-    ImmutableSet<IScheduledTask> result = matches(query).toSet();
+    Iterable<IScheduledTask> result = matches(query);
     long durationNanos = clock.nowNanos() - start;
     boolean infoLevel = durationNanos >= slowQueryThresholdNanos;
     long time = Amount.of(durationNanos, Time.NANOSECONDS).as(Time.MILLISECONDS);

http://git-wip-us.apache.org/repos/asf/aurora/blob/8501d821/src/test/java/org/apache/aurora/scheduler/storage/AbstractTaskStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/AbstractTaskStoreTest.java
b/src/test/java/org/apache/aurora/scheduler/storage/AbstractTaskStoreTest.java
index dee34e2..dc5e2bd 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/AbstractTaskStoreTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/AbstractTaskStoreTest.java
@@ -22,6 +22,7 @@ import java.util.concurrent.TimeUnit;
 
 import com.google.common.base.Optional;
 import com.google.common.collect.FluentIterable;
+import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Maps;
@@ -564,7 +565,13 @@ public abstract class AbstractTaskStoreTest extends TearDownTestCase
{
   }
 
   private void assertQueryResults(Query.Builder query, Set<IScheduledTask> tasks) {
-    assertEquals(tasks, fetchTasks(query));
+    Iterable<IScheduledTask> result = fetchTasks(query);
+    assertQueryHasNoDupes(result);
+    assertEquals(tasks, ImmutableSet.copyOf(fetchTasks(query)));
+  }
+
+  private void assertQueryHasNoDupes(Iterable<IScheduledTask> result) {
+    assertEquals(ImmutableList.copyOf(result).size(), ImmutableSet.copyOf(result).size());
   }
 
   private static IScheduledTask createTask(String id) {


Mime
View raw message