refactor: move metadata_v2 and inode_reader_v2 to internal namespace

This commit is contained in:
Marcus Holland-Moritz 2024-07-27 13:50:54 +02:00
parent c0df7a2973
commit f172a44e37
7 changed files with 36 additions and 23 deletions

View File

@ -633,9 +633,9 @@ list(APPEND LIBDWARFS_READER_SRC
src/dwarfs/cached_block.cpp src/dwarfs/cached_block.cpp
src/dwarfs/filesystem_v2.cpp src/dwarfs/filesystem_v2.cpp
src/dwarfs/fs_section.cpp src/dwarfs/fs_section.cpp
src/dwarfs/inode_reader_v2.cpp src/dwarfs/internal/inode_reader_v2.cpp
src/dwarfs/internal/metadata_v2.cpp
src/dwarfs/metadata_types.cpp src/dwarfs/metadata_types.cpp
src/dwarfs/metadata_v2.cpp
) )
list(APPEND LIBDWARFS_WRITER_SRC list(APPEND LIBDWARFS_WRITER_SRC

View File

@ -41,6 +41,8 @@ struct inode_reader_options;
struct iovec_read_buf; struct iovec_read_buf;
class performance_monitor; class performance_monitor;
namespace internal {
class inode_reader_v2 { class inode_reader_v2 {
public: public:
inode_reader_v2() = default; inode_reader_v2() = default;
@ -101,4 +103,6 @@ class inode_reader_v2 {
private: private:
std::unique_ptr<impl> impl_; std::unique_ptr<impl> impl_;
}; };
} // namespace internal
} // namespace dwarfs } // namespace dwarfs

View File

@ -51,6 +51,8 @@ namespace thrift::metadata {
class metadata; class metadata;
} }
namespace internal {
class metadata_v2 { class metadata_v2 {
public: public:
metadata_v2() = default; metadata_v2() = default;
@ -224,4 +226,6 @@ class metadata_v2 {
private: private:
std::unique_ptr<impl> impl_; std::unique_ptr<impl> impl_;
}; };
} // namespace internal
} // namespace dwarfs } // namespace dwarfs

View File

@ -41,9 +41,13 @@
namespace dwarfs { namespace dwarfs {
namespace internal {
template <typename T> template <typename T>
class metadata_; class metadata_;
}
class dir_entry_view; class dir_entry_view;
class logger; class logger;
@ -89,7 +93,7 @@ class inode_view
::apache::thrift::frozen::MappedFrozen<thrift::metadata::metadata>; ::apache::thrift::frozen::MappedFrozen<thrift::metadata::metadata>;
template <typename T> template <typename T>
friend class metadata_; friend class internal::metadata_;
friend class dir_entry_view; friend class dir_entry_view;
@ -127,7 +131,7 @@ class directory_view {
::apache::thrift::frozen::MappedFrozen<thrift::metadata::metadata>; ::apache::thrift::frozen::MappedFrozen<thrift::metadata::metadata>;
template <typename T> template <typename T>
friend class metadata_; friend class internal::metadata_;
friend class dir_entry_view; friend class dir_entry_view;
@ -159,7 +163,7 @@ class dir_entry_view {
::apache::thrift::frozen::View<thrift::metadata::dir_entry>; ::apache::thrift::frozen::View<thrift::metadata::dir_entry>;
template <typename T> template <typename T>
friend class metadata_; friend class internal::metadata_;
public: public:
std::string name() const; std::string name() const;
@ -216,7 +220,7 @@ class chunk_range {
::apache::thrift::frozen::MappedFrozen<thrift::metadata::metadata>; ::apache::thrift::frozen::MappedFrozen<thrift::metadata::metadata>;
template <typename T> template <typename T>
friend class metadata_; friend class internal::metadata_;
public: public:
class iterator class iterator

View File

@ -43,10 +43,10 @@
#include <dwarfs/fs_section.h> #include <dwarfs/fs_section.h>
#include <dwarfs/fstypes.h> #include <dwarfs/fstypes.h>
#include <dwarfs/history.h> #include <dwarfs/history.h>
#include <dwarfs/inode_reader_v2.h> #include <dwarfs/internal/inode_reader_v2.h>
#include <dwarfs/internal/metadata_v2.h>
#include <dwarfs/internal/worker_group.h> #include <dwarfs/internal/worker_group.h>
#include <dwarfs/logger.h> #include <dwarfs/logger.h>
#include <dwarfs/metadata_v2.h>
#include <dwarfs/mmif.h> #include <dwarfs/mmif.h>
#include <dwarfs/options.h> #include <dwarfs/options.h>
#include <dwarfs/performance_monitor.h> #include <dwarfs/performance_monitor.h>
@ -357,7 +357,7 @@ get_section_data(std::shared_ptr<mmif> mm, fs_section const& section,
return buffer; return buffer;
} }
metadata_v2 internal::metadata_v2
make_metadata(logger& lgr, std::shared_ptr<mmif> mm, make_metadata(logger& lgr, std::shared_ptr<mmif> mm,
section_map const& sections, std::vector<uint8_t>& schema_buffer, section_map const& sections, std::vector<uint8_t>& schema_buffer,
std::vector<uint8_t>& meta_buffer, std::vector<uint8_t>& meta_buffer,
@ -408,11 +408,11 @@ make_metadata(logger& lgr, std::shared_ptr<mmif> mm,
} }
} }
return metadata_v2(lgr, return internal::metadata_v2(lgr,
get_section_data(mm, schema_it->second.front(), get_section_data(mm, schema_it->second.front(),
schema_buffer, force_buffers), schema_buffer, force_buffers),
meta_section_range, options, inode_offset, meta_section_range, options, inode_offset,
force_consistency_check, perfmon); force_consistency_check, perfmon);
} }
template <typename LoggerPolicy> template <typename LoggerPolicy>
@ -497,8 +497,8 @@ class filesystem_ final : public filesystem_v2::impl {
LOG_PROXY_DECL(LoggerPolicy); LOG_PROXY_DECL(LoggerPolicy);
os_access const& os_; os_access const& os_;
std::shared_ptr<mmif> mm_; std::shared_ptr<mmif> mm_;
metadata_v2 meta_; internal::metadata_v2 meta_;
inode_reader_v2 ir_; internal::inode_reader_v2 ir_;
mutable std::mutex mx_; mutable std::mutex mx_;
std::vector<uint8_t> meta_buffer_; std::vector<uint8_t> meta_buffer_;
std::optional<std::span<uint8_t const>> header_; std::optional<std::span<uint8_t const>> header_;
@ -662,7 +662,8 @@ filesystem_<LoggerPolicy>::filesystem_(
cache.set_block_size(meta_.block_size()); cache.set_block_size(meta_.block_size());
ir_ = inode_reader_v2(lgr, std::move(cache), options.inode_reader, perfmon); ir_ = internal::inode_reader_v2(lgr, std::move(cache), options.inode_reader,
perfmon);
if (auto it = sections.find(section_type::HISTORY); it != sections.end()) { if (auto it = sections.find(section_type::HISTORY); it != sections.end()) {
for (auto& section : it->second) { for (auto& section : it->second) {

View File

@ -35,14 +35,14 @@
#include <dwarfs/block_cache.h> #include <dwarfs/block_cache.h>
#include <dwarfs/fstypes.h> #include <dwarfs/fstypes.h>
#include <dwarfs/inode_reader_v2.h> #include <dwarfs/internal/inode_reader_v2.h>
#include <dwarfs/iovec_read_buf.h> #include <dwarfs/iovec_read_buf.h>
#include <dwarfs/logger.h> #include <dwarfs/logger.h>
#include <dwarfs/offset_cache.h> #include <dwarfs/offset_cache.h>
#include <dwarfs/options.h> #include <dwarfs/options.h>
#include <dwarfs/performance_monitor.h> #include <dwarfs/performance_monitor.h>
namespace dwarfs { namespace dwarfs::internal {
namespace { namespace {
@ -405,4 +405,4 @@ inode_reader_v2::inode_reader_v2(
logger_policies>( logger_policies>(
lgr, std::move(bc), opts, std::move(perfmon))) {} lgr, std::move(bc), opts, std::move(perfmon))) {}
} // namespace dwarfs } // namespace dwarfs::internal

View File

@ -48,8 +48,8 @@
#include <dwarfs/features.h> #include <dwarfs/features.h>
#include <dwarfs/file_stat.h> #include <dwarfs/file_stat.h>
#include <dwarfs/fstypes.h> #include <dwarfs/fstypes.h>
#include <dwarfs/internal/metadata_v2.h>
#include <dwarfs/logger.h> #include <dwarfs/logger.h>
#include <dwarfs/metadata_v2.h>
#include <dwarfs/options.h> #include <dwarfs/options.h>
#include <dwarfs/performance_monitor.h> #include <dwarfs/performance_monitor.h>
#include <dwarfs/string_table.h> #include <dwarfs/string_table.h>
@ -61,7 +61,7 @@
#include <thrift/lib/thrift/gen-cpp2/frozen_types_custom_protocol.h> #include <thrift/lib/thrift/gen-cpp2/frozen_types_custom_protocol.h>
namespace dwarfs { namespace dwarfs::internal {
namespace fs = std::filesystem; namespace fs = std::filesystem;
@ -1799,4 +1799,4 @@ metadata_v2::metadata_v2(logger& lgr, std::span<uint8_t const> schema,
lgr, schema, data, options, inode_offset, force_consistency_check, lgr, schema, data, options, inode_offset, force_consistency_check,
std::move(perfmon))) {} std::move(perfmon))) {}
} // namespace dwarfs } // namespace dwarfs::internal