cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [9/22] git commit: rewrite to avoid bFound variable
Date Sat, 26 May 2012 05:25:45 GMT
rewrite to avoid bFound variable


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/853a7593
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/853a7593
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/853a7593

Branch: refs/heads/trunk
Commit: 853a75936c886136e9c7d5e0be42583e0305a6bd
Parents: 2717610
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Fri May 25 15:17:21 2012 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Fri May 25 16:15:24 2012 -0500

----------------------------------------------------------------------
 .../compaction/SizeTieredCompactionStrategy.java   |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/853a7593/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
b/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
index 747edcc..636d6ba 100644
--- a/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
+++ b/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
@@ -124,11 +124,11 @@ public class SizeTieredCompactionStrategy extends AbstractCompactionStrategy
 
         Map<Long, List<T>> buckets = new HashMap<Long, List<T>>();
 
+        outer:
         for (Pair<T, Long> pair: sortedFiles)
         {
             long size = pair.right;
 
-            boolean bFound = false;
             // look for a bucket containing similar-sized files:
             // group in the same bucket if it's w/in 50% of the average for this bucket,
             // or this file and the bucket are all considered "small" (less than `minSSTableSize`)
@@ -145,17 +145,14 @@ public class SizeTieredCompactionStrategy extends AbstractCompactionStrategy
                     long newAverageSize = (totalSize + size) / (bucket.size() + 1);
                     bucket.add(pair.left);
                     buckets.put(newAverageSize, bucket);
-                    bFound = true;
-                    break;
+                    continue outer;
                 }
             }
+
             // no similar bucket found; put it in a new one
-            if (!bFound)
-            {
-                ArrayList<T> bucket = new ArrayList<T>();
-                bucket.add(pair.left);
-                buckets.put(size, bucket);
-            }
+            ArrayList<T> bucket = new ArrayList<T>();
+            bucket.add(pair.left);
+            buckets.put(size, bucket);
         }
 
         return new ArrayList<List<T>>(buckets.values());


Mime
View raw message