diff --git a/replica/compaction_group.hh b/replica/compaction_group.hh index ca8c27854b..697c8ab6d7 100644 --- a/replica/compaction_group.hh +++ b/replica/compaction_group.hh @@ -273,7 +273,6 @@ public: virtual compaction_group& compaction_group_for_key(partition_key_view key, const schema_ptr& s) const noexcept = 0; virtual compaction_group& compaction_group_for_sstable(const sstables::shared_sstable& sst) const noexcept = 0; - virtual std::pair storage_group_of(dht::token) const = 0; virtual size_t log2_storage_groups() const = 0; virtual storage_group* storage_group_for_token(dht::token) const noexcept = 0; diff --git a/replica/database.hh b/replica/database.hh index 3d1f92ff9a..d006c52273 100644 --- a/replica/database.hh +++ b/replica/database.hh @@ -589,8 +589,7 @@ private: // that were previously split. future<> handle_tablet_split_completion(size_t old_tablet_count, const locator::tablet_map& new_tmap); - // Select a compaction group from a given token. - std::pair storage_group_of(dht::token token) const noexcept; + // Select a storage group from a given token. storage_group* storage_group_for_token(dht::token token) const noexcept; // FIXME: Cannot return nullptr, signature can be changed to return storage_group&. storage_group* storage_group_for_id(size_t i) const; diff --git a/replica/table.cc b/replica/table.cc index 1d99db184b..85c4f6ea02 100644 --- a/replica/table.cc +++ b/replica/table.cc @@ -615,9 +615,6 @@ public: compaction_group& compaction_group_for_sstable(const sstables::shared_sstable& sst) const noexcept override { return get_compaction_group(); } - std::pair storage_group_of(dht::token) const override { - return {0, locator::tablet_range_side{}}; - } size_t log2_storage_groups() const override { return 0; } @@ -676,6 +673,23 @@ private: size_t tablet_id_for_token(dht::token t) const noexcept { return tablet_map().get_tablet_id(t).value(); } + + std::pair storage_group_of(dht::token t) const { + auto [id, side] = tablet_map().get_tablet_id_and_range_side(t); + auto idx = id.value(); +#ifndef SCYLLA_BUILD_MODE_RELEASE + if (idx >= tablet_count()) { + on_fatal_internal_error(tlogger, format("storage_group_of: index out of range: idx={} size_log2={} size={} token={}", + idx, log2_storage_groups(), tablet_count(), t)); + } + auto* sg = storage_group_for_id(idx); + if (!t.is_minimum() && !t.is_maximum() && sg && !sg->token_range().contains(t, dht::token_comparator())) { + on_fatal_internal_error(tlogger, format("storage_group_of: storage_group idx={} range={} does not contain token={}", + idx, sg->token_range(), t)); + } +#endif + return { idx, side }; + } public: tablet_storage_group_manager(table& t, const locator::effective_replication_map& erm) : _t(t) @@ -706,22 +720,6 @@ public: compaction_group& compaction_group_for_key(partition_key_view key, const schema_ptr& s) const noexcept override; compaction_group& compaction_group_for_sstable(const sstables::shared_sstable& sst) const noexcept override; - std::pair storage_group_of(dht::token t) const override { - auto [id, side] = tablet_map().get_tablet_id_and_range_side(t); - auto idx = id.value(); -#ifndef SCYLLA_BUILD_MODE_RELEASE - if (idx >= tablet_count()) { - on_fatal_internal_error(tlogger, format("storage_group_of: index out of range: idx={} size_log2={} size={} token={}", - idx, log2_storage_groups(), tablet_count(), t)); - } - auto* sg = storage_group_for_id(idx); - if (!t.is_minimum() && !t.is_maximum() && sg && !sg->token_range().contains(t, dht::token_comparator())) { - on_fatal_internal_error(tlogger, format("storage_group_of: storage_group idx={} range={} does not contain token={}", - idx, sg->token_range(), t)); - } -#endif - return { idx, side }; - } size_t log2_storage_groups() const override { return log2ceil(tablet_map().tablet_count()); } @@ -902,11 +900,6 @@ compaction_group* table::get_compaction_group(size_t id) const noexcept { return storage_group_for_id(id)->main_compaction_group().get(); } -std::pair -table::storage_group_of(dht::token token) const noexcept { - return _sg_manager->storage_group_of(token); -} - storage_group* table::storage_group_for_token(dht::token token) const noexcept { return _sg_manager->storage_group_for_token(token); }