github-actions[bot] commented on code in PR #40226:
URL: https://github.com/apache/doris/pull/40226#discussion_r1744142012


##########
be/test/io/cache/block_file_cache_test.cpp:
##########
@@ -4644,5 +4642,105 @@ TEST_F(BlockFileCacheTest, load_cache2) {
                                     key1.to_string() + "_0/" + 
std::to_string(offset));
     }
 }
+*/
+
+TEST_F(BlockFileCacheTest, test_load) {

Review Comment:
   warning: function 'TEST_F' exceeds recommended size/complexity thresholds 
[readability-function-size]
   ```cpp
   */
       ^
   ```
   <details>
   <summary>Additional context</summary>
   
   **be/test/io/cache/block_file_cache_test.cpp:4646:** 97 lines including 
whitespace and comments (threshold 80)
   ```cpp
   */
       ^
   ```
   
   </details>
   



##########
be/src/io/cache/fs_file_cache_storage.cpp:
##########
@@ -227,7 +289,7 @@ std::string 
FSFileCacheStorage::get_path_in_local_cache(const UInt128Wrapper& va
     }
 }
 
-Status FSFileCacheStorage::rebuild_data_structure() const {
+Status FSFileCacheStorage::upgrade_cache_dir_if_necessary() const {

Review Comment:
   warning: function 'upgrade_cache_dir_if_necessary' has cognitive complexity 
of 119 (threshold 50) [readability-function-cognitive-complexity]
   ```cpp
   Status FSFileCacheStorage::upgrade_cache_dir_if_necessary() const {
                              ^
   ```
   <details>
   <summary>Additional context</summary>
   
   **be/src/io/cache/fs_file_cache_storage.cpp:295:** +1, including nesting 
penalty of 0, nesting level increased to 1
   ```cpp
       RETURN_IF_ERROR(read_file_cache_version(&version));
       ^
   ```
   **be/src/common/status.h:628:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
       do {                                \
       ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:295:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
       RETURN_IF_ERROR(read_file_cache_version(&version));
       ^
   ```
   **be/src/common/status.h:630:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
           if (UNLIKELY(!_status_.ok())) { \
           ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:296:** +1, including nesting 
penalty of 0, nesting level increased to 1
   ```cpp
       if (USE_CACHE_VERSION2 && version != "2.0") {
       ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:296:** +1
   ```cpp
       if (USE_CACHE_VERSION2 && version != "2.0") {
                              ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:300:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           if (ec) {
           ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:304:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           for (; key_it != std::filesystem::directory_iterator(); ++key_it) {
           ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:305:** +3, including nesting 
penalty of 2, nesting level increased to 3
   ```cpp
               if (key_it->is_directory()) {
               ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:307:** +4, including nesting 
penalty of 3, nesting level increased to 4
   ```cpp
                   if (cache_key.size() > KEY_PREFIX_LENGTH) {
                   ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:311:** +5, including nesting 
penalty of 4, nesting level increased to 5
   ```cpp
                       RETURN_IF_ERROR(fs->exists(key_prefix, &exists));
                       ^
   ```
   **be/src/common/status.h:628:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
       do {                                \
       ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:311:** +6, including nesting 
penalty of 5, nesting level increased to 6
   ```cpp
                       RETURN_IF_ERROR(fs->exists(key_prefix, &exists));
                       ^
   ```
   **be/src/common/status.h:630:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
           if (UNLIKELY(!_status_.ok())) { \
           ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:312:** +5, including nesting 
penalty of 4, nesting level increased to 5
   ```cpp
                       if (!exists) {
                       ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:313:** +6, including nesting 
penalty of 5, nesting level increased to 6
   ```cpp
                           RETURN_IF_ERROR(fs->create_directory(key_prefix));
                           ^
   ```
   **be/src/common/status.h:628:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
       do {                                \
       ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:313:** +7, including nesting 
penalty of 6, nesting level increased to 7
   ```cpp
                           RETURN_IF_ERROR(fs->create_directory(key_prefix));
                           ^
   ```
   **be/src/common/status.h:630:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
           if (UNLIKELY(!_status_.ok())) { \
           ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:315:** +5, including nesting 
penalty of 4, nesting level increased to 5
   ```cpp
                       RETURN_IF_ERROR(fs->rename(key_it->path(), key_prefix / 
cache_key));
                       ^
   ```
   **be/src/common/status.h:628:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
       do {                                \
       ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:315:** +6, including nesting 
penalty of 5, nesting level increased to 6
   ```cpp
                       RETURN_IF_ERROR(fs->rename(key_it->path(), key_prefix / 
cache_key));
                       ^
   ```
   **be/src/common/status.h:630:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
           if (UNLIKELY(!_status_.ok())) { \
           ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:319:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           if (!write_file_cache_version().ok()) {
           ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:324:** nesting level increased 
to 1
   ```cpp
       auto rebuild_dir = [&](std::filesystem::directory_iterator& 
upgrade_key_it) -> Status {
                          ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:325:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           for (; upgrade_key_it != std::filesystem::directory_iterator(); 
++upgrade_key_it) {
           ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:326:** +3, including nesting 
penalty of 2, nesting level increased to 3
   ```cpp
               if (upgrade_key_it->path().filename().native().find('_') == 
std::string::npos) {
               ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:327:** +4, including nesting 
penalty of 3, nesting level increased to 4
   ```cpp
                   
RETURN_IF_ERROR(fs->delete_directory(upgrade_key_it->path().native() + "_0"));
                   ^
   ```
   **be/src/common/status.h:628:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
       do {                                \
       ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:327:** +5, including nesting 
penalty of 4, nesting level increased to 5
   ```cpp
                   
RETURN_IF_ERROR(fs->delete_directory(upgrade_key_it->path().native() + "_0"));
                   ^
   ```
   **be/src/common/status.h:630:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
           if (UNLIKELY(!_status_.ok())) { \
           ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:328:** +4, including nesting 
penalty of 3, nesting level increased to 4
   ```cpp
                   RETURN_IF_ERROR(
                   ^
   ```
   **be/src/common/status.h:628:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
       do {                                \
       ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:328:** +5, including nesting 
penalty of 4, nesting level increased to 5
   ```cpp
                   RETURN_IF_ERROR(
                   ^
   ```
   **be/src/common/status.h:630:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
           if (UNLIKELY(!_status_.ok())) { \
           ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:335:** +1, including nesting 
penalty of 0, nesting level increased to 1
   ```cpp
       if constexpr (USE_CACHE_VERSION2) {
       ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:337:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           if (ec) [[unlikely]] {
           ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:341:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           for (; key_prefix_it != std::filesystem::directory_iterator(); 
++key_prefix_it) {
           ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:342:** +3, including nesting 
penalty of 2, nesting level increased to 3
   ```cpp
               if (!key_prefix_it->is_directory()) {
               ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:346:** +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/fs_file_cache_storage.cpp:349:** +4, including nesting 
penalty of 3, nesting level increased to 4
   ```cpp
                   RETURN_IF_ERROR(fs->delete_directory(key_prefix_it->path()));
                   ^
   ```
   **be/src/common/status.h:628:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
       do {                                \
       ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:349:** +5, including nesting 
penalty of 4, nesting level increased to 5
   ```cpp
                   RETURN_IF_ERROR(fs->delete_directory(key_prefix_it->path()));
                   ^
   ```
   **be/src/common/status.h:630:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
           if (UNLIKELY(!_status_.ok())) { \
           ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:352:** +3, including nesting 
penalty of 2, nesting level increased to 3
   ```cpp
               if (ec) [[unlikely]] {
               ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:355:** +3, including nesting 
penalty of 2, nesting level increased to 3
   ```cpp
               RETURN_IF_ERROR(rebuild_dir(key_it));
               ^
   ```
   **be/src/common/status.h:628:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
       do {                                \
       ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:355:** +4, including nesting 
penalty of 3, nesting level increased to 4
   ```cpp
               RETURN_IF_ERROR(rebuild_dir(key_it));
               ^
   ```
   **be/src/common/status.h:630:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
           if (UNLIKELY(!_status_.ok())) { \
           ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:357:** +1, nesting level 
increased to 1
   ```cpp
       } else {
         ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:359:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           if (ec) [[unlikely]] {
           ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:362:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           RETURN_IF_ERROR(rebuild_dir(key_it));
           ^
   ```
   **be/src/common/status.h:628:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
       do {                                \
       ^
   ```
   **be/src/io/cache/fs_file_cache_storage.cpp:362:** +3, including nesting 
penalty of 2, nesting level increased to 3
   ```cpp
           RETURN_IF_ERROR(rebuild_dir(key_it));
           ^
   ```
   **be/src/common/status.h:630:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
           if (UNLIKELY(!_status_.ok())) { \
           ^
   ```
   
   </details>
   



##########
be/test/io/cache/block_file_cache_test.cpp:
##########
@@ -4644,5 +4642,105 @@
                                     key1.to_string() + "_0/" + 
std::to_string(offset));
     }
 }
+*/
+
+TEST_F(BlockFileCacheTest, test_load) {
+    // test both path formats when loading file cache into memory
+    // old file path format, [hash]_[expiration]/[offset]_ttl
+    // new file path format, [hash]_[expiration]/[offset]
+    const int64_t expiration = 1987654321;
+    if (fs::exists(cache_base_path)) {
+        fs::remove_all(cache_base_path);
+    }
+    fs::create_directories(cache_base_path);
+    auto sp = SyncPoint::get_instance();

Review Comment:
   warning: 'auto sp' can be declared as 'auto *sp' [readability-qualified-auto]
   
   ```suggestion
   h);auto *
   ```
   



-- 
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

Reply via email to