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 2013/10/29 21:41:32 UTC

[03/11] git commit: add generation back to bucketing (filtering) sort

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/e5066514
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/e5066514
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/e5066514

Branch: refs/heads/trunk
Commit: e5066514f4405ef0e1ba839339dc3eceece479f7
Parents: 786672e
Author: Jonathan Ellis <jb...@apache.org>
Authored: Tue Oct 29 15:36:10 2013 -0500
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Tue Oct 29 15:36:10 2013 -0500

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


http://git-wip-us.apache.org/repos/asf/cassandra/blob/e5066514/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;
             }
         });