diff --git a/sstables/sstable_directory.cc b/sstables/sstable_directory.cc index 0327885f41..9665301a87 100644 --- a/sstables/sstable_directory.cc +++ b/sstables/sstable_directory.cc @@ -173,63 +173,41 @@ future sstable_directory::load_sstable(sstables::entry co_return sst; } -future sstable_directory::load_sstable(sstables::entry_descriptor desc, process_flags flags) const { - auto sst = co_await load_sstable(std::move(desc), flags.sstable_open_config); - validate(sst, flags); - if (flags.need_mutate_level) { - dirlog.trace("Mutating {} to level 0\n", sst->get_filename()); - co_await sst->mutate_sstable_level(0); - } - co_return sst; -} - future<> sstable_directory::process_descriptor(sstables::entry_descriptor desc, process_flags flags) { if (desc.version > _max_version_seen) { _max_version_seen = desc.version; } - if (flags.sort_sstables_according_to_owner) { - co_await sort_sstable(std::move(desc), flags); - } else { - dirlog.debug("Added {} to unsorted sstables list", sstable_filename(desc)); - _unsorted_sstables.push_back(co_await load_sstable(std::move(desc), flags)); - } -} - -future> sstable_directory::get_shards_for_this_sstable(const sstables::entry_descriptor& desc, process_flags flags) const { - auto sst = _manager.make_sstable(_schema, _table_dir, *_storage_opts, desc.generation, _state, desc.version, desc.format, gc_clock::now(), _error_handler_gen); - co_await sst->load_owner_shards(_sharder); + auto sst = co_await load_sstable(desc, flags.sstable_open_config); validate(sst, flags); - co_return sst->get_shards_for_this_sstable(); -} -future sstable_directory::get_open_info_for_this_sstable(const sstables::entry_descriptor& desc) const { - auto sst = co_await load_sstable(std::move(desc)); - co_return co_await sst->get_open_info(); -} + if (flags.need_mutate_level) { + dirlog.trace("Mutating {} to level 0\n", sst->get_filename()); + co_await sst->mutate_sstable_level(0); + } -future<> -sstable_directory::sort_sstable(sstables::entry_descriptor desc, process_flags flags) { - auto shards = co_await get_shards_for_this_sstable(desc, flags); + if (!flags.sort_sstables_according_to_owner) { + dirlog.debug("Added {} to unsorted sstables list", sst->get_filename()); + _unsorted_sstables.push_back(std::move(sst)); + co_return; + } + + auto shards = sst->get_shards_for_this_sstable(); if (shards.size() == 1) { if (shards[0] == this_shard_id()) { - dirlog.trace("{} identified as a local unshared SSTable", sstable_filename(desc)); - _unshared_local_sstables.push_back(co_await load_sstable(std::move(desc), flags)); + dirlog.trace("{} identified as a local unshared SSTable", sst->get_filename()); + _unshared_local_sstables.push_back(std::move(sst)); } else { - dirlog.trace("{} identified as a remote unshared SSTable, shard={}", sstable_filename(desc), shards[0]); + dirlog.trace("{} identified as a remote unshared SSTable, shard={}", sst->get_filename(), shards[0]); _unshared_remote_sstables[shards[0]].push_back(std::move(desc)); } } else { - dirlog.trace("{} identified as a shared SSTable, shards={}", sstable_filename(desc), shards); - _shared_sstable_info.push_back(co_await get_open_info_for_this_sstable(desc)); + dirlog.trace("{} identified as a shared SSTable, shards={}", sst->get_filename(), shards); + _shared_sstable_info.push_back(co_await sst->get_open_info()); } } -sstring sstable_directory::sstable_filename(const sstables::entry_descriptor& desc) const { - return sstable::filename(make_path(_table_dir, _state).native(), _schema->ks_name(), _schema->cf_name(), desc.version, desc.generation, desc.format, component_type::Data); -} - generation_type sstable_directory::highest_generation_seen() const { return _max_generation_seen; diff --git a/sstables/sstable_directory.hh b/sstables/sstable_directory.hh index 044e85851b..06dd0a7de0 100644 --- a/sstables/sstable_directory.hh +++ b/sstables/sstable_directory.hh @@ -177,21 +177,9 @@ private: future<> process_descriptor(sstables::entry_descriptor desc, process_flags flags); void validate(sstables::shared_sstable sst, process_flags flags) const; future load_sstable(sstables::entry_descriptor desc, sstables::sstable_open_config cfg = {}) const; - future load_sstable(sstables::entry_descriptor desc, process_flags flags) const; future<> load_foreign_sstables(sstable_entry_descriptor_vector info_vec); - // Sort the sstable according to owner - future<> sort_sstable(sstables::entry_descriptor desc, process_flags flags); - - // Returns filename for a SSTable from its entry_descriptor. - sstring sstable_filename(const sstables::entry_descriptor& desc) const; - - // Compute owner of shards for a particular SSTable. - future> get_shards_for_this_sstable(const sstables::entry_descriptor& desc, process_flags flags) const; - // Retrieves sstables::foreign_sstable_open_info for a particular SSTable. - future get_open_info_for_this_sstable(const sstables::entry_descriptor& desc) const; - sstable_directory(sstables_manager& manager, schema_ptr schema, std::variant, const dht::sharder*> sharder,