github-actions[bot] commented on code in PR #39036: URL: https://github.com/apache/doris/pull/39036#discussion_r1706598421
########## be/src/io/cache/block/block_lru_file_cache.cpp: ########## @@ -799,34 +819,26 @@ std::string key_prefix = fs::path(_cache_base_path) / cache_key.substr(0, KEY_PREFIX_LENGTH); if (!fs::exists(key_prefix)) { - std::error_code ec; - fs::create_directories(key_prefix, ec); - if (ec) { - LOG(WARNING) << "Failed to create new version cached directory: " - << ec.message(); - continue; - } - } - std::error_code ec; - std::filesystem::rename(key_it->path(), key_prefix / cache_key, ec); - if (ec) { - LOG(WARNING) - << "Failed to move old version cached directory: " << ec.message(); + RETURN_IF_ERROR(fs::create_directories(key_prefix)); } + RETURN_IF_ERROR( + std::filesystem::rename(key_it->path(), key_prefix / cache_key)); } } } if (!write_file_cache_version().ok()) { - LOG(WARNING) << "Failed to write version hints for file cache"; + Lreturn Status::InternalError("Failed to write version hints for file cache"); } } + return Status::OK(); +} +void LRUFileCache::load_cache_info_into_memory(std::lock_guard<std::mutex>& cache_lock) { Review Comment: warning: function 'load_cache_info_into_memory' exceeds recommended size/complexity thresholds [readability-function-size] ```cpp void LRUFileCache::load_cache_info_into_memory(std::lock_guard<std::mutex>& cache_lock) { ^ ``` <details> <summary>Additional context</summary> **be/src/io/cache/block/block_lru_file_cache.cpp:835:** 116 lines including whitespace and comments (threshold 80) ```cpp void LRUFileCache::load_cache_info_into_memory(std::lock_guard<std::mutex>& cache_lock) { ^ ``` </details> ########## be/src/io/cache/block/block_lru_file_cache.cpp: ########## @@ -799,34 +819,26 @@ Status LRUFileCache::load_cache_info_into_memory(std::lock_guard<std::mutex>& ca std::string key_prefix = fs::path(_cache_base_path) / cache_key.substr(0, KEY_PREFIX_LENGTH); if (!fs::exists(key_prefix)) { - std::error_code ec; - fs::create_directories(key_prefix, ec); - if (ec) { - LOG(WARNING) << "Failed to create new version cached directory: " - << ec.message(); - continue; - } - } - std::error_code ec; - std::filesystem::rename(key_it->path(), key_prefix / cache_key, ec); - if (ec) { - LOG(WARNING) - << "Failed to move old version cached directory: " << ec.message(); + RETURN_IF_ERROR(fs::create_directories(key_prefix)); } + RETURN_IF_ERROR( + std::filesystem::rename(key_it->path(), key_prefix / cache_key)); } } } if (!write_file_cache_version().ok()) { - LOG(WARNING) << "Failed to write version hints for file cache"; + Lreturn Status::InternalError("Failed to write version hints for file cache"); } } + return Status::OK(); +} +void LRUFileCache::load_cache_info_into_memory(std::lock_guard<std::mutex>& cache_lock) { Review Comment: warning: function 'load_cache_info_into_memory' has cognitive complexity of 64 (threshold 50) [readability-function-cognitive-complexity] ```cpp void LRUFileCache::load_cache_info_into_memory(std::lock_guard<std::mutex>& cache_lock) { ^ ``` <details> <summary>Additional context</summary> **be/src/io/cache/block/block_lru_file_cache.cpp:841:** nesting level increased to 1 ```cpp auto scan_file_cache = [&](fs::directory_iterator& key_it) { ^ ``` **be/src/io/cache/block/block_lru_file_cache.cpp:842:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp for (; key_it != fs::directory_iterator(); ++key_it) { ^ ``` **be/src/io/cache/block/block_lru_file_cache.cpp:848:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp for (; offset_it != fs::directory_iterator(); ++offset_it) { ^ ``` **be/src/io/cache/block/block_lru_file_cache.cpp:854:** +4, including nesting penalty of 3, nesting level increased to 4 ```cpp if (delim_pos == std::string::npos) { ^ ``` **be/src/io/cache/block/block_lru_file_cache.cpp:856:** +1, nesting level increased to 4 ```cpp } else { ^ ``` **be/src/io/cache/block/block_lru_file_cache.cpp:860:** +5, including nesting penalty of 4, nesting level increased to 5 ```cpp if (suffix == "persistent") { ^ ``` **be/src/io/cache/block/block_lru_file_cache.cpp:863:** +6, including nesting penalty of 5, nesting level increased to 6 ```cpp if (ec) { ^ ``` **be/src/io/cache/block/block_lru_file_cache.cpp:868:** +1, nesting level increased to 5 ```cpp } else { ^ ``` **be/src/io/cache/block/block_lru_file_cache.cpp:872:** +4, including nesting penalty of 3, nesting level increased to 4 ```cpp } catch (...) { ^ ``` **be/src/io/cache/block/block_lru_file_cache.cpp:876:** +4, including nesting penalty of 3, nesting level increased to 4 ```cpp if (!parsed) { ^ ``` **be/src/io/cache/block/block_lru_file_cache.cpp:882:** +4, including nesting penalty of 3, nesting level increased to 4 ```cpp if (size == 0) { ^ ``` **be/src/io/cache/block/block_lru_file_cache.cpp:885:** +5, including nesting penalty of 4, nesting level increased to 5 ```cpp if (ec) { ^ ``` **be/src/io/cache/block/block_lru_file_cache.cpp:892:** +4, including nesting penalty of 3, nesting level increased to 4 ```cpp if (try_reserve(key, context, offset, size, cache_lock)) { ^ ``` **be/src/io/cache/block/block_lru_file_cache.cpp:895:** +1, nesting level increased to 4 ```cpp } else { ^ ``` **be/src/io/cache/block/block_lru_file_cache.cpp:898:** +5, including nesting penalty of 4, nesting level increased to 5 ```cpp if (ec) { ^ ``` **be/src/io/cache/block/block_lru_file_cache.cpp:908:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp if constexpr (USE_CACHE_VERSION2) { ^ ``` **be/src/io/cache/block/block_lru_file_cache.cpp:910:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp for (; key_prefix_it != fs::directory_iterator(); ++key_prefix_it) { ^ ``` **be/src/io/cache/block/block_lru_file_cache.cpp:911:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (!key_prefix_it->is_directory()) { ^ ``` **be/src/io/cache/block/block_lru_file_cache.cpp:915:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (key_prefix_it->path().filename().native().size() != KEY_PREFIX_LENGTH) { ^ ``` **be/src/io/cache/block/block_lru_file_cache.cpp:924:** +1, nesting level increased to 1 ```cpp } else { ^ ``` **be/src/io/cache/block/block_lru_file_cache.cpp:930:** nesting level increased to 1 ```cpp [](auto& dir) { ^ ``` **be/src/io/cache/block/block_lru_file_cache.cpp:932:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (std::filesystem::is_empty(dir, ec) && !ec) { ^ ``` **be/src/io/cache/block/block_lru_file_cache.cpp:932:** +1 ```cpp if (std::filesystem::is_empty(dir, ec) && !ec) { ^ ``` **be/src/io/cache/block/block_lru_file_cache.cpp:935:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (ec) { ^ ``` </details> -- 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