From eeb0d637bbbf0aa1a341783dfb71f6a618c762cb Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Mon, 21 Oct 2024 14:25:36 +0300 Subject: [PATCH] replica,sstables: Move format_table_directory_name() Now this helper is not needed in replica code, as all manipulations of tables' sstables now sit in the sstables/storage.cc. Signed-off-by: Pavel Emelyanov --- replica/database.cc | 7 ------- replica/database.hh | 6 ++---- sstables/storage.cc | 10 ++++++++-- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/replica/database.cc b/replica/database.cc index 3b67b3d150..10b2d34305 100644 --- a/replica/database.cc +++ b/replica/database.cc @@ -31,7 +31,6 @@ #include #include #include -#include #include "sstables/sstables.hh" #include "sstables/sstables_manager.hh" #include @@ -2555,12 +2554,6 @@ std::pair parse_table_directory_name(const sstring& directory return std::make_pair(directory_name.substr(0, pos), table_id(utils::UUID(directory_name.substr(pos + 1)))); } -sstring format_table_directory_name(sstring name, table_id id) { - auto uuid_sstring = id.to_sstring(); - boost::erase_all(uuid_sstring, "-"); - return format("{}-{}", name, uuid_sstring); -} - future> database::get_snapshot_details() { std::vector data_dirs = _cfg.data_file_directories(); std::unordered_map details; diff --git a/replica/database.hh b/replica/database.hh index 6ab60c6dd3..7761abed50 100644 --- a/replica/database.hh +++ b/replica/database.hh @@ -1891,10 +1891,8 @@ public: future<> clear_inactive_reads_for_tablet(table_id table, dht::token_range tablet_range); }; -// A pair of helper functions to make directory name for a table -// out of its name and uuid, and to parse the directory name back -// into name and uuid of the table -sstring format_table_directory_name(sstring name, table_id id); +// A helper function to parse the directory name back +// into name and uuid of the table (see format_table_directory_name()) std::pair parse_table_directory_name(const sstring&); } // namespace replica diff --git a/sstables/storage.cc b/sstables/storage.cc index aa8a17a931..24e2caf6d1 100644 --- a/sstables/storage.cc +++ b/sstables/storage.cc @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -33,7 +34,6 @@ #include "utils/s3/client.hh" #include "utils/exceptions.hh" #include "utils/to_string.hh" -#include "replica/database.hh" // need to move format_table_directory_name here eventually #include "checked-file-impl.hh" @@ -681,10 +681,16 @@ std::unique_ptr make_storage(sstables_manager& manager, const }, s_opts.value); } +static sstring format_table_directory_name(sstring name, table_id id) { + auto uuid_sstring = id.to_sstring(); + boost::erase_all(uuid_sstring, "-"); + return format("{}-{}", name, uuid_sstring); +} + future> init_table_storage(const sstables_manager& mgr, const schema& s, const data_dictionary::storage_options::local& so) { std::vector dirs; for (const auto& dd : mgr.config().data_file_directories()) { - auto dir = format("{}/{}/{}", dd, s.ks_name(), replica::format_table_directory_name(s.cf_name(), s.id())); + auto dir = format("{}/{}/{}", dd, s.ks_name(), format_table_directory_name(s.cf_name(), s.id())); dirs.emplace_back(std::move(dir)); } co_await coroutine::parallel_for_each(dirs, [] (sstring dir) -> future<> {