|
27 | 27 | import org.apache.cassandra.db.AbstractCompactionController; |
28 | 28 | import org.apache.cassandra.db.ColumnFamilyStore; |
29 | 29 | import org.apache.cassandra.db.Directories; |
| 30 | +import org.apache.cassandra.db.compaction.writers.CompactionAwareWriter; |
30 | 31 | import org.apache.cassandra.db.lifecycle.ILifecycleTransaction; |
31 | 32 | import org.apache.cassandra.io.sstable.format.SSTableReader; |
32 | 33 | import org.apache.cassandra.utils.TimeUUID; |
33 | 34 |
|
34 | 35 | abstract class AbstractCompactionPipeline extends CompactionInfo.Holder implements AutoCloseable { |
35 | | - // Which pipeline each compaction selected, as a delta across one compaction. Read by |
36 | | - // CompactionPipelineCounts (test), which documents why supportability alone cannot establish it. |
| 36 | + // Pipeline selection counts, read only by CompactionPipelineCounts in the test tree. |
37 | 37 | private static final LongAdder CURSOR_PIPELINES_CREATED = new LongAdder(); |
38 | 38 | private static final LongAdder ITERATOR_PIPELINES_CREATED = new LongAdder(); |
39 | 39 |
|
@@ -66,27 +66,70 @@ static AbstractCompactionPipeline create( |
66 | 66 | return new IteratorCompactionPipeline(task, type, scanners, controller, nowInSec, compactionId); |
67 | 67 | } |
68 | 68 |
|
| 69 | + final CompactionTask task; |
| 70 | + long totalKeysWritten; |
| 71 | + CompactionAwareWriter writer; |
| 72 | + |
| 73 | + AbstractCompactionPipeline(CompactionTask task) |
| 74 | + { |
| 75 | + this.task = task; |
| 76 | + } |
| 77 | + |
| 78 | + /** |
| 79 | + * The object that does the work. It owns the progress and the stop flag this pipeline reports, |
| 80 | + * so a subclass must not keep a second copy of either. |
| 81 | + */ |
| 82 | + abstract CompactionInfo.Holder delegate(); |
| 83 | + |
| 84 | + @Override |
| 85 | + public CompactionInfo getCompactionInfo() |
| 86 | + { |
| 87 | + return delegate().getCompactionInfo(); |
| 88 | + } |
| 89 | + |
| 90 | + @Override |
| 91 | + public boolean isGlobal() |
| 92 | + { |
| 93 | + return delegate().isGlobal(); |
| 94 | + } |
| 95 | + |
| 96 | + public void stop() |
| 97 | + { |
| 98 | + delegate().stop(); |
| 99 | + } |
| 100 | + |
69 | 101 | abstract boolean processNextPartitionKey() throws IOException; |
70 | 102 |
|
71 | 103 | public abstract long[] getMergedRowCounts(); |
72 | 104 |
|
73 | 105 | public abstract long getTotalSourceCQLRows(); |
74 | 106 |
|
75 | | - public abstract long getTotalKeysWritten(); |
76 | | - |
77 | 107 | public abstract long getTotalBytesScanned(); |
78 | 108 |
|
79 | | - public abstract AutoCloseable openWriterResource(ColumnFamilyStore cfs, |
80 | | - Directories directories, |
81 | | - ILifecycleTransaction transaction, |
82 | | - Set<SSTableReader> nonExpiredSSTables); |
83 | | - |
84 | 109 | @Override |
85 | 110 | public abstract void close() throws IOException; |
86 | 111 |
|
87 | | - public abstract Collection<SSTableReader> finishWriting(); |
| 112 | + public AutoCloseable openWriterResource(ColumnFamilyStore cfs, |
| 113 | + Directories directories, |
| 114 | + ILifecycleTransaction transaction, |
| 115 | + Set<SSTableReader> nonExpiredSSTables) |
| 116 | + { |
| 117 | + this.writer = task.getCompactionAwareWriter(cfs, directories, transaction, nonExpiredSSTables); |
| 118 | + return writer; |
| 119 | + } |
88 | 120 |
|
89 | | - public abstract long estimatedKeys(); |
| 121 | + public Collection<SSTableReader> finishWriting() |
| 122 | + { |
| 123 | + return writer.finish(); |
| 124 | + } |
| 125 | + |
| 126 | + public long estimatedKeys() |
| 127 | + { |
| 128 | + return writer.estimatedKeys(); |
| 129 | + } |
90 | 130 |
|
91 | | - public abstract void stop(); |
| 131 | + public long getTotalKeysWritten() |
| 132 | + { |
| 133 | + return totalKeysWritten; |
| 134 | + } |
92 | 135 | } |
0 commit comments