diff --git a/sstables/index_entry.hh b/sstables/index_entry.hh index 05c4db595f..e8af227af1 100644 --- a/sstables/index_entry.hh +++ b/sstables/index_entry.hh @@ -27,6 +27,44 @@ namespace sstables { +class promoted_index_block { +public: + promoted_index_block(temporary_buffer&& start, temporary_buffer&& end, + uint64_t offset, uint64_t width) + : _start(std::move(start)), _end(std::move(end)) + , _offset(offset), _width(width) + {} + promoted_index_block(const promoted_index_block& rhs) + : _start(rhs._start.get(), rhs._start.size()), _end(rhs._end.get(), rhs._end.size()) + , _offset(rhs._offset), _width(rhs._width) + {} + promoted_index_block(promoted_index_block&&) noexcept = default; + + promoted_index_block& operator=(const promoted_index_block& rhs) { + if (this != &rhs) { + _start = temporary_buffer(rhs._start.get(), rhs._start.size()); + _end = temporary_buffer(rhs._end.get(), rhs._end.size()); + _offset = rhs._offset; + _width = rhs._width; + } + return *this; + } + promoted_index_block& operator=(promoted_index_block&&) noexcept = default; + + composite_view start(const schema& s) const { return composite_view(to_bytes_view(_start), s.is_compound());} + composite_view end(const schema& s) const { return composite_view(to_bytes_view(_end), s.is_compound());} + uint64_t offset() const { return _offset; } + uint64_t width() const { return _width; } + +private: + temporary_buffer _start; + temporary_buffer _end; + uint64_t _offset; + uint64_t _width; +}; + +using promoted_index_blocks = seastar::circular_buffer; + inline void erase_all_but_last(promoted_index_blocks& pi_blocks) { while (pi_blocks.size() > 1) { pi_blocks.pop_front(); diff --git a/sstables/types.hh b/sstables/types.hh index 7b1e370f88..78315d9d8b 100644 --- a/sstables/types.hh +++ b/sstables/types.hh @@ -111,44 +111,6 @@ enum class indexable_element { cell }; -class promoted_index_block { -public: - promoted_index_block(temporary_buffer&& start, temporary_buffer&& end, - uint64_t offset, uint64_t width) - : _start(std::move(start)), _end(std::move(end)) - , _offset(offset), _width(width) - {} - promoted_index_block(const promoted_index_block& rhs) - : _start(rhs._start.get(), rhs._start.size()), _end(rhs._end.get(), rhs._end.size()) - , _offset(rhs._offset), _width(rhs._width) - {} - promoted_index_block(promoted_index_block&&) noexcept = default; - - promoted_index_block& operator=(const promoted_index_block& rhs) { - if (this != &rhs) { - _start = temporary_buffer(rhs._start.get(), rhs._start.size()); - _end = temporary_buffer(rhs._end.get(), rhs._end.size()); - _offset = rhs._offset; - _width = rhs._width; - } - return *this; - } - promoted_index_block& operator=(promoted_index_block&&) noexcept = default; - - composite_view start(const schema& s) const { return composite_view(to_bytes_view(_start), s.is_compound());} - composite_view end(const schema& s) const { return composite_view(to_bytes_view(_end), s.is_compound());} - uint64_t offset() const { return _offset; } - uint64_t width() const { return _width; } - -private: - temporary_buffer _start; - temporary_buffer _end; - uint64_t _offset; - uint64_t _width; -}; - -using promoted_index_blocks = seastar::circular_buffer; - class summary_entry { public: dht::token_view token;