avoid using global partitioner to estimate ranges in index sstables patch by jbellis; reviewed by yukim for CASSANDRA-4403
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/be969899 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/be969899 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/be969899 Branch: refs/heads/cassandra-1.1 Commit: be969899c954751f861b3861b3b709be56270ccd Parents: 67dec69 Author: Jonathan Ellis <jbel...@apache.org> Authored: Mon Jul 2 17:08:36 2012 -0500 Committer: Jonathan Ellis <jbel...@apache.org> Committed: Tue Jul 3 12:01:10 2012 -0500 ---------------------------------------------------------------------- CHANGES.txt | 2 + .../org/apache/cassandra/db/ColumnFamilyStore.java | 28 +++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/be969899/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 72991f1..7cd12a5 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,6 @@ 1.1.3 + * avoid using global partitioner to estimate ranges in index sstables + (CASSANDRA-4403) * restore pre-CASSANDRA-3862 approach to removing expired tombstones from row cache during compaction (CASSANDRA-4364) * (stress) support for CQL prepared statements (CASSANDRA-3633) http://git-wip-us.apache.org/repos/asf/cassandra/blob/be969899/src/java/org/apache/cassandra/db/ColumnFamilyStore.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java index 93f022d..0b66020 100644 --- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java +++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java @@ -904,9 +904,10 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean /** * Calculate expected file size of SSTable after compaction. * - * If operation type is {@code CLEANUP}, then we calculate expected file size - * with checking token range to be eliminated. - * Other than that, we just add up all the files' size, which is the worst case file + * If operation type is {@code CLEANUP} and we're not dealing with an index sstable, + * then we calculate expected file size with checking token range to be eliminated. + * + * Otherwise, we just add up all the files' size, which is the worst case file * size for compaction of all the list of files given. * * @param sstables SSTables to calculate expected compacted file size @@ -915,21 +916,18 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean */ public long getExpectedCompactedFileSize(Iterable<SSTableReader> sstables, OperationType operation) { - long expectedFileSize = 0; - if (operation == OperationType.CLEANUP) + if (operation != OperationType.CLEANUP || isIndex()) { - Collection<Range<Token>> ranges = StorageService.instance.getLocalRanges(table.name); - for (SSTableReader sstable : sstables) - { - List<Pair<Long, Long>> positions = sstable.getPositionsForRanges(ranges); - for (Pair<Long, Long> position : positions) - expectedFileSize += position.right - position.left; - } + return SSTable.getTotalBytes(sstables); } - else + + long expectedFileSize = 0; + Collection<Range<Token>> ranges = StorageService.instance.getLocalRanges(table.name); + for (SSTableReader sstable : sstables) { - for (SSTableReader sstable : sstables) - expectedFileSize += sstable.onDiskLength(); + List<Pair<Long, Long>> positions = sstable.getPositionsForRanges(ranges); + for (Pair<Long, Long> position : positions) + expectedFileSize += position.right - position.left; } return expectedFileSize; }