From c268384eea39be47f884347d38cf11f7aa10e77d Mon Sep 17 00:00:00 2001 From: Shinichi Umegane Date: Wed, 4 Sep 2024 20:33:26 +0900 Subject: [PATCH] Refactor: Corrected inclusion of private headers in public include files --- include/limestone/api/datastore.h | 6 ++++-- src/limestone/compaction_catalog.cpp | 8 ++++---- .../limestone/api => src/limestone}/compaction_catalog.h | 8 ++++---- src/limestone/datastore.cpp | 5 +++-- src/limestone/datastore_format.cpp | 2 +- src/limestone/online_compaction.cpp | 2 +- test/limestone/compaction/compaction_catalog_test.cpp | 6 +++--- test/limestone/compaction/online_compaction_test.cpp | 2 +- test/limestone/log/log_dir_test.cpp | 4 ++-- 9 files changed, 23 insertions(+), 20 deletions(-) rename {include/limestone/api => src/limestone}/compaction_catalog.h (98%) diff --git a/include/limestone/api/datastore.h b/include/limestone/api/datastore.h index 8cc90ffa..9303df52 100644 --- a/include/limestone/api/datastore.h +++ b/include/limestone/api/datastore.h @@ -38,8 +38,10 @@ #include #include #include -#include +namespace limestone::internal { + class compaction_catalog; +} namespace limestone::api { /** @@ -256,7 +258,7 @@ class datastore { std::atomic stop_online_compaction_worker_{false}; - std::optional compaction_catalog_; + std::unique_ptr compaction_catalog_; void online_compaction_worker(); diff --git a/src/limestone/compaction_catalog.cpp b/src/limestone/compaction_catalog.cpp index accb70fd..99898769 100644 --- a/src/limestone/compaction_catalog.cpp +++ b/src/limestone/compaction_catalog.cpp @@ -24,11 +24,11 @@ #include -#include +#include "compaction_catalog.h" #include "logging_helper.h" -#include +#include "limestone/api/epoch_id_type.h" -namespace limestone::api { +namespace limestone::internal { using limestone::api::epoch_id_type; @@ -256,4 +256,4 @@ const std::set& compaction_catalog::get_detached_pwals() const { return detached_pwals_; } -} // namespace limestone::api +} // namespace limestone::internal diff --git a/include/limestone/api/compaction_catalog.h b/src/limestone/compaction_catalog.h similarity index 98% rename from include/limestone/api/compaction_catalog.h rename to src/limestone/compaction_catalog.h index 339a35f6..a0ba946e 100644 --- a/include/limestone/api/compaction_catalog.h +++ b/src/limestone/compaction_catalog.h @@ -24,7 +24,9 @@ #include "limestone/api/epoch_id_type.h" -namespace limestone::api { +namespace limestone::internal { + +using namespace limestone::api; /** * @brief Structure to hold information about compacted files. @@ -208,8 +210,6 @@ class compaction_catalog { epoch_id_type max_epoch_id_ = 0; ///< Maximum epoch ID included in the compacted files // Set of filenames for compacted files. - // Compacted files are those with filenames starting with "cmpct", - // and they contain deduplicated data from PWAL files. boost::filesystem::path catalog_file_path_; // Set of filenames for compacted PWAL files. @@ -223,6 +223,6 @@ class compaction_catalog { [[nodiscard]] std::string create_catalog_content() const; }; -} // namespace limestone::api +} // namespace limestone::internal #endif // COMPACTION_CATALOG_H diff --git a/src/limestone/datastore.cpp b/src/limestone/datastore.cpp index 51a61671..69fccebe 100644 --- a/src/limestone/datastore.cpp +++ b/src/limestone/datastore.cpp @@ -27,10 +27,11 @@ #include #include "internal.h" -#include + #include #include "log_entry.h" #include "online_compaction.h" +#include "compaction_catalog.h" namespace limestone::api { using namespace limestone::internal; @@ -67,7 +68,7 @@ datastore::datastore(configuration const& conf) : location_(conf.data_locations_ } internal::check_and_migrate_logdir_format(location_); add_file(compaction_catalog_path); - compaction_catalog_ = compaction_catalog::from_catalog_file(location_); + compaction_catalog_ = std::make_unique(compaction_catalog::from_catalog_file(location_)); // XXX: prusik era // TODO: read rotated epoch files if main epoch file does not exist diff --git a/src/limestone/datastore_format.cpp b/src/limestone/datastore_format.cpp index 5d23ca5c..7b6e36fd 100644 --- a/src/limestone/datastore_format.cpp +++ b/src/limestone/datastore_format.cpp @@ -22,8 +22,8 @@ #include "logging_helper.h" #include -#include +#include "compaction_catalog.h" #include "internal.h" #include "log_entry.h" diff --git a/src/limestone/online_compaction.cpp b/src/limestone/online_compaction.cpp index b45a6569..539f7198 100644 --- a/src/limestone/online_compaction.cpp +++ b/src/limestone/online_compaction.cpp @@ -17,11 +17,11 @@ #include "online_compaction.h" #include -#include #include #include #include "logging_helper.h" +#include "compaction_catalog.h" namespace limestone::internal { diff --git a/test/limestone/compaction/compaction_catalog_test.cpp b/test/limestone/compaction/compaction_catalog_test.cpp index a82a4cc5..cbda9519 100644 --- a/test/limestone/compaction/compaction_catalog_test.cpp +++ b/test/limestone/compaction/compaction_catalog_test.cpp @@ -16,13 +16,13 @@ #include #include -#include +#include "compaction_catalog.h" namespace limestone::testing { using limestone::api::epoch_id_type; -using limestone::api::compacted_file_info; -using limestone::api::compaction_catalog; +using limestone::internal::compacted_file_info; +using limestone::internal::compaction_catalog; class compaction_catalog_test : public ::testing::Test { protected: void SetUp() override { diff --git a/test/limestone/compaction/online_compaction_test.cpp b/test/limestone/compaction/online_compaction_test.cpp index c1cea7ce..dcaa35ce 100644 --- a/test/limestone/compaction/online_compaction_test.cpp +++ b/test/limestone/compaction/online_compaction_test.cpp @@ -20,13 +20,13 @@ #include #include -#include #include #include "dblog_scan.h" #include "internal.h" #include "log_entry.h" #include "online_compaction.h" +#include "compaction_catalog.h" #include "test_root.h" diff --git a/test/limestone/log/log_dir_test.cpp b/test/limestone/log/log_dir_test.cpp index 01e815ae..3eef8fa9 100644 --- a/test/limestone/log/log_dir_test.cpp +++ b/test/limestone/log/log_dir_test.cpp @@ -2,17 +2,17 @@ #include #include -#include #include "dblog_scan.h" #include "internal.h" #include "log_entry.h" +#include "compaction_catalog.h" #include "test_root.h" using namespace std::literals; using dblog_scan = limestone::internal::dblog_scan; -using compaction_catalog = limestone::api::compaction_catalog; +using compaction_catalog = limestone::internal::compaction_catalog; namespace limestone::testing {