/* * Copyright (C) 2022-present ScyllaDB */ /* * SPDX-License-Identifier: AGPL-3.0-or-later */ #pragma once #include #include "frozen_mutation.hh" #include #include #include "repair/decorated_key_with_hash.hh" #include "repair/hash.hh" #include "repair/sync_boundary.hh" using namespace seastar; using is_dirty_on_master = bool_class; class decorated_key_with_hash; class repair_hash; class repair_row { std::optional _fm; lw_shared_ptr _dk_with_hash; std::optional _boundary; std::optional _hash; is_dirty_on_master _dirty_on_master; lw_shared_ptr _mf; public: repair_row() = default; repair_row(std::optional fm, std::optional pos, lw_shared_ptr dk_with_hash, std::optional hash, is_dirty_on_master dirty_on_master, lw_shared_ptr mf = {}) : _fm(std::move(fm)) , _dk_with_hash(std::move(dk_with_hash)) , _boundary(pos ? std::optional(repair_sync_boundary{_dk_with_hash->dk, std::move(*pos)}) : std::nullopt) , _hash(std::move(hash)) , _dirty_on_master(dirty_on_master) , _mf(std::move(mf)) { } lw_shared_ptr& get_mutation_fragment_ptr() { return _mf; } mutation_fragment& get_mutation_fragment() { if (!_mf) { throw std::runtime_error("empty mutation_fragment"); } return *_mf; } frozen_mutation_fragment& get_frozen_mutation() { if (!_fm) { throw std::runtime_error("empty frozen_mutation_fragment"); } return *_fm; } const frozen_mutation_fragment& get_frozen_mutation() const { if (!_fm) { throw std::runtime_error("empty frozen_mutation_fragment"); } return *_fm; } const lw_shared_ptr& get_dk_with_hash() const { return _dk_with_hash; } size_t size() const { if (!_fm) { throw std::runtime_error("empty size due to empty frozen_mutation_fragment"); } return _fm->representation().size(); } const repair_sync_boundary& boundary() const { if (!_boundary) { throw std::runtime_error("empty repair_sync_boundary"); } return *_boundary; } const repair_hash& hash() const { if (!_hash) { throw std::runtime_error("empty hash"); } return *_hash; } is_dirty_on_master dirty_on_master() const { return _dirty_on_master; } future<> clear_gently() noexcept { if (_fm) { co_await _fm->clear_gently(); _fm.reset(); } _dk_with_hash = {}; _boundary.reset(); _hash.reset(); _mf = {}; } };