You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2012/05/26 07:25:45 UTC
[9/22] git commit: rewrite to avoid bFound variable
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 <jb...@apache.org>
Authored: Fri May 25 15:17:21 2012 -0500
Committer: Jonathan Ellis <jb...@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());