mutation_compactor: add detach_state()
Allow the state of the compaction to be detached. The detached state is a set of mutation fragments, which if replayed through a new compactor object will result in the latter being in the same state as the previous one was. This allows for storing the compaction state in the compacted reader by using `unpop_mutation_fragment()` to push back the fragments that comprise the detached state into the reader. This way, if a new compaction object is created it can just consume the reader and continue where the previous compaction left off.
This commit is contained in:
@@ -54,6 +54,12 @@ GCC6_CONCEPT(
|
||||
};
|
||||
)
|
||||
|
||||
struct detached_compaction_state {
|
||||
::partition_start partition_start;
|
||||
std::optional<::static_row> static_row;
|
||||
std::deque<range_tombstone> range_tombstones;
|
||||
};
|
||||
|
||||
// emit_only_live::yes will cause compact_for_query to emit only live
|
||||
// static and clustering rows. It doesn't affect the way range tombstones are
|
||||
// emitted.
|
||||
@@ -323,6 +329,18 @@ public:
|
||||
bool are_limits_reached() const {
|
||||
return _row_limit == 0 || _partition_limit == 0;
|
||||
}
|
||||
|
||||
/// Detach the internal state of the compactor
|
||||
///
|
||||
/// The state is represented by the last seen partition header, static row
|
||||
/// and active range tombstones. Replaying these fragments through a new
|
||||
/// compactor will result in the new compactor being in the same state *this
|
||||
/// is (given the same outside parameters of course). Practically this
|
||||
/// allows the compaction state to be stored in the compacted reader.
|
||||
detached_compaction_state detach_state() && {
|
||||
partition_start ps(std::move(_last_dk), _range_tombstones.get_partition_tombstone());
|
||||
return {std::move(ps), std::move(_last_static_row), std::move(_range_tombstones).range_tombstones()};
|
||||
}
|
||||
};
|
||||
|
||||
template<emit_only_live_rows OnlyLive, compact_for_sstables SSTableCompaction, typename Consumer>
|
||||
|
||||
@@ -263,6 +263,10 @@ public:
|
||||
return _range_tombstones;
|
||||
}
|
||||
|
||||
std::deque<range_tombstone> range_tombstones() && {
|
||||
return std::move(_range_tombstones);
|
||||
}
|
||||
|
||||
void apply(range_tombstone rt);
|
||||
|
||||
void clear();
|
||||
|
||||
Reference in New Issue
Block a user