From 86159cc8990ac6253b408fd389e0327ffb47bcdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Van=C4=9Bk?= Date: Wed, 12 Feb 2025 14:06:51 +0100 Subject: [PATCH] Migration for Boost 1.85 Boost 1.85 removed some deprecated code in filesystem module which is still used in columnstore: - The boost/filesystem/convenience.hpp was removed but columnstore does not use any functionality from that file except indirect includes. Therefore this include is removed or replaced with more general boost/filesystem.hpp. The convenience.hpp header file was deprecated in filesystem V3 introduced in Boost 1.46.0. - `normalize` method was removed and users are suggested to replace it with `lexically_normal` method, which was introduced in Boost 1.60.0. Original `normalize` call is preserved for backward compatibility with old Boost version, however`, `lexically_normal` method is preferably used with Boost 1.60.0 and newer. - The `copy_option` was removed in favor of `copy_options` (note the trailing 's'), but enum values were renamed. Namely, `fail_if_exists` is replaced with `none` and `overwrite_if_exists` is replaced with `overwrite_existing`. The `copy_options` was introduced in Boost 1.74.0. New form is used instead, but a backward compatibility layer for Boost 1.73.0 and older was introduced in boost_copy_options_compat.hpp file. This solution seems to be less awkward than using multiple #if #else #endif blocks in source code. --- .../columnstoreSupport/columnstoreSupport.cpp | 7 +++-- storage-manager/src/LocalStorage.cpp | 3 +- storage-manager/src/Ownership.cpp | 6 ++++ utils/common/boost_copy_options_compat.hpp | 28 +++++++++++++++++++ utils/configcpp/configcpp.cpp | 3 +- utils/idbdatafile/IDBPolicy.cpp | 2 +- utils/idbdatafile/PosixFileSystem.cpp | 3 +- writeengine/bulk/we_bulkload.cpp | 3 +- .../we_redistributeworkerthread.cpp | 3 +- writeengine/server/we_ddlcommandproc.cpp | 3 +- .../shared/we_bulkrollbackfilecompressed.cpp | 1 - .../we_bulkrollbackfilecompressedhdfs.cpp | 1 - writeengine/shared/we_bulkrollbackmgr.cpp | 1 - writeengine/shared/we_rbmetawriter.cpp | 1 - writeengine/xml/we_xmljob.cpp | 3 +- 15 files changed, 48 insertions(+), 20 deletions(-) create mode 100644 utils/common/boost_copy_options_compat.hpp diff --git a/oamapps/columnstoreSupport/columnstoreSupport.cpp b/oamapps/columnstoreSupport/columnstoreSupport.cpp index d32496281..d8a8c80a2 100644 --- a/oamapps/columnstoreSupport/columnstoreSupport.cpp +++ b/oamapps/columnstoreSupport/columnstoreSupport.cpp @@ -30,6 +30,7 @@ #include #include +#include "boost_copy_options_compat.hpp" #include "mcsconfig.h" #include "liboamcpp.h" #include "configcpp.h" @@ -256,11 +257,11 @@ void* reportThread(string* reporttype) boost::filesystem::path configFile = std::string(MCSSYSCONFDIR) + std::string("/columnstore/Columnstore.xml"); boost::filesystem::copy_file(configFile, "./Columnstore.xml", - boost::filesystem::copy_option::overwrite_if_exists); + boost::filesystem::copy_options::overwrite_existing); boost::filesystem::path SMconfigFile = std::string(MCSSYSCONFDIR) + std::string("/columnstore/storagemanager.cnf"); boost::filesystem::copy_file(SMconfigFile, "./storagemanager.cnf", - boost::filesystem::copy_option::overwrite_if_exists); + boost::filesystem::copy_options::overwrite_existing); system("sed -i 's/.*aws_access_key_id.*/aws_access_key_id={PRIVATE}/' ./storagemanager.cnf"); system("sed -i 's/.*aws_secret_access_key.*/aws_secret_access_key={PRIVATE}/' ./storagemanager.cnf"); fclose(pOutputFile); @@ -858,7 +859,7 @@ int main(int argc, char* argv[]) boost::filesystem::path configFile = std::string(MCSMYCNFDIR) + "/columnstore.cnf"; boost::filesystem::copy_file(configFile, "./columnstore.cnf", - boost::filesystem::copy_option::overwrite_if_exists); + boost::filesystem::copy_options::overwrite_existing); } int wait = 0; diff --git a/storage-manager/src/LocalStorage.cpp b/storage-manager/src/LocalStorage.cpp index 005e43838..59a43d4cf 100644 --- a/storage-manager/src/LocalStorage.cpp +++ b/storage-manager/src/LocalStorage.cpp @@ -21,6 +21,7 @@ #include #include #include +#include "boost_copy_options_compat.hpp" #include "LocalStorage.h" #include "Config.h" @@ -94,7 +95,7 @@ inline void LocalStorage::addLatency() int LocalStorage::copy(const bf::path& source, const bf::path& dest) { boost::system::error_code err; - bf::copy_file(source, dest, bf::copy_option::fail_if_exists, err); + bf::copy_file(source, dest, bf::copy_options::none, err); if (err) { errno = err.value(); diff --git a/storage-manager/src/Ownership.cpp b/storage-manager/src/Ownership.cpp index cadcebc22..a22def05a 100644 --- a/storage-manager/src/Ownership.cpp +++ b/storage-manager/src/Ownership.cpp @@ -77,7 +77,13 @@ bf::path Ownership::get(const bf::path& p, bool getOwnership) bf::path::const_iterator pit; int i, levels; +#if BOOST_VERSION >= 106000 + // available since 1.60.0 released 2015-12-17 + normalizedPath.lexically_normal(); +#else + // removed in 1.85.0 release 2024-04-15 normalizedPath.normalize(); +#endif // cerr << "Ownership::get() param = " << normalizedPath.string() << endl; if (prefixDepth > 0) { diff --git a/utils/common/boost_copy_options_compat.hpp b/utils/common/boost_copy_options_compat.hpp new file mode 100644 index 000000000..479542c09 --- /dev/null +++ b/utils/common/boost_copy_options_compat.hpp @@ -0,0 +1,28 @@ +#ifndef COMPAT_BOOST_FILESYSTEM_HPP +#define COMPAT_BOOST_FILESYSTEM_HPP + +#include + +// copy_option was replaced with copy_options in version 1.74.0 released 2020-08-14 +// copy_option was removed in version 1.85.0 released 2024-04-15 +#if BOOST_VERSION < 107400 + +#include + +namespace boost +{ +namespace filesystem +{ +namespace copy_options +{ + +constexpr copy_option::enum_type overwrite_existing = copy_option::overwrite_if_exists; +constexpr copy_option::enum_type none = copy_option::fail_if_exists; + +} +} +} + +#endif + +#endif diff --git a/utils/configcpp/configcpp.cpp b/utils/configcpp/configcpp.cpp index e102a0cba..de692946f 100644 --- a/utils/configcpp/configcpp.cpp +++ b/utils/configcpp/configcpp.cpp @@ -54,6 +54,7 @@ namespace fs = boost::filesystem; #include "configcpp.h" +#include "boost_copy_options_compat.hpp" #include "exceptclasses.h" #include "installdir.h" #ifdef _MSC_VER @@ -401,7 +402,7 @@ void Config::writeConfig(const string& configFile) const { } - fs::copy_file(dcf, scft, fs::copy_option::overwrite_if_exists); + fs::copy_file(dcf, scft, fs::copy_options::overwrite_existing); try { diff --git a/utils/idbdatafile/IDBPolicy.cpp b/utils/idbdatafile/IDBPolicy.cpp index 01d3f65f0..6809a511f 100644 --- a/utils/idbdatafile/IDBPolicy.cpp +++ b/utils/idbdatafile/IDBPolicy.cpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include "configcpp.h" // for Config diff --git a/utils/idbdatafile/PosixFileSystem.cpp b/utils/idbdatafile/PosixFileSystem.cpp index bd3e1c4b2..84e3431e2 100644 --- a/utils/idbdatafile/PosixFileSystem.cpp +++ b/utils/idbdatafile/PosixFileSystem.cpp @@ -24,8 +24,7 @@ #include #include -#include -#include +#include using namespace std; diff --git a/writeengine/bulk/we_bulkload.cpp b/writeengine/bulk/we_bulkload.cpp index ebec84dc2..e3f3ba304 100644 --- a/writeengine/bulk/we_bulkload.cpp +++ b/writeengine/bulk/we_bulkload.cpp @@ -34,8 +34,7 @@ #include #include #include -#include -#include +#include #include #include #include diff --git a/writeengine/redistribute/we_redistributeworkerthread.cpp b/writeengine/redistribute/we_redistributeworkerthread.cpp index 5825ea537..cd885e6f2 100644 --- a/writeengine/redistribute/we_redistributeworkerthread.cpp +++ b/writeengine/redistribute/we_redistributeworkerthread.cpp @@ -32,8 +32,7 @@ using namespace std; #include "boost/scoped_ptr.hpp" #include "boost/scoped_array.hpp" #include "boost/thread/mutex.hpp" -#include "boost/filesystem/path.hpp" -#include "boost/filesystem/operations.hpp" +#include "boost/filesystem.hpp" using namespace boost; #include "installdir.h" diff --git a/writeengine/server/we_ddlcommandproc.cpp b/writeengine/server/we_ddlcommandproc.cpp index 3970e6c1e..56c760db9 100644 --- a/writeengine/server/we_ddlcommandproc.cpp +++ b/writeengine/server/we_ddlcommandproc.cpp @@ -19,8 +19,7 @@ // $Id: we_ddlcommandproc.cpp 3082 2011-09-26 22:00:38Z chao $ #include -#include "boost/filesystem/operations.hpp" -#include "boost/filesystem/path.hpp" +#include "boost/filesystem.hpp" #include "boost/scoped_ptr.hpp" using namespace std; diff --git a/writeengine/shared/we_bulkrollbackfilecompressed.cpp b/writeengine/shared/we_bulkrollbackfilecompressed.cpp index 7e2b8c509..75b9730ec 100644 --- a/writeengine/shared/we_bulkrollbackfilecompressed.cpp +++ b/writeengine/shared/we_bulkrollbackfilecompressed.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include "we_define.h" #include "we_fileop.h" diff --git a/writeengine/shared/we_bulkrollbackfilecompressedhdfs.cpp b/writeengine/shared/we_bulkrollbackfilecompressedhdfs.cpp index 61f8b61f7..984417695 100644 --- a/writeengine/shared/we_bulkrollbackfilecompressedhdfs.cpp +++ b/writeengine/shared/we_bulkrollbackfilecompressedhdfs.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include "we_define.h" #include "we_fileop.h" diff --git a/writeengine/shared/we_bulkrollbackmgr.cpp b/writeengine/shared/we_bulkrollbackmgr.cpp index 0fc93729f..9c02a81b5 100644 --- a/writeengine/shared/we_bulkrollbackmgr.cpp +++ b/writeengine/shared/we_bulkrollbackmgr.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include "we_bulkrollbackmgr.h" diff --git a/writeengine/shared/we_rbmetawriter.cpp b/writeengine/shared/we_rbmetawriter.cpp index 98bf2cdce..7c66269f1 100644 --- a/writeengine/shared/we_rbmetawriter.cpp +++ b/writeengine/shared/we_rbmetawriter.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include "we_config.h" #include "we_convertor.h" diff --git a/writeengine/xml/we_xmljob.cpp b/writeengine/xml/we_xmljob.cpp index 2a95203df..46fd2d234 100644 --- a/writeengine/xml/we_xmljob.cpp +++ b/writeengine/xml/we_xmljob.cpp @@ -36,8 +36,7 @@ #include "we_convertor.h" #include "dataconvert.h" #include -#include -#include +#include #include