From dcc9167734c2bdffe714be4fbcbde71c5367e9eb Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Thu, 6 Mar 2025 15:15:49 +0300 Subject: [PATCH] sstables: Rename filename($component) calls to ${component}_filename() There's a generic sstable::filename(component_type) method that returns a file name for the given component. For "popular" components, namely TOC, Data and Index there are dedicated sstable methods to get their names. Fix existing callers of the generic method to use the former. It's shorter, nicer and makes further patching simpler. Signed-off-by: Pavel Emelyanov --- sstables/mx/writer.cc | 6 +++--- sstables/sstables.cc | 6 +++--- test/lib/sstable_utils.hh | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sstables/mx/writer.cc b/sstables/mx/writer.cc index cf33e151ad..68f8640528 100644 --- a/sstables/mx/writer.cc +++ b/sstables/mx/writer.cc @@ -884,17 +884,17 @@ void writer::init_file_writers() { auto out = _sst._storage->make_data_or_index_sink(_sst, component_type::Data).get(); if (!_compression_enabled) { - _data_writer = std::make_unique(std::move(out), _sst.sstable_buffer_size, _sst.filename(component_type::Data)); + _data_writer = std::make_unique(std::move(out), _sst.sstable_buffer_size, _sst.get_filename()); } else { _data_writer = std::make_unique( make_compressed_file_m_format_output_stream( output_stream(std::move(out)), &_sst._components->compression, - _sst._schema->get_compressor_params()), _sst.filename(component_type::Data)); + _sst._schema->get_compressor_params()), _sst.get_filename()); } out = _sst._storage->make_data_or_index_sink(_sst, component_type::Index).get(); - _index_writer = std::make_unique(output_stream(std::move(out)), _sst.filename(component_type::Index)); + _index_writer = std::make_unique(output_stream(std::move(out)), _sst.index_filename()); } std::unique_ptr writer::close_writer(std::unique_ptr& w) { diff --git a/sstables/sstables.cc b/sstables/sstables.cc index b65bdcd05c..07a22b1d8b 100644 --- a/sstables/sstables.cc +++ b/sstables/sstables.cc @@ -838,16 +838,16 @@ future<> sstable::read_toc() noexcept { _recognized_components.insert(reverse_map(c, sstable_version_constants::get_component_map(_version))); } catch (std::out_of_range& oor) { _unrecognized_components.push_back(c); - sstlog.info("Unrecognized TOC component was found: {} in sstable {}", c, filename(component_type::TOC)); + sstlog.info("Unrecognized TOC component was found: {} in sstable {}", c, toc_filename()); } } if (!_recognized_components.size()) { - throw malformed_sstable_exception("Empty TOC", filename(component_type::TOC)); + throw malformed_sstable_exception("Empty TOC", toc_filename()); } }); } catch (std::system_error& e) { if (e.code() == std::error_code(ENOENT, std::system_category())) { - throw malformed_sstable_exception(filename(component_type::TOC) + ": file not found"); + throw malformed_sstable_exception(toc_filename() + ": file not found"); } throw; } diff --git a/test/lib/sstable_utils.hh b/test/lib/sstable_utils.hh index a15f62a976..315d7088a7 100644 --- a/test/lib/sstable_utils.hh +++ b/test/lib/sstable_utils.hh @@ -155,7 +155,7 @@ public: void rewrite_toc_without_component(component_type component) { SCYLLA_ASSERT(component != component_type::TOC); _sst->_recognized_components.erase(component); - remove_file(_sst->filename(component_type::TOC)).get(); + remove_file(_sst->toc_filename()).get(); _sst->_storage->open(*_sst); _sst->seal_sstable(false).get(); }