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


##########
be/src/olap/lru_cache.cpp:
##########
@@ -177,6 +177,52 @@ LRUCache::~LRUCache() {
     prune();
 }
 
+PrunedInfo LRUCache::set_capacity(size_t capacity) {
+    LRUHandle* last_ref_list = nullptr;
+    {
+        std::lock_guard l(_mutex);
+        _capacity = capacity;
+        _evict_from_lru(0, &last_ref_list);
+    }
+
+    int64_t pruned_count = 0;
+    int64_t pruned_size = 0;
+    while (last_ref_list != nullptr) {
+        ++pruned_count;
+        pruned_size += last_ref_list->total_size;
+        LRUHandle* next = last_ref_list->next;
+        last_ref_list->free();
+        last_ref_list = next;
+    }
+    return {pruned_count, pruned_size};
+}
+
+uint64_t LRUCache::get_lookup_count() {

Review Comment:
   warning: method 'get_lookup_count' can be made const 
[readability-make-member-function-const]
   
   be/src/olap/lru_cache.h:348:
   ```diff
   -     uint64_t get_lookup_count();
   +     uint64_t get_lookup_count() const;
   ```
   
   ```suggestion
   uint64_t LRUCache::get_lookup_count() const {
   ```
   



##########
be/src/olap/lru_cache.cpp:
##########
@@ -177,6 +177,52 @@
     prune();
 }
 
+PrunedInfo LRUCache::set_capacity(size_t capacity) {
+    LRUHandle* last_ref_list = nullptr;
+    {
+        std::lock_guard l(_mutex);
+        _capacity = capacity;
+        _evict_from_lru(0, &last_ref_list);
+    }
+
+    int64_t pruned_count = 0;
+    int64_t pruned_size = 0;
+    while (last_ref_list != nullptr) {
+        ++pruned_count;
+        pruned_size += last_ref_list->total_size;
+        LRUHandle* next = last_ref_list->next;
+        last_ref_list->free();
+        last_ref_list = next;
+    }
+    return {pruned_count, pruned_size};
+}
+
+uint64_t LRUCache::get_lookup_count() {
+    std::lock_guard l(_mutex);
+    return _lookup_count;
+}
+
+uint64_t LRUCache::get_hit_count() {

Review Comment:
   warning: method 'get_hit_count' can be made const 
[readability-make-member-function-const]
   
   be/src/olap/lru_cache.h:349:
   ```diff
   -     uint64_t get_hit_count();
   +     uint64_t get_hit_count() const;
   ```
   
   ```suggestion
   uint64_t LRUCache::get_hit_count() const {
   ```
   



##########
be/src/olap/lru_cache.cpp:
##########
@@ -177,6 +177,52 @@
     prune();
 }
 
+PrunedInfo LRUCache::set_capacity(size_t capacity) {
+    LRUHandle* last_ref_list = nullptr;
+    {
+        std::lock_guard l(_mutex);
+        _capacity = capacity;
+        _evict_from_lru(0, &last_ref_list);
+    }
+
+    int64_t pruned_count = 0;
+    int64_t pruned_size = 0;
+    while (last_ref_list != nullptr) {
+        ++pruned_count;
+        pruned_size += last_ref_list->total_size;
+        LRUHandle* next = last_ref_list->next;
+        last_ref_list->free();
+        last_ref_list = next;
+    }
+    return {pruned_count, pruned_size};
+}
+
+uint64_t LRUCache::get_lookup_count() {
+    std::lock_guard l(_mutex);
+    return _lookup_count;
+}
+
+uint64_t LRUCache::get_hit_count() {
+    std::lock_guard l(_mutex);
+    return _hit_count;
+}
+
+size_t LRUCache::get_usage() {

Review Comment:
   warning: method 'get_usage' can be made const 
[readability-make-member-function-const]
   
   be/src/olap/lru_cache.h:350:
   ```diff
   -     size_t get_usage();
   +     size_t get_usage() const;
   ```
   
   ```suggestion
   size_t LRUCache::get_usage() const {
   ```
   



##########
be/src/olap/lru_cache.cpp:
##########
@@ -177,6 +177,52 @@
     prune();
 }
 
+PrunedInfo LRUCache::set_capacity(size_t capacity) {
+    LRUHandle* last_ref_list = nullptr;
+    {
+        std::lock_guard l(_mutex);
+        _capacity = capacity;
+        _evict_from_lru(0, &last_ref_list);
+    }
+
+    int64_t pruned_count = 0;
+    int64_t pruned_size = 0;
+    while (last_ref_list != nullptr) {
+        ++pruned_count;
+        pruned_size += last_ref_list->total_size;
+        LRUHandle* next = last_ref_list->next;
+        last_ref_list->free();
+        last_ref_list = next;
+    }
+    return {pruned_count, pruned_size};
+}
+
+uint64_t LRUCache::get_lookup_count() {
+    std::lock_guard l(_mutex);
+    return _lookup_count;
+}
+
+uint64_t LRUCache::get_hit_count() {
+    std::lock_guard l(_mutex);
+    return _hit_count;
+}
+
+size_t LRUCache::get_usage() {
+    std::lock_guard l(_mutex);
+    return _usage;
+}
+
+size_t LRUCache::get_capacity() {

Review Comment:
   warning: method 'get_capacity' can be made const 
[readability-make-member-function-const]
   
   be/src/olap/lru_cache.h:351:
   ```diff
   -     size_t get_capacity();
   +     size_t get_capacity() const;
   ```
   
   ```suggestion
   size_t LRUCache::get_capacity() const {
   ```
   



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