Merge branch 'cassandra-3.0' into cassandra-3.5

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

Branch: refs/heads/trunk
Commit: faa9524a6858b55cf61209505902612dc90f310c
Parents: 950b1a3 b623e82
Author: Marcus Eriksson <marc...@apache.org>
Authored: Wed Mar 16 09:23:52 2016 +0100
Committer: Marcus Eriksson <marc...@apache.org>
Committed: Wed Mar 16 09:23:52 2016 +0100

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../writers/MaxSSTableSizeWriter.java           | 27 +++++++++++++-------
 2 files changed, 19 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/faa9524a/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 4a060d3,13c682f..70e65e4
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -7,8 -6,10 +7,9 @@@ Merged from 3.0
   * Fix filtering on non-primary key columns for queries without index 
(CASSANDRA-6377)
   * Fix sstableloader fail when using materialized view (CASSANDRA-11275)
  Merged from 2.2:
+  * Fix bloom filter sizing with LCS (CASSANDRA-11344)
   * (cqlsh) Fix error when result is 0 rows with EXPAND ON (CASSANDRA-11092)
   * Add missing newline at end of bin/cqlsh (CASSANDRA-11325)
 - * Fix AE in nodetool cfstats (backport CASSANDRA-10859) (CASSANDRA-11297)
   * Unresolved hostname leads to replace being ignored (CASSANDRA-11210)
   * Only log yaml config once, at startup (CASSANDRA-11217)
   * Reference leak with parallel repairs on the same table (CASSANDRA-11215)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/faa9524a/src/java/org/apache/cassandra/db/compaction/writers/MaxSSTableSizeWriter.java
----------------------------------------------------------------------
diff --cc 
src/java/org/apache/cassandra/db/compaction/writers/MaxSSTableSizeWriter.java
index 609c898,b206498..8c3ada7
--- 
a/src/java/org/apache/cassandra/db/compaction/writers/MaxSSTableSizeWriter.java
+++ 
b/src/java/org/apache/cassandra/db/compaction/writers/MaxSSTableSizeWriter.java
@@@ -32,7 -33,7 +33,6 @@@ import org.apache.cassandra.io.sstable.
  
  public class MaxSSTableSizeWriter extends CompactionAwareWriter
  {
-     private final long estimatedTotalKeys;
 -    private final long expectedWriteSize;
      private final long maxSSTableSize;
      private final int level;
      private final long estimatedSSTables;
@@@ -74,11 -63,27 +74,26 @@@
          this.allSSTables = txn.originals();
          this.level = level;
          this.maxSSTableSize = maxSSTableSize;
-         estimatedTotalKeys = 
SSTableReader.getApproximateKeyCount(nonExpiredSSTables);
-         estimatedSSTables = Math.max(1, estimatedTotalKeys / maxSSTableSize);
+ 
+         long totalSize = getTotalWriteSize(nonExpiredSSTables, 
estimatedTotalKeys, cfs, txn.opType());
 -        expectedWriteSize = Math.min(maxSSTableSize, totalSize);
+         estimatedSSTables = Math.max(1, totalSize / maxSSTableSize);
+     }
+ 
+     /**
+      * Gets the estimated total amount of data to write during compaction
+      */
+     private static long getTotalWriteSize(Iterable<SSTableReader> 
nonExpiredSSTables, long estimatedTotalKeys, ColumnFamilyStore cfs, 
OperationType compactionType)
+     {
+         long estimatedKeysBeforeCompaction = 0;
+         for (SSTableReader sstable : nonExpiredSSTables)
+             estimatedKeysBeforeCompaction += sstable.estimatedKeys();
+         estimatedKeysBeforeCompaction = Math.max(1, 
estimatedKeysBeforeCompaction);
+         double estimatedCompactionRatio = (double) estimatedTotalKeys / 
estimatedKeysBeforeCompaction;
++
+         return Math.round(estimatedCompactionRatio * 
cfs.getExpectedCompactedFileSize(nonExpiredSSTables, compactionType));
      }
  
 -    @Override
 -    public boolean realAppend(UnfilteredRowIterator partition)
 +    protected boolean realAppend(UnfilteredRowIterator partition)
      {
          RowIndexEntry rie = sstableWriter.append(partition);
          if (sstableWriter.currentWriter().getOnDiskFilePointer() > 
maxSSTableSize)
@@@ -103,11 -103,6 +118,5 @@@
                                                      txn);
  
          sstableWriter.switchWriter(writer);
 -
      }
- 
-     @Override
-     public long estimatedKeys()
-     {
-         return estimatedTotalKeys;
-     }
  }

Reply via email to