diff --git a/mutation_compactor.hh b/mutation_compactor.hh index f0f1d46076..039aea62f1 100644 --- a/mutation_compactor.hh +++ b/mutation_compactor.hh @@ -54,6 +54,12 @@ GCC6_CONCEPT( }; ) +struct detached_compaction_state { + ::partition_start partition_start; + std::optional<::static_row> static_row; + std::deque 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 diff --git a/range_tombstone.hh b/range_tombstone.hh index 795239571f..94b1fad92d 100644 --- a/range_tombstone.hh +++ b/range_tombstone.hh @@ -263,6 +263,10 @@ public: return _range_tombstones; } + std::deque range_tombstones() && { + return std::move(_range_tombstones); + } + void apply(range_tombstone rt); void clear();