github-actions[bot] commented on code in PR #39036:
URL: https://github.com/apache/doris/pull/39036#discussion_r1706573212
##########
be/src/io/cache/block/block_lru_file_cache.cpp:
##########
@@ -799,34 +815,27 @@
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() {
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() {
^
```
<details>
<summary>Additional context</summary>
**be/src/io/cache/block/block_lru_file_cache.cpp:831:** 117 lines including
whitespace and comments (threshold 80)
```cpp
void LRUFileCache::load_cache_info_into_memory() {
^
```
</details>
##########
be/src/io/cache/block/block_lru_file_cache.cpp:
##########
@@ -799,34 +815,27 @@ 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() {
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() {
^
```
<details>
<summary>Additional context</summary>
**be/src/io/cache/block/block_lru_file_cache.cpp:838:** 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:839:** +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:845:** +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:851:** +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:853:** +1, nesting level
increased to 4
```cpp
} else {
^
```
**be/src/io/cache/block/block_lru_file_cache.cpp:857:** +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:860:** +6, including
nesting penalty of 5, nesting level increased to 6
```cpp
if (ec) {
^
```
**be/src/io/cache/block/block_lru_file_cache.cpp:865:** +1, nesting level
increased to 5
```cpp
} else {
^
```
**be/src/io/cache/block/block_lru_file_cache.cpp:869:** +4, including
nesting penalty of 3, nesting level increased to 4
```cpp
} catch (...) {
^
```
**be/src/io/cache/block/block_lru_file_cache.cpp:873:** +4, including
nesting penalty of 3, nesting level increased to 4
```cpp
if (!parsed) {
^
```
**be/src/io/cache/block/block_lru_file_cache.cpp:879:** +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:882:** +5, including
nesting penalty of 4, nesting level increased to 5
```cpp
if (ec) {
^
```
**be/src/io/cache/block/block_lru_file_cache.cpp:889:** +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:892:** +1, nesting level
increased to 4
```cpp
} else {
^
```
**be/src/io/cache/block/block_lru_file_cache.cpp:895:** +5, including
nesting penalty of 4, nesting level increased to 5
```cpp
if (ec) {
^
```
**be/src/io/cache/block/block_lru_file_cache.cpp:905:** +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:907:** +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:908:** +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:912:** +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:921:** +1, nesting level
increased to 1
```cpp
} else {
^
```
**be/src/io/cache/block/block_lru_file_cache.cpp:927:** nesting level
increased to 1
```cpp
[](auto& dir) {
^
```
**be/src/io/cache/block/block_lru_file_cache.cpp:929:** +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:929:** +1
```cpp
if (std::filesystem::is_empty(dir, ec) && !ec) {
^
```
**be/src/io/cache/block/block_lru_file_cache.cpp:932:** +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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]