github-actions[bot] commented on code in PR #27726: URL: https://github.com/apache/doris/pull/27726#discussion_r1420887919
########## be/src/olap/wal_manager.cpp: ########## @@ -75,11 +97,45 @@ Status WalManager::init() { } RETURN_IF_ERROR(scan_wals(wal_dir)); } + RETURN_IF_ERROR(init_wal_limit()); return Thread::create( "WalMgr", "replay_wal", [this]() { static_cast<void>(this->replay()); }, &_replay_thread); } +Status WalManager::init_wal_limit() { Review Comment: warning: method 'init_wal_limit' can be made static [readability-convert-member-functions-to-static] be/src/olap/wal_manager.h:78: ```diff - Status init_wal_limit(); + static Status init_wal_limit(); ``` ########## be/src/olap/wal_manager.cpp: ########## @@ -155,7 +211,25 @@ Status WalManager::add_wal_path(int64_t db_id, int64_t table_id, int64_t wal_id, const std::string& label) { std::string base_path = - _wal_dirs.size() == 1 ? _wal_dirs[0] : _wal_dirs[rand() % _wal_dirs.size()]; + _wal_dirs.size() == 1 + ? _wal_dirs[0] + : *std::max_element(_wal_dirs.begin(), _wal_dirs.end(), + [this](const std::string& dir1, const std::string& dir2) { + return _wal_dir_to_disk_usage_map[dir1]->load() < + _wal_dir_to_disk_usage_map[dir2]->load(); + }); + std::stringstream ss; + ss << base_path << "/" << std::to_string(db_id) << "/" << std::to_string(table_id) << "/" + << std::to_string(wal_id) << "_" << label; + { + std::lock_guard<std::shared_mutex> wrlock(_wal_lock); + _wal_path_map.emplace(wal_id, ss.str()); + } + return Status::OK(); +} + +Status WalManager::add_wal_path(int64_t db_id, int64_t table_id, int64_t wal_id, Review Comment: warning: method 'add_wal_path' can be made static [readability-convert-member-functions-to-static] ```suggestion static Status WalManager::add_wal_path(int64_t db_id, int64_t table_id, int64_t wal_id, ``` ########## be/src/olap/wal_writer.cpp: ########## @@ -26,21 +26,15 @@ #include "io/fs/local_file_system.h" #include "io/fs/path.h" #include "olap/storage_engine.h" +#include "olap/wal_manager.h" #include "util/crc32c.h" namespace doris { const char* k_wal_magic = "WAL1"; const uint32_t k_wal_magic_length = 4; -WalWriter::WalWriter(const std::string& file_name, - const std::shared_ptr<std::atomic_size_t>& all_wal_disk_bytes, - const std::shared_ptr<std::condition_variable>& cv) - : cv(cv), - _file_name(file_name), - _disk_bytes(0), - _all_wal_disk_bytes(all_wal_disk_bytes), - _is_first_append_blocks(true) {} +WalWriter::WalWriter(const std::string& file_name) : _file_name(file_name) {} Review Comment: warning: pass by value and use std::move [modernize-pass-by-value] be/src/olap/wal_writer.cpp:22: ```diff + #include <utility> ``` ```suggestion WalWriter::WalWriter(std::string file_name) : _file_name(std::move(file_name)std::string Writer(const std::string& file_name) : _file_name(file_name) {} ``` ########## be/src/runtime/group_commit_mgr.h: ########## @@ -20,9 +20,13 @@ #include <gen_cpp/PaloInternalService_types.h> Review Comment: warning: 'gen_cpp/PaloInternalService_types.h' file not found [clang-diagnostic-error] ```cpp #include <gen_cpp/PaloInternalService_types.h> ^ ``` ########## be/src/runtime/group_commit_mgr.cpp: ########## @@ -420,9 +426,10 @@ void GroupCommitMgr::stop() { LOG(INFO) << "GroupCommitMgr is stopped"; } -Status GroupCommitMgr::get_first_block_load_queue( - int64_t db_id, int64_t table_id, std::shared_ptr<vectorized::FutureBlock> block, - std::shared_ptr<LoadBlockQueue>& load_block_queue) { +Status GroupCommitMgr::get_first_block_load_queue(int64_t db_id, int64_t table_id, Review Comment: warning: method 'get_first_block_load_queue' can be made static [readability-convert-member-functions-to-static] ```suggestion static Status GroupCommitMgr::get_first_block_load_queue(int64_t db_id, int64_t table_id, ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org