sstables: change make_descriptor() to accept fs::path

change another overload of `make_descriptor()` to accept `fs::path`,
in the same spirit of a previous change in this area. so we have
a more consistent API for creating sstable descriptor. and this
new API is simpler to use.

Refs #15187
Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
This commit is contained in:
Kefu Chai
2023-08-28 12:52:09 +08:00
parent 50c1d9aee7
commit a29838f9e1
3 changed files with 5 additions and 6 deletions

View File

@@ -34,7 +34,7 @@ struct entry_descriptor {
// Use the given ks and cf and don't attempt to extract it from the dir path.
// This allows loading sstables from any path, but the filename still has to be valid.
static entry_descriptor make_descriptor(sstring sstdir, sstring fname, sstring ks, sstring cf);
static entry_descriptor make_descriptor(const std::filesystem::path& sst_path, sstring ks, sstring cf);
entry_descriptor(std::string_view sstdir, sstring ks, sstring cf, generation_type generation,
sstable_version_types version, sstable_format_types format,

View File

@@ -2160,8 +2160,8 @@ entry_descriptor entry_descriptor::make_descriptor(const std::filesystem::path&
return make_entry_descriptor(sst_path.parent_path().native(), sst_path.filename().native(), nullptr, nullptr);
}
entry_descriptor entry_descriptor::make_descriptor(sstring sstdir, sstring fname, sstring ks, sstring cf) {
return make_entry_descriptor(sstdir, fname, &ks, &cf);
entry_descriptor entry_descriptor::make_descriptor(const std::filesystem::path& sst_path, sstring ks, sstring cf) {
return make_entry_descriptor(sst_path.parent_path().native(), sst_path.filename().native(), &ks, &cf);
}
sstable_version_types version_from_string(std::string_view s) {

View File

@@ -252,10 +252,9 @@ const std::vector<sstables::shared_sstable> load_sstables(schema_ptr schema, sst
}
}
const auto dir_path = sst_path.parent_path();
const auto sst_filename = sst_path.filename();
auto ed = sstables::entry_descriptor::make_descriptor(dir_path.c_str(), sst_filename.c_str(), schema->ks_name(), schema->cf_name());
auto ed = sstables::entry_descriptor::make_descriptor(sst_path, schema->ks_name(), schema->cf_name());
const auto dir_path = sst_path.parent_path();
data_dictionary::storage_options local;
auto sst = sst_man.make_sstable(schema, dir_path.c_str(), local, ed.generation, sstables::sstable_state::normal, ed.version, ed.format);