Fix total bytes count for parallel compaction

patch by slebresne; reviewed by jbellis for CASSANDRA-3758
This commit is contained in:
Sylvain Lebresne 2012-03-30 16:19:27 +02:00
parent 7326ba8879
commit 3931ee709d
4 changed files with 14 additions and 11 deletions

View File

@ -15,6 +15,7 @@
tasks and upgradesstables (CASSANDRA-3985)
* fix NPE on invalid CQL delete command (CASSANDRA-3755)
* allow custom types in CLI's assume command (CASSANDRA-4081)
* Fix totalBytes count for parallel compactions (CASSANDRA-3758)
1.0.8

View File

@ -41,15 +41,24 @@ public abstract class AbstractCompactionIterable implements Iterable<AbstractCom
protected final OperationType type;
protected final CompactionController controller;
protected long totalBytes;
protected final long totalBytes;
protected volatile long bytesRead;
protected final List<SSTableScanner> scanners;
protected final Throttle throttle;
public AbstractCompactionIterable(CompactionController controller, OperationType type)
public AbstractCompactionIterable(CompactionController controller, OperationType type, List<SSTableScanner> scanners)
{
this.controller = controller;
this.type = type;
this.scanners = scanners;
this.bytesRead = 0;
long bytes = 0;
for (SSTableScanner scanner : scanners)
bytes += scanner.getFileLength();
this.totalBytes = bytes;
this.throttle = new Throttle(toString(), new Throttle.ThroughputFunction()
{
/** @return Instantaneous throughput target in bytes per millisecond. */

View File

@ -41,7 +41,6 @@ public class CompactionIterable extends AbstractCompactionIterable
private static Logger logger = LoggerFactory.getLogger(CompactionIterable.class);
private long row;
private final List<SSTableScanner> scanners;
private static final Comparator<IColumnIterator> comparator = new Comparator<IColumnIterator>()
{
@ -58,12 +57,8 @@ public class CompactionIterable extends AbstractCompactionIterable
protected CompactionIterable(OperationType type, List<SSTableScanner> scanners, CompactionController controller)
{
super(controller, type);
this.scanners = scanners;
super(controller, type, scanners);
row = 0;
totalBytes = bytesRead = 0;
for (SSTableScanner scanner : scanners)
totalBytes += scanner.getFileLength();
}
protected static List<SSTableScanner> getScanners(Iterable<SSTableReader> sstables) throws IOException

View File

@ -59,7 +59,6 @@ public class ParallelCompactionIterable extends AbstractCompactionIterable
{
private static Logger logger = LoggerFactory.getLogger(ParallelCompactionIterable.class);
private final List<SSTableScanner> scanners;
private final int maxInMemorySize;
public ParallelCompactionIterable(OperationType type, Iterable<SSTableReader> sstables, CompactionController controller) throws IOException
@ -74,8 +73,7 @@ public class ParallelCompactionIterable extends AbstractCompactionIterable
protected ParallelCompactionIterable(OperationType type, List<SSTableScanner> scanners, CompactionController controller, int maxInMemorySize)
{
super(controller, type);
this.scanners = scanners;
super(controller, type, scanners);
this.maxInMemorySize = maxInMemorySize;
}