cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbros...@apache.org
Subject cassandra git commit: avoid double map lookup in loop
Date Sun, 17 Jul 2016 23:40:46 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 70fd80ae4 -> 0a5603789


avoid double map lookup in loop


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

Branch: refs/heads/trunk
Commit: 0a5603789d09a946a22f6928269590c284d80e40
Parents: 70fd80a
Author: Dave Brosius <dbrosius@mebigfatguy.com>
Authored: Sun Jul 17 19:40:15 2016 -0400
Committer: Dave Brosius <dbrosius@mebigfatguy.com>
Committed: Sun Jul 17 19:40:15 2016 -0400

----------------------------------------------------------------------
 .../cassandra/db/compaction/LeveledCompactionStrategy.java   | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/0a560378/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java b/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java
index 3f57fe0..ec5e1d9 100644
--- a/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java
+++ b/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java
@@ -179,11 +179,13 @@ public class LeveledCompactionStrategy extends AbstractCompactionStrategy
         for (SSTableReader sstable : ssTablesToGroup)
         {
             Integer level = sstable.getSSTableLevel();
-            if (!sstablesByLevel.containsKey(level))
+            Collection<SSTableReader> sstablesForLevel = sstablesByLevel.get(level);
+            if (sstablesForLevel == null)
             {
-                sstablesByLevel.put(level, new ArrayList<SSTableReader>());
+                sstablesForLevel = new ArrayList<SSTableReader>();
+                sstablesByLevel.put(level, sstablesForLevel);
             }
-            sstablesByLevel.get(level).add(sstable);
+            sstablesForLevel.add(sstable);
         }
 
         Collection<Collection<SSTableReader>> groupedSSTables = new ArrayList<>();


Mime
View raw message