You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by ya...@apache.org on 2021/04/08 01:12:11 UTC
[incubator-doris] branch master updated: [Refactor] Remove boost
filesystem (#5579)
This is an automated email from the ASF dual-hosted git repository.
yangzhg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push:
new d641a26 [Refactor] Remove boost filesystem (#5579)
d641a26 is described below
commit d641a26490c64c0e9df834bc65155a2182658cd5
Author: Zhengguo Yang <78...@qq.com>
AuthorDate: Thu Apr 8 09:11:59 2021 +0800
[Refactor] Remove boost filesystem (#5579)
* use std::filesystem instead of boost
Co-authored-by: Mingyu Chen <mo...@gmail.com>
---
be/src/agent/agent_server.cpp | 8 ++--
be/src/agent/cgroups_mgr.cpp | 16 +++----
be/src/agent/heartbeat_server.cpp | 2 +-
be/src/agent/pusher.cpp | 10 ++---
be/src/http/action/restore_tablet_action.cpp | 2 +-
be/src/olap/data_dir.cpp | 20 ++++-----
be/src/olap/push_handler.cpp | 2 +-
be/src/olap/rowset/segment_group.cpp | 4 +-
be/src/olap/rowset/segment_writer.cpp | 11 +++--
be/src/olap/snapshot_manager.cpp | 7 ++-
be/src/olap/storage_engine.cpp | 12 +++---
be/src/olap/tablet.cpp | 2 +-
be/src/olap/tablet_manager.cpp | 2 +-
be/src/olap/task/engine_batch_load_task.cpp | 16 +++----
be/src/olap/task/engine_clone_task.cpp | 14 +++---
be/src/olap/txn_manager.cpp | 10 ++---
be/src/olap/utils.cpp | 26 ++++++------
be/src/olap/utils.h | 6 +--
be/src/runtime/etl_job_mgr.cpp | 4 +-
be/src/runtime/snapshot_loader.cpp | 14 +++---
be/src/runtime/tmp_file_mgr.cc | 10 ++---
be/src/tools/meta_tool.cpp | 5 ++-
be/src/util/broker_storage_backend.cpp | 2 +-
be/src/util/cpu_info.cpp | 4 +-
be/src/util/file_utils.cpp | 15 +++----
be/src/util/filesystem_util.cc | 52 ++++++++++++-----------
be/src/util/path_util.h | 2 +-
be/test/agent/cgroups_mgr_test.cpp | 16 +++----
be/test/olap/byte_buffer_test.cpp | 6 +--
be/test/olap/file_helper_test.cpp | 12 +++---
be/test/olap/file_utils_test.cpp | 34 +++++++++------
be/test/olap/olap_meta_test.cpp | 4 +-
be/test/olap/olap_snapshot_converter_test.cpp | 24 +++++------
be/test/olap/options_test.cpp | 4 +-
be/test/olap/rowset/alpha_rowset_test.cpp | 2 +-
be/test/olap/rowset/rowset_converter_test.cpp | 1 -
be/test/olap/rowset/rowset_meta_manager_test.cpp | 8 ++--
be/test/olap/rowset/rowset_meta_test.cpp | 8 ++--
be/test/olap/rowset/segment_v2/segment_test.cpp | 4 +-
be/test/olap/tablet_meta_manager_test.cpp | 8 ++--
be/test/olap/tablet_mgr_test.cpp | 12 +++---
be/test/olap/timestamped_version_tracker_test.cpp | 2 +-
be/test/olap/txn_manager_test.cpp | 10 ++---
be/test/runtime/buffered_block_mgr2_test.cpp | 6 +--
be/test/runtime/buffered_tuple_stream2_test.cpp | 2 +-
be/test/runtime/snapshot_loader_test.cpp | 12 +++---
be/test/runtime/tmp_file_mgr_test.cpp | 8 ++--
be/test/util/filesystem_util_test.cpp | 13 ++----
48 files changed, 240 insertions(+), 234 deletions(-)
diff --git a/be/src/agent/agent_server.cpp b/be/src/agent/agent_server.cpp
index 6c2882f..ebfc175 100644
--- a/be/src/agent/agent_server.cpp
+++ b/be/src/agent/agent_server.cpp
@@ -17,7 +17,7 @@
#include "agent/agent_server.h"
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <string>
#include "agent/task_worker_pool.h"
@@ -39,9 +39,9 @@ AgentServer::AgentServer(ExecEnv* exec_env, const TMasterInfo& master_info)
for (auto& path : exec_env->store_paths()) {
try {
string dpp_download_path_str = path.path + DPP_PREFIX;
- boost::filesystem::path dpp_download_path(dpp_download_path_str);
- if (boost::filesystem::exists(dpp_download_path)) {
- boost::filesystem::remove_all(dpp_download_path);
+ std::filesystem::path dpp_download_path(dpp_download_path_str);
+ if (std::filesystem::exists(dpp_download_path)) {
+ std::filesystem::remove_all(dpp_download_path);
}
} catch (...) {
LOG(WARNING) << "boost exception when remove dpp download path. path=" << path.path;
diff --git a/be/src/agent/cgroups_mgr.cpp b/be/src/agent/cgroups_mgr.cpp
index 53308fb..6c73ee9 100644
--- a/be/src/agent/cgroups_mgr.cpp
+++ b/be/src/agent/cgroups_mgr.cpp
@@ -173,7 +173,7 @@ AgentStatus CgroupsMgr::_config_disk_throttle(std::string user_name, std::string
string write_iops_path = cgroups_path + "/blkio.throttle.write_iops_device";
if (!is_file_exist(cgroups_path.c_str())) {
- if (!boost::filesystem::create_directory(cgroups_path)) {
+ if (!std::filesystem::create_directory(cgroups_path)) {
LOG(ERROR) << "Create cgroups: " << cgroups_path << " failed";
return AgentStatus::DORIS_ERROR;
}
@@ -239,7 +239,7 @@ AgentStatus CgroupsMgr::modify_user_cgroups(const string& user_name,
// Check if the user's cgroups exists, if not create it
string user_cgroups_path = this->_root_cgroups_path + "/" + user_name;
if (!is_file_exist(user_cgroups_path.c_str())) {
- if (!boost::filesystem::create_directory(user_cgroups_path)) {
+ if (!std::filesystem::create_directory(user_cgroups_path)) {
LOG(ERROR) << "Create cgroups for user " << user_name << " failed";
return AgentStatus::DORIS_ERROR;
}
@@ -267,7 +267,7 @@ AgentStatus CgroupsMgr::modify_user_cgroups(const string& user_name,
// Check if the level cgroups exist
string level_cgroups_path = user_cgroups_path + "/" + level_name;
if (!is_file_exist(level_cgroups_path.c_str())) {
- if (!boost::filesystem::create_directory(level_cgroups_path)) {
+ if (!std::filesystem::create_directory(level_cgroups_path)) {
return AgentStatus::DORIS_ERROR;
}
}
@@ -309,8 +309,8 @@ AgentStatus CgroupsMgr::init_cgroups() {
return AgentStatus::DORIS_ERROR;
}
// If root folder exists, then delete all subfolders under it
- boost::filesystem::directory_iterator item_begin(this->_root_cgroups_path);
- boost::filesystem::directory_iterator item_end;
+ std::filesystem::directory_iterator item_begin(this->_root_cgroups_path);
+ std::filesystem::directory_iterator item_end;
for (; item_begin != item_end; item_begin++) {
if (is_directory(item_begin->path().string().c_str())) {
// Delete the sub folder
@@ -382,8 +382,8 @@ AgentStatus CgroupsMgr::delete_user_cgroups(const string& user_name) {
string user_cgroups_path = this->_root_cgroups_path + "/" + user_name;
if (is_file_exist(user_cgroups_path.c_str())) {
// Delete sub cgroups --> level cgroups
- boost::filesystem::directory_iterator item_begin(user_cgroups_path);
- boost::filesystem::directory_iterator item_end;
+ std::filesystem::directory_iterator item_begin(user_cgroups_path);
+ std::filesystem::directory_iterator item_end;
for (; item_begin != item_end; item_begin++) {
if (is_directory(item_begin->path().string().c_str())) {
string cur_cgroups_path = item_begin->path().string();
@@ -410,7 +410,7 @@ AgentStatus CgroupsMgr::drop_cgroups(const string& deleted_cgroups_path) {
this->relocate_tasks(deleted_cgroups_path, this->_root_cgroups_path);
++i;
#ifdef BE_TEST
- boost::filesystem::remove_all(deleted_cgroups_path);
+ std::filesystem::remove_all(deleted_cgroups_path);
#endif
if (i == this->_drop_retry_times) {
LOG(ERROR) << "drop cgroups under path: " << deleted_cgroups_path << " failed.";
diff --git a/be/src/agent/heartbeat_server.cpp b/be/src/agent/heartbeat_server.cpp
index 47f12b5..516350d 100644
--- a/be/src/agent/heartbeat_server.cpp
+++ b/be/src/agent/heartbeat_server.cpp
@@ -19,7 +19,7 @@
#include <thrift/TProcessor.h>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <ctime>
#include <fstream>
diff --git a/be/src/agent/pusher.cpp b/be/src/agent/pusher.cpp
index 5d1d2b0..90e3ad2 100644
--- a/be/src/agent/pusher.cpp
+++ b/be/src/agent/pusher.cpp
@@ -91,12 +91,12 @@ AgentStatus Pusher::_get_tmp_file_dir(const string& root_path, string* download_
*download_path = root_path + DPP_PREFIX;
// Check path exist
- boost::filesystem::path full_path(*download_path);
+ std::filesystem::path full_path(*download_path);
- if (!boost::filesystem::exists(full_path)) {
+ if (!std::filesystem::exists(full_path)) {
LOG(INFO) << "download dir not exist: " << *download_path;
boost::system::error_code error_code;
- boost::filesystem::create_directories(*download_path, error_code);
+ std::filesystem::create_directories(*download_path, error_code);
if (0 != error_code) {
status = DORIS_ERROR;
@@ -154,7 +154,7 @@ AgentStatus Pusher::process(vector<TTabletInfo>* tablet_infos) {
// check file size
if (_push_req.__isset.http_file_size) {
// Check file size
- uint64_t local_file_size = boost::filesystem::file_size(_local_file_path);
+ uint64_t local_file_size = std::filesystem::file_size(_local_file_path);
if (file_size != local_file_size) {
LOG(WARNING) << "download_file size error. file_size=" << file_size
<< ", local_file_size=" << local_file_size;
@@ -204,7 +204,7 @@ AgentStatus Pusher::process(vector<TTabletInfo>* tablet_infos) {
}
// Delete download file
- if (boost::filesystem::exists(_local_file_path)) {
+ if (std::filesystem::exists(_local_file_path)) {
if (remove(_local_file_path.c_str()) == -1) {
LOG(WARNING) << "can not remove file=" << _local_file_path;
}
diff --git a/be/src/http/action/restore_tablet_action.cpp b/be/src/http/action/restore_tablet_action.cpp
index 54704a3..29cdc5f 100644
--- a/be/src/http/action/restore_tablet_action.cpp
+++ b/be/src/http/action/restore_tablet_action.cpp
@@ -40,7 +40,7 @@
#include "util/file_utils.h"
#include "util/json_util.h"
-using boost::filesystem::path;
+using std::filesystem::path;
namespace doris {
diff --git a/be/src/olap/data_dir.cpp b/be/src/olap/data_dir.cpp
index c451f75..e48392a 100644
--- a/be/src/olap/data_dir.cpp
+++ b/be/src/olap/data_dir.cpp
@@ -28,7 +28,7 @@
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/trim.hpp>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <boost/interprocess/sync/file_lock.hpp>
#include <fstream>
#include <set>
@@ -188,8 +188,8 @@ Status DataDir::_read_cluster_id(const std::string& cluster_id_path, int32_t* cl
}
Status DataDir::_init_capacity() {
- boost::filesystem::path boost_path = _path;
- int64_t disk_capacity = boost::filesystem::space(boost_path).capacity;
+ std::filesystem::path boost_path = _path;
+ int64_t disk_capacity = std::filesystem::space(boost_path).capacity;
if (_capacity_bytes == -1) {
_capacity_bytes = disk_capacity;
} else if (_capacity_bytes > disk_capacity) {
@@ -404,7 +404,7 @@ void DataDir::find_tablet_in_trash(int64_t tablet_id, std::vector<std::string>*
std::string DataDir::get_root_path_from_schema_hash_path_in_trash(
const std::string& schema_hash_dir_in_trash) {
- boost::filesystem::path schema_hash_path_in_trash(schema_hash_dir_in_trash);
+ std::filesystem::path schema_hash_path_in_trash(schema_hash_dir_in_trash);
return schema_hash_path_in_trash.parent_path()
.parent_path()
.parent_path()
@@ -684,8 +684,8 @@ void DataDir::perform_path_gc_by_tablet() {
// could find the tablet, then skip check it
continue;
}
- boost::filesystem::path tablet_path(path);
- boost::filesystem::path data_dir_path =
+ std::filesystem::path tablet_path(path);
+ std::filesystem::path data_dir_path =
tablet_path.parent_path().parent_path().parent_path().parent_path();
std::string data_dir_string = data_dir_path.string();
DataDir* data_dir = StorageEngine::instance()->get_store(data_dir_string);
@@ -818,18 +818,18 @@ bool DataDir::_check_pending_ids(const std::string& id) {
Status DataDir::update_capacity() {
try {
- boost::filesystem::path path_name(_path);
- boost::filesystem::space_info path_info = boost::filesystem::space(path_name);
+ std::filesystem::path path_name(_path);
+ std::filesystem::space_info path_info = std::filesystem::space(path_name);
_available_bytes = path_info.available;
if (_disk_capacity_bytes == 0) {
// disk capacity only need to be set once
_disk_capacity_bytes = path_info.capacity;
}
- } catch (boost::filesystem::filesystem_error& e) {
+ } catch (std::filesystem::filesystem_error& e) {
RETURN_NOT_OK_STATUS_WITH_WARN(
Status::IOError(strings::Substitute(
"get path $0 available capacity failed, error=$1", _path, e.what())),
- "boost::filesystem::space failed");
+ "std::filesystem::space failed");
}
disks_total_capacity->set_value(_disk_capacity_bytes);
diff --git a/be/src/olap/push_handler.cpp b/be/src/olap/push_handler.cpp
index a740176..d08a06b 100644
--- a/be/src/olap/push_handler.cpp
+++ b/be/src/olap/push_handler.cpp
@@ -18,7 +18,7 @@
#include "olap/push_handler.h"
#include <algorithm>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <iostream>
#include <sstream>
diff --git a/be/src/olap/rowset/segment_group.cpp b/be/src/olap/rowset/segment_group.cpp
index 762c4ca..c1d7fa2 100644
--- a/be/src/olap/rowset/segment_group.cpp
+++ b/be/src/olap/rowset/segment_group.cpp
@@ -620,8 +620,8 @@ OLAPStatus SegmentGroup::add_short_key(const RowCursor& short_key, const uint32_
string file_path = construct_index_file_path(_num_segments - 1);
StorageEngine* engine = StorageEngine::instance();
if (engine != nullptr) {
- boost::filesystem::path tablet_path(_rowset_path_prefix);
- boost::filesystem::path data_dir_path =
+ std::filesystem::path tablet_path(_rowset_path_prefix);
+ std::filesystem::path data_dir_path =
tablet_path.parent_path().parent_path().parent_path().parent_path();
std::string data_dir_string = data_dir_path.string();
DataDir* data_dir = engine->get_store(data_dir_string);
diff --git a/be/src/olap/rowset/segment_writer.cpp b/be/src/olap/rowset/segment_writer.cpp
index a0213a3..e165e39 100644
--- a/be/src/olap/rowset/segment_writer.cpp
+++ b/be/src/olap/rowset/segment_writer.cpp
@@ -207,12 +207,17 @@ OLAPStatus SegmentWriter::finalize(uint32_t* segment_file_size) {
StorageEngine* engine = StorageEngine::instance();
DataDir* data_dir = nullptr;
if (engine != nullptr) {
- boost::filesystem::path tablet_path(_segment_group->rowset_path_prefix());
- boost::filesystem::path data_dir_path =
+ std::filesystem::path tablet_path = std::string_view(_segment_group->rowset_path_prefix());
+ std::filesystem::path data_dir_path =
tablet_path.parent_path().parent_path().parent_path().parent_path();
std::string data_dir_string = data_dir_path.string();
data_dir = engine->get_store(data_dir_string);
- data_dir->add_pending_ids(ROWSET_ID_PREFIX + _segment_group->rowset_id().to_string());
+ if (LIKELY(data_dir != nullptr)) {
+ data_dir->add_pending_ids(ROWSET_ID_PREFIX + _segment_group->rowset_id().to_string());
+ } else {
+ LOG(WARNING) << "data dir not found. [data_dir=" << data_dir_string << "]";
+ return OLAP_ERR_CANNOT_CREATE_DIR;
+ }
}
if (OLAP_SUCCESS != (res = file_handle.open_with_mode(_file_name, O_CREAT | O_EXCL | O_WRONLY,
S_IRUSR | S_IWUSR))) {
diff --git a/be/src/olap/snapshot_manager.cpp b/be/src/olap/snapshot_manager.cpp
index 32adf76..87ed672 100644
--- a/be/src/olap/snapshot_manager.cpp
+++ b/be/src/olap/snapshot_manager.cpp
@@ -24,7 +24,7 @@
#include <algorithm>
#include <boost/date_time/gregorian/gregorian.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <iterator>
#include <map>
#include <set>
@@ -40,9 +40,8 @@
#include "olap/rowset/rowset_writer.h"
#include "olap/storage_engine.h"
-using boost::filesystem::copy_file;
-using boost::filesystem::copy_option;
-using boost::filesystem::path;
+using std::filesystem::copy_file;
+using std::filesystem::path;
using std::map;
using std::nothrow;
using std::set;
diff --git a/be/src/olap/storage_engine.cpp b/be/src/olap/storage_engine.cpp
index 670cd21..5f12abd 100644
--- a/be/src/olap/storage_engine.cpp
+++ b/be/src/olap/storage_engine.cpp
@@ -26,7 +26,7 @@
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <cstdio>
#include <new>
#include <queue>
@@ -62,10 +62,10 @@
#include "util/trace.h"
using apache::thrift::ThriftDebugString;
-using boost::filesystem::canonical;
-using boost::filesystem::directory_iterator;
-using boost::filesystem::path;
-using boost::filesystem::recursive_directory_iterator;
+using std::filesystem::canonical;
+using std::filesystem::directory_iterator;
+using std::filesystem::path;
+using std::filesystem::recursive_directory_iterator;
using std::back_inserter;
using std::copy;
using std::inserter;
@@ -861,7 +861,7 @@ OLAPStatus StorageEngine::load_header(const string& shard_path, const TCloneReq&
// TODO(zc)
try {
auto store_path =
- boost::filesystem::path(shard_path).parent_path().parent_path().string();
+ std::filesystem::path(shard_path).parent_path().parent_path().string();
store = get_store(store_path);
if (store == nullptr) {
LOG(WARNING) << "invalid shard path, path=" << shard_path;
diff --git a/be/src/olap/tablet.cpp b/be/src/olap/tablet.cpp
index 1a12faa..457d7f0 100644
--- a/be/src/olap/tablet.cpp
+++ b/be/src/olap/tablet.cpp
@@ -24,7 +24,7 @@
#include <stdio.h>
#include <algorithm>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <map>
#include <set>
diff --git a/be/src/olap/tablet_manager.cpp b/be/src/olap/tablet_manager.cpp
index 92a4724..569c343 100644
--- a/be/src/olap/tablet_manager.cpp
+++ b/be/src/olap/tablet_manager.cpp
@@ -25,7 +25,7 @@
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <cstdio>
#include <cstdlib>
diff --git a/be/src/olap/task/engine_batch_load_task.cpp b/be/src/olap/task/engine_batch_load_task.cpp
index a2718f0..a2545e2 100644
--- a/be/src/olap/task/engine_batch_load_task.cpp
+++ b/be/src/olap/task/engine_batch_load_task.cpp
@@ -154,17 +154,17 @@ AgentStatus EngineBatchLoadTask::_get_tmp_file_dir(const string& root_path, stri
*download_path = root_path + DPP_PREFIX;
// Check path exist
- boost::filesystem::path full_path(*download_path);
+ std::filesystem::path full_path(*download_path);
- if (!boost::filesystem::exists(full_path)) {
+ if (!std::filesystem::exists(full_path)) {
LOG(INFO) << "download dir not exist: " << *download_path;
- boost::system::error_code error_code;
- boost::filesystem::create_directories(*download_path, error_code);
+ std::error_code ec;
+ std::filesystem::create_directories(*download_path, ec);
- if (error_code.failed()) {
+ if (ec) {
status = DORIS_ERROR;
LOG(WARNING) << "create download dir failed.path: " << *download_path
- << ", error code: " << error_code;
+ << ", error code: " << ec;
}
}
@@ -221,7 +221,7 @@ AgentStatus EngineBatchLoadTask::_process() {
// check file size
if (_push_req.__isset.http_file_size) {
// Check file size
- uint64_t local_file_size = boost::filesystem::file_size(_local_file_path);
+ uint64_t local_file_size = std::filesystem::file_size(_local_file_path);
if (file_size != local_file_size) {
LOG(WARNING) << "download_file size error. file_size=" << file_size
<< ", local_file_size=" << local_file_size;
@@ -271,7 +271,7 @@ AgentStatus EngineBatchLoadTask::_process() {
}
// Delete download file
- if (boost::filesystem::exists(_local_file_path)) {
+ if (std::filesystem::exists(_local_file_path)) {
if (remove(_local_file_path.c_str()) == -1) {
LOG(WARNING) << "can not remove file=" << _local_file_path;
}
diff --git a/be/src/olap/task/engine_clone_task.cpp b/be/src/olap/task/engine_clone_task.cpp
index 30d21e4..ae61aeb 100644
--- a/be/src/olap/task/engine_clone_task.cpp
+++ b/be/src/olap/task/engine_clone_task.cpp
@@ -189,11 +189,11 @@ OLAPStatus EngineCloneTask::_do_clone() {
LOG(INFO) << "clone failed. want to delete local dir: " << local_data_path
<< ". signature: " << _signature;
try {
- boost::filesystem::path local_path(local_data_path);
- if (boost::filesystem::exists(local_path)) {
- boost::filesystem::remove_all(local_path);
+ std::filesystem::path local_path(local_data_path);
+ if (std::filesystem::exists(local_path)) {
+ std::filesystem::remove_all(local_path);
}
- } catch (boost::filesystem::filesystem_error &e) {
+ } catch (std::filesystem::filesystem_error &e) {
// Ignore the error, OLAP will delete it
LOG(WARNING) << "clone delete useless dir failed. "
<< " error: " << e.what() << " local dir: " << local_data_path.c_str()
@@ -483,7 +483,7 @@ Status EngineCloneTask::_download_files(DataDir* data_dir, const std::string& re
RETURN_IF_ERROR(client->download(local_file_path));
// Check file length
- uint64_t local_file_size = boost::filesystem::file_size(local_file_path);
+ uint64_t local_file_size = std::filesystem::file_size(local_file_path);
if (local_file_size != file_size) {
LOG(WARNING) << "download file length error"
<< ", remote_path=" << remote_file_url << ", file_size=" << file_size
@@ -619,8 +619,8 @@ OLAPStatus EngineCloneTask::_finish_clone(Tablet* tablet, const string& clone_di
tablet->release_base_compaction_lock();
// clear clone dir
- boost::filesystem::path clone_dir_path(clone_dir);
- boost::filesystem::remove_all(clone_dir_path);
+ std::filesystem::path clone_dir_path(clone_dir);
+ std::filesystem::remove_all(clone_dir_path);
LOG(INFO) << "finish to clone data, clear downloaded data. res=" << res
<< ", tablet=" << tablet->full_name() << ", clone_dir=" << clone_dir;
return res;
diff --git a/be/src/olap/txn_manager.cpp b/be/src/olap/txn_manager.cpp
index 6349e72..81d135e 100644
--- a/be/src/olap/txn_manager.cpp
+++ b/be/src/olap/txn_manager.cpp
@@ -25,7 +25,7 @@
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <cstdio>
#include <new>
#include <queue>
@@ -50,10 +50,10 @@
#include "util/time.h"
using apache::thrift::ThriftDebugString;
-using boost::filesystem::canonical;
-using boost::filesystem::directory_iterator;
-using boost::filesystem::path;
-using boost::filesystem::recursive_directory_iterator;
+using std::filesystem::canonical;
+using std::filesystem::directory_iterator;
+using std::filesystem::path;
+using std::filesystem::recursive_directory_iterator;
using std::back_inserter;
using std::copy;
using std::inserter;
diff --git a/be/src/olap/utils.cpp b/be/src/olap/utils.cpp
index ec22d04..3f51e5e 100644
--- a/be/src/olap/utils.cpp
+++ b/be/src/olap/utils.cpp
@@ -26,7 +26,7 @@
#include <time.h>
#include <unistd.h>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <boost/regex.hpp>
#include <cstdint>
#include <cstring>
@@ -583,8 +583,8 @@ OLAPStatus gen_timestamp_string(string* out_string) {
// 两个参数都必须传路径,
// schema_hash_root用于计算trash位置,file_path用于唯一确定要删的文件
-OLAPStatus move_to_trash(const boost::filesystem::path& schema_hash_root,
- const boost::filesystem::path& file_path) {
+OLAPStatus move_to_trash(const std::filesystem::path& schema_hash_root,
+ const std::filesystem::path& file_path) {
OLAPStatus res = OLAP_SUCCESS;
string old_file_path = file_path.string();
string old_file_name = file_path.filename().string();
@@ -800,24 +800,24 @@ bool check_datapath_rw(const string& path) {
}
OLAPStatus copy_dir(const string& src_dir, const string& dst_dir) {
- boost::filesystem::path src_path(src_dir.c_str());
- boost::filesystem::path dst_path(dst_dir.c_str());
+ std::filesystem::path src_path(src_dir);
+ std::filesystem::path dst_path(dst_dir);
try {
// Check whether the function call is valid
- if (!boost::filesystem::exists(src_path) || !boost::filesystem::is_directory(src_path)) {
+ if (!std::filesystem::exists(src_path) || !std::filesystem::is_directory(src_path)) {
OLAP_LOG_WARNING("Source dir not exist or is not a dir.[src_path=%s]",
src_path.string().c_str());
return OLAP_ERR_CREATE_FILE_ERROR;
}
- if (boost::filesystem::exists(dst_path)) {
+ if (std::filesystem::exists(dst_path)) {
LOG(WARNING) << "Dst dir already exists.[dst_path=" << dst_path.string() << "]";
return OLAP_ERR_CREATE_FILE_ERROR;
}
// Create the destination directory
- if (!boost::filesystem::create_directory(dst_path)) {
+ if (!std::filesystem::create_directory(dst_path)) {
LOG(WARNING) << "Unable to create dst dir.[dst_path=" << dst_path.string() << "]";
return OLAP_ERR_CREATE_FILE_ERROR;
}
@@ -829,11 +829,11 @@ OLAPStatus copy_dir(const string& src_dir, const string& dst_dir) {
}
// Iterate through the source directory
- for (boost::filesystem::directory_iterator file(src_path);
- file != boost::filesystem::directory_iterator(); ++file) {
+ for (std::filesystem::directory_iterator file(src_path);
+ file != std::filesystem::directory_iterator(); ++file) {
try {
- boost::filesystem::path current(file->path());
- if (boost::filesystem::is_directory(current)) {
+ std::filesystem::path current = file->path();
+ if (std::filesystem::is_directory(current)) {
// Found directory: Recursion
OLAPStatus res = OLAP_SUCCESS;
if (OLAP_SUCCESS !=
@@ -845,7 +845,7 @@ OLAPStatus copy_dir(const string& src_dir, const string& dst_dir) {
}
} else {
// Found file: Copy
- boost::filesystem::copy_file(current, (dst_path / current.filename()).string());
+ std::filesystem::copy_file(current, (dst_path / current.filename()).string());
}
} catch (...) {
OLAP_LOG_WARNING("Fail to copy file.[src_path=%s dst_path=%s]",
diff --git a/be/src/olap/utils.h b/be/src/olap/utils.h
index 67dda93..4f7d6bd 100644
--- a/be/src/olap/utils.h
+++ b/be/src/olap/utils.h
@@ -23,7 +23,7 @@
#include <sys/time.h>
#include <zlib.h>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <cstdio>
#include <cstdlib>
#include <exception>
@@ -137,8 +137,8 @@ OLAPStatus gen_timestamp_string(std::string* out_string);
// 将file移到回收站,回收站位于storage_root/trash, file可以是文件或目录
// 移动的同时将file改名:storage_root/trash/20150619154308/file
-OLAPStatus move_to_trash(const boost::filesystem::path& schema_hash_root,
- const boost::filesystem::path& file_path);
+OLAPStatus move_to_trash(const std::filesystem::path& schema_hash_root,
+ const std::filesystem::path& file_path);
enum ComparatorEnum {
COMPARATOR_LESS = 0,
diff --git a/be/src/runtime/etl_job_mgr.cpp b/be/src/runtime/etl_job_mgr.cpp
index 0ec8eb2..155141d 100644
--- a/be/src/runtime/etl_job_mgr.cpp
+++ b/be/src/runtime/etl_job_mgr.cpp
@@ -17,7 +17,7 @@
#include "runtime/etl_job_mgr.h"
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <functional>
#include "gen_cpp/FrontendService.h"
@@ -155,7 +155,7 @@ void EtlJobMgr::finalize_job(PlanFragmentExecutor* executor) {
if (executor->status().ok()) {
// Get files
for (auto& it : state->output_files()) {
- int64_t file_size = boost::filesystem::file_size(it);
+ int64_t file_size = std::filesystem::file_size(it);
result.file_map[to_http_path(it)] = file_size;
}
// set statistics
diff --git a/be/src/runtime/snapshot_loader.cpp b/be/src/runtime/snapshot_loader.cpp
index eccd0b0..3284493 100644
--- a/be/src/runtime/snapshot_loader.cpp
+++ b/be/src/runtime/snapshot_loader.cpp
@@ -394,16 +394,16 @@ Status SnapshotLoader::move(const std::string& snapshot_path, TabletSharedPtr ta
return Status::InternalError(ss.str());
}
- boost::filesystem::path tablet_dir(tablet_path);
- boost::filesystem::path snapshot_dir(snapshot_path);
- if (!boost::filesystem::exists(tablet_dir)) {
+ std::filesystem::path tablet_dir(tablet_path);
+ std::filesystem::path snapshot_dir(snapshot_path);
+ if (!std::filesystem::exists(tablet_dir)) {
std::stringstream ss;
ss << "tablet path does not exist: " << tablet_path;
LOG(WARNING) << ss.str();
return Status::InternalError(ss.str());
}
- if (!boost::filesystem::exists(snapshot_dir)) {
+ if (!std::filesystem::exists(snapshot_dir)) {
std::stringstream ss;
ss << "snapshot path does not exist: " << snapshot_path;
LOG(WARNING) << ss.str();
@@ -430,11 +430,11 @@ Status SnapshotLoader::move(const std::string& snapshot_path, TabletSharedPtr ta
// This remove seems soft enough, because we already get
// tablet id and schema hash from this path, which
// means this path is a valid path.
- boost::filesystem::remove_all(tablet_dir);
+ std::filesystem::remove_all(tablet_dir);
VLOG_CRITICAL << "remove dir: " << tablet_dir;
- boost::filesystem::create_directory(tablet_dir);
+ std::filesystem::create_directory(tablet_dir);
VLOG_CRITICAL << "re-create dir: " << tablet_dir;
- } catch (const boost::filesystem::filesystem_error& e) {
+ } catch (const std::filesystem::filesystem_error& e) {
std::stringstream ss;
ss << "failed to move tablet path: " << tablet_path << ". err: " << e.what();
LOG(WARNING) << ss.str();
diff --git a/be/src/runtime/tmp_file_mgr.cc b/be/src/runtime/tmp_file_mgr.cc
index a81a599..090a464 100644
--- a/be/src/runtime/tmp_file_mgr.cc
+++ b/be/src/runtime/tmp_file_mgr.cc
@@ -18,7 +18,7 @@
#include "runtime/tmp_file_mgr.h"
#include <boost/algorithm/string.hpp>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/thread/locks.hpp>
@@ -38,8 +38,8 @@ using boost::algorithm::is_any_of;
using boost::algorithm::join;
using boost::algorithm::split;
using boost::algorithm::token_compress_on;
-using boost::filesystem::absolute;
-using boost::filesystem::path;
+using std::filesystem::absolute;
+using std::filesystem::path;
using boost::uuids::random_generator;
using std::string;
@@ -84,8 +84,8 @@ Status TmpFileMgr::init_custom(const vector<string>& tmp_dirs, bool one_dir_per_
// For each tmp directory, find the disk it is on,
// so additional tmp directories on the same disk can be skipped.
for (int i = 0; i < tmp_dirs.size(); ++i) {
- boost::filesystem::path tmp_path(boost::trim_right_copy_if(tmp_dirs[i], is_any_of("/")));
- tmp_path = boost::filesystem::absolute(tmp_path);
+ std::filesystem::path tmp_path = std::string_view(boost::trim_right_copy_if(tmp_dirs[i], is_any_of("/")));
+ tmp_path = std::filesystem::absolute(tmp_path);
path scratch_subdir_path(tmp_path / _s_tmp_sub_dir_name);
// tmp_path must be a writable directory.
Status status = FileSystemUtil::verify_is_directory(tmp_path.string());
diff --git a/be/src/tools/meta_tool.cpp b/be/src/tools/meta_tool.cpp
index 99e6614..39fe84b 100644
--- a/be/src/tools/meta_tool.cpp
+++ b/be/src/tools/meta_tool.cpp
@@ -17,7 +17,8 @@
#include <gflags/gflags.h>
-#include <boost/filesystem.hpp>
+#include <filesystem>
+#include <fstream>
#include <iostream>
#include <set>
#include <sstream>
@@ -43,7 +44,7 @@
#include "util/crc32c.h"
#include "util/file_utils.h"
-using boost::filesystem::path;
+using std::filesystem::path;
using doris::DataDir;
using doris::OLAP_SUCCESS;
using doris::OlapMeta;
diff --git a/be/src/util/broker_storage_backend.cpp b/be/src/util/broker_storage_backend.cpp
index c0ec365..75fb224 100644
--- a/be/src/util/broker_storage_backend.cpp
+++ b/be/src/util/broker_storage_backend.cpp
@@ -55,7 +55,7 @@ Status BrokerStorageBackend::download(const std::string& remote, const std::stri
RETURN_IF_ERROR(broker_reader->open());
// 2. remove the existing local file if exist
- if (boost::filesystem::remove(local)) {
+ if (std::filesystem::remove(local)) {
VLOG(2) << "remove the previously exist local file: " << local;
}
diff --git a/be/src/util/cpu_info.cpp b/be/src/util/cpu_info.cpp
index f99375b..304eec1 100644
--- a/be/src/util/cpu_info.cpp
+++ b/be/src/util/cpu_info.cpp
@@ -42,7 +42,7 @@
#include <algorithm>
#include <boost/algorithm/string.hpp>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <fstream>
#include <iostream>
#include <sstream>
@@ -56,7 +56,7 @@
using boost::algorithm::contains;
using boost::algorithm::trim;
-namespace fs = boost::filesystem;
+namespace fs = std::filesystem;
using std::max;
DECLARE_bool(abort_on_config_error);
diff --git a/be/src/util/file_utils.cpp b/be/src/util/file_utils.cpp
index 0a52d14..8825226 100644
--- a/be/src/util/file_utils.cpp
+++ b/be/src/util/file_utils.cpp
@@ -24,8 +24,7 @@
#include <sys/types.h>
#include <algorithm>
-#include <boost/filesystem.hpp>
-#include <boost/system/error_code.hpp>
+#include <filesystem>
#include <iomanip>
#include <sstream>
@@ -45,10 +44,10 @@ Status FileUtils::create_dir(const std::string& path, Env* env) {
return Status::InvalidArgument(strings::Substitute("Unknown primitive type($0)", path));
}
- boost::filesystem::path p(path);
+ std::filesystem::path p(path);
std::string partial_path;
- for (boost::filesystem::path::iterator it = p.begin(); it != p.end(); ++it) {
+ for (std::filesystem::path::iterator it = p.begin(); it != p.end(); ++it) {
partial_path = partial_path + it->string() + "/";
bool is_dir = false;
@@ -84,10 +83,10 @@ Status FileUtils::create_dir(const std::string& dir_path) {
}
Status FileUtils::remove_all(const std::string& file_path) {
- boost::filesystem::path boost_path(file_path);
- boost::system::error_code ec;
- boost::filesystem::remove_all(boost_path, ec);
- if (ec != boost::system::errc::success) {
+ std::filesystem::path boost_path(file_path);
+ std::error_code ec;
+ std::filesystem::remove_all(boost_path, ec);
+ if (ec) {
std::stringstream ss;
ss << "remove all(" << file_path << ") failed, because: " << ec;
return Status::InternalError(ss.str());
diff --git a/be/src/util/filesystem_util.cc b/be/src/util/filesystem_util.cc
index e4ad06e..6f4ebf7 100644
--- a/be/src/util/filesystem_util.cc
+++ b/be/src/util/filesystem_util.cc
@@ -21,28 +21,25 @@
#include <sys/resource.h>
#include <sys/stat.h>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include "util/error_util.h"
-namespace errc = boost::system::errc;
-namespace filesystem = boost::filesystem;
-
-using boost::system::error_code;
+using std::error_code;
using std::exception;
using std::string;
using std::vector;
-// boost::filesystem functions must be given an errcode parameter to avoid the variants
+// std::filesystem functions must be given an errcode parameter to avoid the variants
// of those functions that throw exceptions.
namespace doris {
Status FileSystemUtil::create_directory(const string& directory) {
error_code errcode;
- bool exists = filesystem::exists(directory, errcode);
+ bool exists = std::filesystem::exists(directory, errcode);
// Need to check for no_such_file_or_directory error case - Boost's exists() sometimes
// returns an error when it should simply return false.
- if (errcode != errc::success && errcode != errc::no_such_file_or_directory) {
+ if (errcode && errcode != std::errc::no_such_file_or_directory) {
std::stringstream error_msg;
error_msg << "Encountered error checking existence of directory: " << directory << ": "
<< errcode.message();
@@ -51,15 +48,15 @@ Status FileSystemUtil::create_directory(const string& directory) {
if (exists) {
// Attempt to remove the directory and its contents so that we can create a fresh
// empty directory that we will have permissions for.
- filesystem::remove_all(directory, errcode);
- if (errcode != errc::success) {
+ std::filesystem::remove_all(directory, errcode);
+ if (errcode) {
std::stringstream error_msg;
error_msg << "Encountered error removing directory " << directory << errcode.message();
return Status::InternalError(error_msg.str());
}
}
- filesystem::create_directories(directory, errcode);
- if (errcode != errc::success) {
+ std::filesystem::create_directories(directory, errcode);
+ if (errcode) {
std::stringstream error_msg;
error_msg << "Encountered error creating directory " << directory << errcode.message();
return Status::InternalError(error_msg.str());
@@ -70,8 +67,8 @@ Status FileSystemUtil::create_directory(const string& directory) {
Status FileSystemUtil::remove_paths(const vector<string>& directories) {
for (int i = 0; i < directories.size(); ++i) {
error_code errcode;
- filesystem::remove_all(directories[i], errcode);
- if (errcode != errc::success) {
+ std::filesystem::remove_all(directories[i], errcode);
+ if (errcode) {
std::stringstream error_msg;
error_msg << "Encountered error removing directory " << directories[i] << ": "
<< errcode.message();
@@ -117,8 +114,8 @@ Status FileSystemUtil::resize_file(const string& file_path, int64_t trunc_len) {
Status FileSystemUtil::verify_is_directory(const string& directory_path) {
error_code errcode;
- bool exists = filesystem::exists(directory_path, errcode);
- if (errcode != errc::success) {
+ bool exists = std::filesystem::exists(directory_path, errcode);
+ if (errcode) {
std::stringstream error_msg;
error_msg << "Encountered exception while verifying existence of directory path "
<< directory_path << ": " << errcode.message();
@@ -129,8 +126,8 @@ Status FileSystemUtil::verify_is_directory(const string& directory_path) {
error_msg << "Directory path " << directory_path << " does not exist ";
return Status::InternalError(error_msg.str());
}
- bool is_dir = filesystem::is_directory(directory_path, errcode);
- if (errcode != errc::success) {
+ bool is_dir = std::filesystem::is_directory(directory_path, errcode);
+ if (errcode) {
std::stringstream error_msg;
error_msg << "Encountered exception while verifying existence of directory path "
<< directory_path << ": " << errcode.message();
@@ -147,8 +144,8 @@ Status FileSystemUtil::verify_is_directory(const string& directory_path) {
Status FileSystemUtil::get_space_available(const string& directory_path,
uint64_t* available_bytes) {
error_code errcode;
- filesystem::space_info info = filesystem::space(directory_path, errcode);
- if (errcode != errc::success) {
+ std::filesystem::space_info info = std::filesystem::space(directory_path, errcode);
+ if (errcode) {
std::stringstream error_msg;
error_msg << "Encountered exception while checking available space for path "
<< directory_path << ": " << errcode.message();
@@ -169,11 +166,10 @@ uint64_t FileSystemUtil::max_num_file_handles() {
// NOTE: the parent_path and sub_path can either dir or file.
// return true if patent_path == sub_path
bool FileSystemUtil::contain_path(const std::string& parent_path, const std::string& sub_path) {
- boost::filesystem::path parent(parent_path);
- boost::filesystem::path sub(sub_path);
+ std::filesystem::path parent(parent_path);
+ std::filesystem::path sub(sub_path);
parent = parent.lexically_normal();
sub = sub.lexically_normal();
-
if (parent == sub) {
return true;
}
@@ -192,8 +188,14 @@ bool FileSystemUtil::contain_path(const std::string& parent_path, const std::str
if (dir_len > file_len) {
return false;
}
-
- return std::equal(parent.begin(), parent.end(), sub.begin());
+ auto p_it = parent.begin();
+ auto s_it = sub.begin();
+ for (; p_it != parent.end() && !p_it->string().empty(); ++p_it, ++s_it) {
+ if (!(*p_it == *s_it)) {
+ return false;
+ }
+ }
+ return true;
}
} // end namespace doris
diff --git a/be/src/util/path_util.h b/be/src/util/path_util.h
index a3816ef..1376d2c 100644
--- a/be/src/util/path_util.h
+++ b/be/src/util/path_util.h
@@ -55,7 +55,7 @@ std::string dir_name(const std::string& path);
// This is like basename(3) but for C++ strings.
std::string base_name(const std::string& path);
-// It is used to replace boost::filesystem::path::extension().
+// It is used to replace std::filesystem::path::extension().
// If the filename contains a dot but does not consist solely of one or to two dots,
// returns the substring of file_name starting at the rightmost dot and ending at
// the path's end. Otherwise, returns an empty string.
diff --git a/be/test/agent/cgroups_mgr_test.cpp b/be/test/agent/cgroups_mgr_test.cpp
index efa2015..66b8012 100644
--- a/be/test/agent/cgroups_mgr_test.cpp
+++ b/be/test/agent/cgroups_mgr_test.cpp
@@ -18,9 +18,9 @@
#include "agent/cgroups_mgr.h"
#include <algorithm>
+#include <filesystem>
#include <fstream>
-#include "boost/filesystem.hpp"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "util/logging.h"
@@ -42,9 +42,9 @@ class CgroupsMgrTest : public testing::Test {
public:
// create a mock cgroup folder
static void SetUpTestCase() {
- ASSERT_TRUE(boost::filesystem::remove_all(_s_cgroup_path));
+ ASSERT_TRUE(std::filesystem::remove_all(_s_cgroup_path));
// create a mock cgroup path
- ASSERT_TRUE(boost::filesystem::create_directory(_s_cgroup_path));
+ ASSERT_TRUE(std::filesystem::create_directory(_s_cgroup_path));
std::vector<StorePath> paths;
paths.emplace_back(config::storage_root_path, -1);
@@ -56,7 +56,7 @@ public:
}
// delete the mock cgroup folder
- static void TearDownTestCase() { ASSERT_TRUE(boost::filesystem::remove_all(_s_cgroup_path)); }
+ static void TearDownTestCase() { ASSERT_TRUE(std::filesystem::remove_all(_s_cgroup_path)); }
// test if a file contains specific number
static bool does_contain_number(const std::string& file_path, int32_t number) {
@@ -110,13 +110,13 @@ TEST_F(CgroupsMgrTest, TestInitCgroups) {
outfile.close();
// create a mock user under cgroup path
- ASSERT_TRUE(boost::filesystem::create_directory(_s_cgroup_path + "/yiguolei"));
+ ASSERT_TRUE(std::filesystem::create_directory(_s_cgroup_path + "/yiguolei"));
std::ofstream user_out_file(_s_cgroup_path + "/yiguolei/tasks");
user_out_file << 123 << std::endl;
user_out_file.close();
// create a mock user group under cgroup path
- ASSERT_TRUE(boost::filesystem::create_directory(_s_cgroup_path + "/yiguolei/low"));
+ ASSERT_TRUE(std::filesystem::create_directory(_s_cgroup_path + "/yiguolei/low"));
std::ofstream group_out_file(CgroupsMgrTest::_s_cgroup_path + "/yiguolei/low/tasks");
group_out_file << 456 << std::endl;
group_out_file.close();
@@ -136,7 +136,7 @@ TEST_F(CgroupsMgrTest, TestAssignThreadToCgroups) {
ASSERT_EQ(AgentStatus::DORIS_ERROR, op_status);
// user cgroup exist
// create a mock user under cgroup path
- ASSERT_TRUE(boost::filesystem::create_directory(_s_cgroup_path + "/yiguolei2"));
+ ASSERT_TRUE(std::filesystem::create_directory(_s_cgroup_path + "/yiguolei2"));
std::ofstream user_out_file(_s_cgroup_path + "/yiguolei2/tasks");
user_out_file << 123 << std::endl;
user_out_file.close();
@@ -147,7 +147,7 @@ TEST_F(CgroupsMgrTest, TestAssignThreadToCgroups) {
// user,level cgroup exist
// create a mock user group under cgroup path
- ASSERT_TRUE(boost::filesystem::create_directory(_s_cgroup_path + "/yiguolei2/low"));
+ ASSERT_TRUE(std::filesystem::create_directory(_s_cgroup_path + "/yiguolei2/low"));
std::ofstream group_out_file(_s_cgroup_path + "/yiguolei2/low/tasks");
group_out_file << 456 << std::endl;
group_out_file.close();
diff --git a/be/test/olap/byte_buffer_test.cpp b/be/test/olap/byte_buffer_test.cpp
index 0e1e9cd..4d2b5d1 100644
--- a/be/test/olap/byte_buffer_test.cpp
+++ b/be/test/olap/byte_buffer_test.cpp
@@ -17,10 +17,10 @@
#include "olap/byte_buffer.h"
+#include <filesystem>
#include <gtest/gtest.h>
#include <sys/mman.h>
-#include "boost/filesystem.hpp"
#include "common/configbase.h"
#include "olap/file_helper.h"
#include "util/logging.h"
@@ -32,8 +32,8 @@ public:
virtual ~TestByteBuffer() {}
virtual void SetUp() {}
virtual void TearDown() {
- if (boost::filesystem::exists(".test_byte_buffer")) {
- ASSERT_TRUE(boost::filesystem::remove_all(".test_byte_buffer"));
+ if (std::filesystem::exists(".test_byte_buffer")) {
+ ASSERT_TRUE(std::filesystem::remove_all(".test_byte_buffer"));
}
}
};
diff --git a/be/test/olap/file_helper_test.cpp b/be/test/olap/file_helper_test.cpp
index e22bdc1..c015e64 100644
--- a/be/test/olap/file_helper_test.cpp
+++ b/be/test/olap/file_helper_test.cpp
@@ -18,10 +18,10 @@
#include "olap/file_helper.h"
#include <algorithm>
+#include <filesystem>
#include <fstream>
#include "agent/status.h"
-#include "boost/filesystem.hpp"
#include "common/configbase.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
@@ -44,13 +44,13 @@ class FileHandlerTest : public testing::Test {
public:
// create a mock cgroup folder
virtual void SetUp() {
- ASSERT_FALSE(boost::filesystem::exists(_s_test_data_path));
+ ASSERT_FALSE(std::filesystem::exists(_s_test_data_path));
// create a mock cgroup path
- ASSERT_TRUE(boost::filesystem::create_directory(_s_test_data_path));
+ ASSERT_TRUE(std::filesystem::create_directory(_s_test_data_path));
}
// delete the mock cgroup folder
- virtual void TearDown() { ASSERT_TRUE(boost::filesystem::remove_all(_s_test_data_path)); }
+ virtual void TearDown() { ASSERT_TRUE(std::filesystem::remove_all(_s_test_data_path)); }
static std::string _s_test_data_path;
};
@@ -61,11 +61,11 @@ TEST_F(FileHandlerTest, TestWrite) {
FileHandler file_handler;
std::string file_name = _s_test_data_path + "/abcd123.txt";
// create a file using open
- ASSERT_FALSE(boost::filesystem::exists(file_name));
+ ASSERT_FALSE(std::filesystem::exists(file_name));
OLAPStatus op_status =
file_handler.open_with_mode(file_name, O_CREAT | O_EXCL | O_WRONLY, S_IRUSR | S_IWUSR);
ASSERT_EQ(OLAPStatus::OLAP_SUCCESS, op_status);
- ASSERT_TRUE(boost::filesystem::exists(file_name));
+ ASSERT_TRUE(std::filesystem::exists(file_name));
// tell current offset
off_t cur_offset = file_handler.tell();
diff --git a/be/test/olap/file_utils_test.cpp b/be/test/olap/file_utils_test.cpp
index 191cefb..a7ee9cd 100644
--- a/be/test/olap/file_utils_test.cpp
+++ b/be/test/olap/file_utils_test.cpp
@@ -18,12 +18,12 @@
#include "util/file_utils.h"
#include <algorithm>
+#include <filesystem>
#include <fstream>
#include <set>
#include <vector>
#include "agent/status.h"
-#include "boost/filesystem.hpp"
#include "common/configbase.h"
#include "env/env.h"
#include "gmock/gmock.h"
@@ -47,13 +47,19 @@ class FileUtilsTest : public testing::Test {
public:
// create a mock cgroup folder
virtual void SetUp() {
- ASSERT_FALSE(boost::filesystem::exists(_s_test_data_path));
+ ASSERT_FALSE(std::filesystem::exists(_s_test_data_path));
// create a mock cgroup path
- ASSERT_TRUE(boost::filesystem::create_directory(_s_test_data_path));
+ ASSERT_TRUE(std::filesystem::create_directory(_s_test_data_path));
+ }
+ void save_string_file(const std::filesystem::path& filename, const std::string& content) {
+ std::ofstream file;
+ file.exceptions(std::ofstream::failbit | std::ofstream::badbit);
+ file.open(filename, std::ios_base::binary);
+ file.write(content.c_str(), content.size());
}
// delete the mock cgroup folder
- virtual void TearDown() { ASSERT_TRUE(boost::filesystem::remove_all(_s_test_data_path)); }
+ virtual void TearDown() { ASSERT_TRUE(std::filesystem::remove_all(_s_test_data_path)); }
static std::string _s_test_data_path;
};
@@ -64,11 +70,11 @@ TEST_F(FileUtilsTest, TestCopyFile) {
FileHandler src_file_handler;
std::string src_file_name = _s_test_data_path + "/abcd12345.txt";
// create a file using open
- ASSERT_FALSE(boost::filesystem::exists(src_file_name));
+ ASSERT_FALSE(std::filesystem::exists(src_file_name));
OLAPStatus op_status = src_file_handler.open_with_mode(
src_file_name, O_CREAT | O_EXCL | O_WRONLY, S_IRUSR | S_IWUSR);
ASSERT_EQ(OLAPStatus::OLAP_SUCCESS, op_status);
- ASSERT_TRUE(boost::filesystem::exists(src_file_name));
+ ASSERT_TRUE(std::filesystem::exists(src_file_name));
char* large_bytes2[(1 << 12)];
memset(large_bytes2, 0, sizeof(char) * ((1 << 12)));
@@ -98,8 +104,8 @@ TEST_F(FileUtilsTest, TestRemove) {
ASSERT_TRUE(FileUtils::create_dir("./file_test/abc/def/zxc").ok());
ASSERT_TRUE(FileUtils::create_dir("./file_test/abc/123").ok());
- boost::filesystem::save_string_file("./file_test/s1", "123");
- boost::filesystem::save_string_file("./file_test/123/s2", "123");
+ save_string_file("./file_test/s1", "123");
+ save_string_file("./file_test/123/s2", "123");
ASSERT_TRUE(FileUtils::check_exist("./file_test"));
ASSERT_TRUE(FileUtils::remove_all("./file_test").ok());
@@ -107,7 +113,7 @@ TEST_F(FileUtilsTest, TestRemove) {
// remove
ASSERT_TRUE(FileUtils::create_dir("./file_test/abc/123").ok());
- boost::filesystem::save_string_file("./file_test/abc/123/s2", "123");
+ save_string_file("./file_test/abc/123/s2", "123");
ASSERT_FALSE(FileUtils::remove("./file_test").ok());
ASSERT_FALSE(FileUtils::remove("./file_test/abc/").ok());
@@ -127,8 +133,8 @@ TEST_F(FileUtilsTest, TestRemove) {
// remove paths
ASSERT_TRUE(FileUtils::create_dir("./file_test/123/456/789").ok());
ASSERT_TRUE(FileUtils::create_dir("./file_test/abc/def/zxc").ok());
- boost::filesystem::save_string_file("./file_test/s1", "123");
- boost::filesystem::save_string_file("./file_test/s2", "123");
+ save_string_file("./file_test/s1", "123");
+ save_string_file("./file_test/s2", "123");
std::vector<std::string> ps;
ps.push_back("./file_test/123/456/789");
@@ -222,9 +228,9 @@ TEST_F(FileUtilsTest, TestListDirsFiles) {
ASSERT_EQ(5, dirs.size());
ASSERT_EQ(0, files.size());
- boost::filesystem::save_string_file("./file_test/f1", "just test");
- boost::filesystem::save_string_file("./file_test/f2", "just test");
- boost::filesystem::save_string_file("./file_test/f3", "just test");
+ save_string_file("./file_test/f1", "just test");
+ save_string_file("./file_test/f2", "just test");
+ save_string_file("./file_test/f3", "just test");
dirs.clear();
files.clear();
diff --git a/be/test/olap/olap_meta_test.cpp b/be/test/olap/olap_meta_test.cpp
index 5d13abd..4ba0abb 100644
--- a/be/test/olap/olap_meta_test.cpp
+++ b/be/test/olap/olap_meta_test.cpp
@@ -19,7 +19,7 @@
#include <gtest/gtest.h>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <sstream>
#include <string>
@@ -44,7 +44,7 @@ public:
_meta = new OlapMeta(_root_path);
OLAPStatus s = _meta->init();
ASSERT_EQ(OLAP_SUCCESS, s);
- ASSERT_TRUE(boost::filesystem::exists(_root_path + "/meta"));
+ ASSERT_TRUE(std::filesystem::exists(_root_path + "/meta"));
}
virtual void TearDown() {
diff --git a/be/test/olap/olap_snapshot_converter_test.cpp b/be/test/olap/olap_snapshot_converter_test.cpp
index 222d7db..b91c911 100644
--- a/be/test/olap/olap_snapshot_converter_test.cpp
+++ b/be/test/olap/olap_snapshot_converter_test.cpp
@@ -18,12 +18,12 @@
#include "olap/olap_snapshot_converter.h"
#include <boost/algorithm/string.hpp>
+#include <filesystem>
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
-#include "boost/filesystem.hpp"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "json2pb/json_to_pb.h"
@@ -64,26 +64,26 @@ public:
string test_engine_data_path = "./be/test/olap/test_data/converter_test_data/data";
_engine_data_path = "./be/test/olap/test_data/converter_test_data/tmp";
- boost::filesystem::remove_all(_engine_data_path);
+ std::filesystem::remove_all(_engine_data_path);
FileUtils::create_dir(_engine_data_path);
_data_dir = new DataDir(_engine_data_path, 1000000000);
_data_dir->init();
_meta_path = "./meta";
string tmp_data_path = _engine_data_path + "/data";
- if (boost::filesystem::exists(tmp_data_path)) {
- boost::filesystem::remove_all(tmp_data_path);
+ if (std::filesystem::exists(tmp_data_path)) {
+ std::filesystem::remove_all(tmp_data_path);
}
copy_dir(test_engine_data_path, tmp_data_path);
_tablet_id = 15007;
_schema_hash = 368169781;
_tablet_data_path = tmp_data_path + "/" + std::to_string(0) + "/" +
std::to_string(_tablet_id) + "/" + std::to_string(_schema_hash);
- if (boost::filesystem::exists(_meta_path)) {
- boost::filesystem::remove_all(_meta_path);
+ if (std::filesystem::exists(_meta_path)) {
+ std::filesystem::remove_all(_meta_path);
}
- ASSERT_TRUE(boost::filesystem::create_directory(_meta_path));
- ASSERT_TRUE(boost::filesystem::exists(_meta_path));
+ ASSERT_TRUE(std::filesystem::create_directory(_meta_path));
+ ASSERT_TRUE(std::filesystem::exists(_meta_path));
_meta = new (std::nothrow) OlapMeta(_meta_path);
ASSERT_NE(nullptr, _meta);
OLAPStatus st = _meta->init();
@@ -93,11 +93,11 @@ public:
virtual void TearDown() {
delete _meta;
delete _data_dir;
- if (boost::filesystem::exists(_meta_path)) {
- ASSERT_TRUE(boost::filesystem::remove_all(_meta_path));
+ if (std::filesystem::exists(_meta_path)) {
+ ASSERT_TRUE(std::filesystem::remove_all(_meta_path));
}
- if (boost::filesystem::exists(_engine_data_path)) {
- ASSERT_TRUE(boost::filesystem::remove_all(_engine_data_path));
+ if (std::filesystem::exists(_engine_data_path)) {
+ ASSERT_TRUE(std::filesystem::remove_all(_engine_data_path));
}
}
diff --git a/be/test/olap/options_test.cpp b/be/test/olap/options_test.cpp
index 14e1a1b..78d88f8 100644
--- a/be/test/olap/options_test.cpp
+++ b/be/test/olap/options_test.cpp
@@ -18,8 +18,8 @@
#include "olap/options.h"
#include <gtest/gtest.h>
+#include <filesystem>
-#include <boost/filesystem.hpp>
#include <string>
namespace doris {
@@ -40,7 +40,7 @@ public:
};
TEST_F(OptionsTest, parse_root_path) {
- std::string path_prefix = boost::filesystem::system_complete("./test_run").string();
+ std::string path_prefix = std::filesystem::absolute("./test_run").string();
std::string path1 = path_prefix + "/palo";
std::string path2 = path_prefix + "/palo.ssd";
diff --git a/be/test/olap/rowset/alpha_rowset_test.cpp b/be/test/olap/rowset/alpha_rowset_test.cpp
index 509b08e..4229460 100644
--- a/be/test/olap/rowset/alpha_rowset_test.cpp
+++ b/be/test/olap/rowset/alpha_rowset_test.cpp
@@ -17,11 +17,11 @@
#include "olap/rowset/alpha_rowset.h"
+#include <filesystem>
#include <fstream>
#include <sstream>
#include <string>
-#include "boost/filesystem.hpp"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "json2pb/json_to_pb.h"
diff --git a/be/test/olap/rowset/rowset_converter_test.cpp b/be/test/olap/rowset/rowset_converter_test.cpp
index 867c711..fece436 100644
--- a/be/test/olap/rowset/rowset_converter_test.cpp
+++ b/be/test/olap/rowset/rowset_converter_test.cpp
@@ -21,7 +21,6 @@
#include <sstream>
#include <string>
-#include "boost/filesystem.hpp"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "json2pb/json_to_pb.h"
diff --git a/be/test/olap/rowset/rowset_meta_manager_test.cpp b/be/test/olap/rowset/rowset_meta_manager_test.cpp
index db2dd81..b8a448a 100644
--- a/be/test/olap/rowset/rowset_meta_manager_test.cpp
+++ b/be/test/olap/rowset/rowset_meta_manager_test.cpp
@@ -18,10 +18,10 @@
#include "olap/rowset/rowset_meta_manager.h"
#include <fstream>
+#include <filesystem>
#include <sstream>
#include <string>
-#include "boost/filesystem.hpp"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "json2pb/json_to_pb.h"
@@ -57,12 +57,12 @@ public:
}
std::string meta_path = "./meta";
- ASSERT_TRUE(boost::filesystem::create_directory(meta_path));
+ ASSERT_TRUE(std::filesystem::create_directory(meta_path));
_meta = new (std::nothrow) OlapMeta(meta_path);
ASSERT_NE(nullptr, _meta);
OLAPStatus st = _meta->init();
ASSERT_TRUE(st == OLAP_SUCCESS);
- ASSERT_TRUE(boost::filesystem::exists("./meta"));
+ ASSERT_TRUE(std::filesystem::exists("./meta"));
std::ifstream infile(rowset_meta_path);
char buffer[1024];
@@ -77,7 +77,7 @@ public:
virtual void TearDown() {
delete _meta;
- ASSERT_TRUE(boost::filesystem::remove_all("./meta"));
+ ASSERT_TRUE(std::filesystem::remove_all("./meta"));
}
private:
diff --git a/be/test/olap/rowset/rowset_meta_test.cpp b/be/test/olap/rowset/rowset_meta_test.cpp
index 896f730..e8b577b 100644
--- a/be/test/olap/rowset/rowset_meta_test.cpp
+++ b/be/test/olap/rowset/rowset_meta_test.cpp
@@ -18,10 +18,10 @@
#include "olap/rowset/rowset_meta.h"
#include <fstream>
+#include <filesystem>
#include <sstream>
#include <string>
-#include "boost/filesystem.hpp"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "json2pb/json_to_pb.h"
@@ -45,12 +45,12 @@ class RowsetMetaTest : public testing::Test {
public:
virtual void SetUp() {
std::string meta_path = "./meta";
- ASSERT_TRUE(boost::filesystem::create_directory(meta_path));
+ ASSERT_TRUE(std::filesystem::create_directory(meta_path));
_meta = new (std::nothrow) OlapMeta(meta_path);
ASSERT_NE(nullptr, _meta);
OLAPStatus st = _meta->init();
ASSERT_TRUE(st == OLAP_SUCCESS);
- ASSERT_TRUE(boost::filesystem::exists("./meta"));
+ ASSERT_TRUE(std::filesystem::exists("./meta"));
std::ifstream infile(rowset_meta_path);
char buffer[1024];
@@ -64,7 +64,7 @@ public:
virtual void TearDown() {
delete _meta;
- ASSERT_TRUE(boost::filesystem::remove_all("./meta"));
+ ASSERT_TRUE(std::filesystem::remove_all("./meta"));
}
private:
diff --git a/be/test/olap/rowset/segment_v2/segment_test.cpp b/be/test/olap/rowset/segment_v2/segment_test.cpp
index 34291ea..96d9dbe 100644
--- a/be/test/olap/rowset/segment_v2/segment_test.cpp
+++ b/be/test/olap/rowset/segment_v2/segment_test.cpp
@@ -19,7 +19,7 @@
#include <gtest/gtest.h>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <functional>
#include <iostream>
@@ -644,7 +644,7 @@ TEST_F(SegmentReaderWriterTest, estimate_segment_size) {
ASSERT_TRUE(writer.finalize(&file_size, &index_size).ok());
ASSERT_TRUE(wblock->close().ok());
- file_size = boost::filesystem::file_size(fname);
+ file_size = std::filesystem::file_size(fname);
LOG(INFO) << "segment file size is:" << file_size;
ASSERT_NE(segment_size, 0);
diff --git a/be/test/olap/tablet_meta_manager_test.cpp b/be/test/olap/tablet_meta_manager_test.cpp
index 7820ce2..2cb7604 100644
--- a/be/test/olap/tablet_meta_manager_test.cpp
+++ b/be/test/olap/tablet_meta_manager_test.cpp
@@ -20,7 +20,7 @@
#include <gtest/gtest.h>
#include <json2pb/json_to_pb.h>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <fstream>
#include <sstream>
#include <string>
@@ -43,12 +43,12 @@ class TabletMetaManagerTest : public testing::Test {
public:
virtual void SetUp() {
std::string root_path = "./store";
- ASSERT_TRUE(boost::filesystem::create_directory(root_path));
+ ASSERT_TRUE(std::filesystem::create_directory(root_path));
_data_dir = new (std::nothrow) DataDir(root_path);
ASSERT_NE(nullptr, _data_dir);
Status st = _data_dir->init();
ASSERT_TRUE(st.ok());
- ASSERT_TRUE(boost::filesystem::exists(root_path + "/meta"));
+ ASSERT_TRUE(std::filesystem::exists(root_path + "/meta"));
std::ifstream infile(meta_path);
char buffer[1024];
@@ -62,7 +62,7 @@ public:
virtual void TearDown() {
delete _data_dir;
- ASSERT_TRUE(boost::filesystem::remove_all("./store"));
+ ASSERT_TRUE(std::filesystem::remove_all("./store"));
}
private:
diff --git a/be/test/olap/tablet_mgr_test.cpp b/be/test/olap/tablet_mgr_test.cpp
index c74959a..682a35a 100644
--- a/be/test/olap/tablet_mgr_test.cpp
+++ b/be/test/olap/tablet_mgr_test.cpp
@@ -16,10 +16,10 @@
// under the License.
#include <fstream>
+#include <filesystem>
#include <sstream>
#include <string>
-#include "boost/filesystem.hpp"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "json2pb/json_to_pb.h"
@@ -50,7 +50,7 @@ public:
virtual void SetUp() {
string test_engine_data_path = "./be/test/olap/test_data/converter_test_data/data";
_engine_data_path = "./be/test/olap/test_data/converter_test_data/tmp";
- boost::filesystem::remove_all(_engine_data_path);
+ std::filesystem::remove_all(_engine_data_path);
FileUtils::create_dir(_engine_data_path);
FileUtils::create_dir(_engine_data_path + "/meta");
@@ -67,8 +67,8 @@ public:
_data_dir = new DataDir(_engine_data_path, 1000000000);
_data_dir->init();
string tmp_data_path = _engine_data_path + "/data";
- if (boost::filesystem::exists(tmp_data_path)) {
- boost::filesystem::remove_all(tmp_data_path);
+ if (std::filesystem::exists(tmp_data_path)) {
+ std::filesystem::remove_all(tmp_data_path);
}
copy_dir(test_engine_data_path, tmp_data_path);
_tablet_id = 15007;
@@ -80,8 +80,8 @@ public:
virtual void TearDown() {
delete _data_dir;
- if (boost::filesystem::exists(_engine_data_path)) {
- ASSERT_TRUE(boost::filesystem::remove_all(_engine_data_path));
+ if (std::filesystem::exists(_engine_data_path)) {
+ ASSERT_TRUE(std::filesystem::remove_all(_engine_data_path));
}
}
diff --git a/be/test/olap/timestamped_version_tracker_test.cpp b/be/test/olap/timestamped_version_tracker_test.cpp
index 5c23164..c8494ea 100644
--- a/be/test/olap/timestamped_version_tracker_test.cpp
+++ b/be/test/olap/timestamped_version_tracker_test.cpp
@@ -19,9 +19,9 @@
#include <gtest/gtest.h>
#include <fstream>
+#include <filesystem>
#include <sstream>
-#include "boost/filesystem.hpp"
#include "gutil/strings/substitute.h"
#include "json2pb/json_to_pb.h"
#include "olap/olap_meta.h"
diff --git a/be/test/olap/txn_manager_test.cpp b/be/test/olap/txn_manager_test.cpp
index 8bf3f77..69d20ba 100644
--- a/be/test/olap/txn_manager_test.cpp
+++ b/be/test/olap/txn_manager_test.cpp
@@ -18,10 +18,10 @@
#include "olap/txn_manager.h"
#include <fstream>
+#include <filesystem>
#include <sstream>
#include <string>
-#include "boost/filesystem.hpp"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "json2pb/json_to_pb.h"
@@ -108,13 +108,13 @@ public:
}
std::string meta_path = "./meta";
- boost::filesystem::remove_all("./meta");
- ASSERT_TRUE(boost::filesystem::create_directory(meta_path));
+ std::filesystem::remove_all("./meta");
+ ASSERT_TRUE(std::filesystem::create_directory(meta_path));
_meta = new (std::nothrow) OlapMeta(meta_path);
ASSERT_NE(nullptr, _meta);
OLAPStatus st = _meta->init();
ASSERT_TRUE(st == OLAP_SUCCESS);
- ASSERT_TRUE(boost::filesystem::exists("./meta"));
+ ASSERT_TRUE(std::filesystem::exists("./meta"));
load_id.set_hi(0);
load_id.set_lo(0);
@@ -159,7 +159,7 @@ public:
virtual void TearDown() {
delete _meta;
- ASSERT_TRUE(boost::filesystem::remove_all("./meta"));
+ ASSERT_TRUE(std::filesystem::remove_all("./meta"));
}
private:
diff --git a/be/test/runtime/buffered_block_mgr2_test.cpp b/be/test/runtime/buffered_block_mgr2_test.cpp
index eefa326..bc4723b 100644
--- a/be/test/runtime/buffered_block_mgr2_test.cpp
+++ b/be/test/runtime/buffered_block_mgr2_test.cpp
@@ -22,7 +22,7 @@
#include <boost/bind.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <boost/scoped_ptr.hpp>
#include <boost/thread/thread.hpp>
@@ -37,8 +37,8 @@
#include "util/logging.h"
#include "util/monotime.h"
-using boost::filesystem::directory_iterator;
-using boost::filesystem::remove;
+using std::filesystem::directory_iterator;
+using std::filesystem::remove;
using boost::scoped_ptr;
using boost::unordered_map;
using boost::thread;
diff --git a/be/test/runtime/buffered_tuple_stream2_test.cpp b/be/test/runtime/buffered_tuple_stream2_test.cpp
index 12b5124..dd8d2e5 100644
--- a/be/test/runtime/buffered_tuple_stream2_test.cpp
+++ b/be/test/runtime/buffered_tuple_stream2_test.cpp
@@ -18,7 +18,7 @@
#include <gtest/gtest.h>
#include <boost/bind.hpp>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <boost/scoped_ptr.hpp>
#include <limits> // for std::numeric_limits<int>::max()
#include <string>
diff --git a/be/test/runtime/snapshot_loader_test.cpp b/be/test/runtime/snapshot_loader_test.cpp
index 58fd0dd..7808efe 100644
--- a/be/test/runtime/snapshot_loader_test.cpp
+++ b/be/test/runtime/snapshot_loader_test.cpp
@@ -17,7 +17,7 @@
#include <gtest/gtest.h>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include "runtime/exec_env.h"
#include "util/cpu_info.h"
@@ -55,7 +55,7 @@ TEST_F(SnapshotLoaderTest, NormalCase) {
&schema_hash);
ASSERT_FALSE(st.ok());
- boost::filesystem::remove_all("./ss_test/");
+ std::filesystem::remove_all("./ss_test/");
std::map<std::string, std::string> src_to_dest;
src_to_dest["./ss_test/"] = "./ss_test";
st = loader._check_local_snapshot_paths(src_to_dest, true);
@@ -63,18 +63,18 @@ TEST_F(SnapshotLoaderTest, NormalCase) {
st = loader._check_local_snapshot_paths(src_to_dest, false);
ASSERT_FALSE(st.ok());
- boost::filesystem::create_directory("./ss_test/");
+ std::filesystem::create_directory("./ss_test/");
st = loader._check_local_snapshot_paths(src_to_dest, true);
ASSERT_TRUE(st.ok());
st = loader._check_local_snapshot_paths(src_to_dest, false);
ASSERT_TRUE(st.ok());
- boost::filesystem::remove_all("./ss_test/");
+ std::filesystem::remove_all("./ss_test/");
- boost::filesystem::create_directory("./ss_test/");
+ std::filesystem::create_directory("./ss_test/");
std::vector<std::string> files;
st = loader._get_existing_files_from_local("./ss_test/", &files);
ASSERT_EQ(0, files.size());
- boost::filesystem::remove_all("./ss_test/");
+ std::filesystem::remove_all("./ss_test/");
std::string snapshot_file;
std::string tablet_file;
diff --git a/be/test/runtime/tmp_file_mgr_test.cpp b/be/test/runtime/tmp_file_mgr_test.cpp
index 76dc87f..43fb7fb 100644
--- a/be/test/runtime/tmp_file_mgr_test.cpp
+++ b/be/test/runtime/tmp_file_mgr_test.cpp
@@ -19,7 +19,7 @@
#include <gtest/gtest.h>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <boost/scoped_ptr.hpp>
#include <cstdlib>
@@ -29,7 +29,7 @@
#include "util/logging.h"
#include "util/metrics.h"
-using boost::filesystem::path;
+using std::filesystem::path;
using std::string;
using std::vector;
using std::set;
@@ -74,12 +74,12 @@ TEST_F(TmpFileMgrTest, TestFileAllocation) {
EXPECT_TRUE(status.ok());
EXPECT_EQ(next_offset, offset);
next_offset = offset + write_sizes[i];
- EXPECT_EQ(next_offset, boost::filesystem::file_size(file->path()));
+ EXPECT_EQ(next_offset, std::filesystem::file_size(file->path()));
}
// Check that cleanup is correct.
status = file->remove();
EXPECT_TRUE(status.ok());
- EXPECT_FALSE(boost::filesystem::exists(file->path()));
+ EXPECT_FALSE(std::filesystem::exists(file->path()));
// check_metrics(&tmp_file_mgr);
}
// Test that we can do initialization with two directories on same device and
diff --git a/be/test/util/filesystem_util_test.cpp b/be/test/util/filesystem_util_test.cpp
index ac1d367..f445d44 100644
--- a/be/test/util/filesystem_util_test.cpp
+++ b/be/test/util/filesystem_util_test.cpp
@@ -20,14 +20,14 @@
#include <gtest/gtest.h>
#include <sys/stat.h>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include "common/configbase.h"
#include "util/logging.h"
namespace doris {
-namespace filesystem = boost::filesystem;
+namespace filesystem = std::filesystem;
using filesystem::path;
TEST(FileSystemUtil, rlimit) {
@@ -36,7 +36,8 @@ TEST(FileSystemUtil, rlimit) {
TEST(FileSystemUtil, CreateDirectory) {
// Setup a temporary directory with one subdir
- path dir = filesystem::unique_path();
+ std::string dir_name = std::tmpnam(nullptr);
+ path dir{dir_name};
path subdir1 = dir / "path1";
path subdir2 = dir / "path2";
path subdir3 = dir / "a" / "longer" / "path";
@@ -129,12 +130,6 @@ TEST(FilesystemUtil, contain_path) {
} // end namespace doris
int main(int argc, char** argv) {
- std::string conffile = std::string(getenv("DORIS_HOME")) + "/conf/be.conf";
- if (!doris::config::init(conffile.c_str(), false)) {
- fprintf(stderr, "error read config file. \n");
- return -1;
- }
- doris::init_glog("be-test");
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org