cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [09/11] git commit: add generation back to bucketing (filtering) sort
Date Tue, 29 Oct 2013 20:41:38 GMT
add generation back to bucketing (filtering) sort


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

Branch: refs/heads/cassandra-2.0
Commit: 9a9449406ede4e9efcd14de0fbc5c0e43272cee5
Parents: 3728530
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Tue Oct 29 15:36:10 2013 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Tue Oct 29 15:41:17 2013 -0500

----------------------------------------------------------------------
 .../db/compaction/SizeTieredCompactionStrategy.java      | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a944940/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 5115860..09d4e8e 100644
--- a/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
+++ b/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
@@ -90,7 +90,7 @@ public class SizeTieredCompactionStrategy extends AbstractCompactionStrategy
     @VisibleForTesting
     static List<SSTableReader> filterColdSSTables(List<SSTableReader> sstables,
double coldReadsToOmit)
     {
-        // sort the sstables by hotness (coldest-first), breaking ties with size on disk
(mainly for system tables and cold tables)
+        // sort the sstables by hotness (coldest-first)
         Collections.sort(sstables, new Comparator<SSTableReader>()
         {
             public int compare(SSTableReader o1, SSTableReader o2)
@@ -99,7 +99,14 @@ public class SizeTieredCompactionStrategy extends AbstractCompactionStrategy
                 if (comparison != 0)
                     return comparison;
 
-                return Long.compare(o1.bytesOnDisk(), o2.bytesOnDisk());
+                // break ties with size on disk (mainly for system tables and cold tables)
+                comparison = Long.compare(o1.bytesOnDisk(), o2.bytesOnDisk());
+                if (comparison != 0)
+                    return comparison;
+
+                // if there's still a tie, use generation, which is guaranteed to be unique.
 this ensures that
+                // our filtering is deterministic, which can be useful when debugging.
+                return o1.descriptor.generation - o2.descriptor.generation;
             }
         });
 


Mime
View raw message