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/30 16:18:30 UTC
[02/10] 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/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/trunk
Commit: 9a9449406ede4e9efcd14de0fbc5c0e43272cee5
Parents: 3728530
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: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;
}
});