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


##########
be/src/olap/storage_engine.cpp:
##########
@@ -1369,4 +1409,29 @@
     }
 }
 
+int CreateTabletIdxCache::get_index(const std::string& key) {
+    auto lru_handle = cache()->lookup(key);
+    if (lru_handle) {
+        Defer release([cache = cache(), lru_handle] { 
cache->release(lru_handle); });
+        auto value = (CacheValue*)cache()->value(lru_handle);
+        value->last_visit_time = UnixMillis();
+        VLOG_DEBUG << "use create tablet idx cache key=" << key << " value=" 
<< value->idx;
+        return value->idx;
+    }
+    return -1;
+}
+
+void CreateTabletIdxCache::set_index(const std::string& key, int next_idx) {
+    assert(next_idx >= 0);
+    CacheValue* value = new CacheValue;

Review Comment:
   warning: use auto when initializing with new to avoid duplicating the type 
name [modernize-use-auto]
   
   ```suggestion
    assert(next_idx >= 0);auto
   ```
   



##########
be/src/olap/storage_engine.h:
##########
@@ -332,36 +338,12 @@ class StorageEngine {
 
     void _decrease_low_priority_task_nums(DataDir* dir);
 
-private:
-    struct CompactionCandidate {
-        CompactionCandidate(uint32_t nicumulative_compaction_, int64_t 
tablet_id_, uint32_t index_)
-                : nice(nicumulative_compaction_), tablet_id(tablet_id_), 
disk_index(index_) {}
-        uint32_t nice; // priority
-        int64_t tablet_id;
-        uint32_t disk_index = -1;
-    };
+    void _get_candidate_stores(TStorageMedium::type storage_medium,
+                               std::vector<DirInfo>& dir_infos);
 
-    // In descending order
-    struct CompactionCandidateComparator {
-        bool operator()(const CompactionCandidate& a, const 
CompactionCandidate& b) {
-            return a.nice > b.nice;
-        }
-    };
-
-    struct CompactionDiskStat {
-        CompactionDiskStat(std::string path, uint32_t index, bool used)
-                : storage_path(path),
-                  disk_index(index),
-                  task_running(0),
-                  task_remaining(0),
-                  is_used(used) {}
-        const std::string storage_path;
-        const uint32_t disk_index;
-        uint32_t task_running;
-        uint32_t task_remaining;
-        bool is_used;
-    };
+    int _get_and_set_next_disk_index(int64 partition_id, TStorageMedium::type 
storage_medium);
 
+private:

Review Comment:
   warning: redundant access specifier has the same accessibility as the 
previous access specifier [readability-redundant-access-specifiers]
   
   ```suggestion
   
   ```
   <details>
   <summary>Additional context</summary>
   
   **be/src/olap/storage_engine.h:232:** previously declared here
   ```cpp
   private:
   ^
   ```
   
   </details>
   



##########
be/src/olap/storage_engine.cpp:
##########
@@ -447,46 +452,80 @@
     return Status::OK();
 }
 
+StorageEngine::DiskRemainingLevel get_available_level(double 
disk_usage_percent) {
+    assert(disk_usage_percent <= 1);
+    if (disk_usage_percent < 0.7) {
+        return StorageEngine::DiskRemainingLevel::LOW;
+    } else if (disk_usage_percent < 0.85) {
+        return StorageEngine::DiskRemainingLevel::MID;
+    }
+    return StorageEngine::DiskRemainingLevel::HIGH;
+}
+
+int StorageEngine::_get_and_set_next_disk_index(int64 partition_id,

Review Comment:
   warning: method '_get_and_set_next_disk_index' can be made static 
[readability-convert-member-functions-to-static]
   
   ```suggestion
   static int StorageEngine::_get_and_set_next_disk_index(int64 partition_id,
   ```
   



##########
be/src/olap/storage_engine.cpp:
##########
@@ -1369,4 +1409,29 @@
     }
 }
 
+int CreateTabletIdxCache::get_index(const std::string& key) {
+    auto lru_handle = cache()->lookup(key);
+    if (lru_handle) {
+        Defer release([cache = cache(), lru_handle] { 
cache->release(lru_handle); });
+        auto value = (CacheValue*)cache()->value(lru_handle);
+        value->last_visit_time = UnixMillis();
+        VLOG_DEBUG << "use create tablet idx cache key=" << key << " value=" 
<< value->idx;
+        return value->idx;
+    }
+    return -1;
+}
+
+void CreateTabletIdxCache::set_index(const std::string& key, int next_idx) {
+    assert(next_idx >= 0);
+    CacheValue* value = new CacheValue;
+    value->last_visit_time = UnixMillis();
+    value->idx = next_idx;
+    auto deleter = [](const doris::CacheKey& key, void* value) {
+        CacheValue* cache_value = (CacheValue*)value;

Review Comment:
   warning: use auto when initializing with a cast to avoid duplicating the 
type name [modernize-use-auto]
   
   ```suggestion
   ey& key, void* value) {auto
   ```
   



##########
be/src/olap/storage_engine.cpp:
##########
@@ -129,7 +131,10 @@
           _memtable_flush_executor(nullptr),
           _calc_delete_bitmap_executor(nullptr),
           _default_rowset_type(BETA_ROWSET),
-          _stream_load_recorder(nullptr) {
+          _heartbeat_flags(nullptr),

Review Comment:
   warning: member initializer for '_heartbeat_flags' is redundant 
[modernize-use-default-member-init]
   
   ```suggestion
             ,
   ```
   



##########
be/src/olap/storage_engine.cpp:
##########
@@ -18,6 +18,7 @@
 #include "olap/storage_engine.h"
 
 // IWYU pragma: no_include <bthread/errno.h>
+#include <assert.h>

Review Comment:
   warning: inclusion of deprecated C++ header 'assert.h'; consider using 
'cassert' instead [modernize-deprecated-headers]
   
   ```suggestion
   #include <cassert>
   ```
   



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

Reply via email to