From 853a75936c886136e9c7d5e0be42583e0305a6bd Mon Sep 17 00:00:00 2001 From: Jonathan Ellis Date: Fri, 25 May 2012 15:17:21 -0500 Subject: [PATCH] rewrite to avoid bFound variable --- .../compaction/SizeTieredCompactionStrategy.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java b/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java index 747edcca59..636d6ba152 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> buckets = new HashMap>(); + outer: for (Pair 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 bucket = new ArrayList(); - bucket.add(pair.left); - buckets.put(size, bucket); - } + ArrayList bucket = new ArrayList(); + bucket.add(pair.left); + buckets.put(size, bucket); } return new ArrayList>(buckets.values());