xinyiZzz commented on a change in pull request #6829:
URL: https://github.com/apache/incubator-doris/pull/6829#discussion_r731850588
##########
File path: be/src/olap/lru_cache.cpp
##########
@@ -392,7 +394,47 @@ int LRUCache::prune() {
to_remove_head = old;
}
}
- int pruned_count = 0;
+ int64_t pruned_count = 0;
+ while (to_remove_head != nullptr) {
+ ++pruned_count;
+ LRUHandle* next = to_remove_head->next;
+ to_remove_head->free();
+ to_remove_head = next;
+ }
+ return pruned_count;
+}
+
+int64_t LRUCache::prune_if(bool (*pred)(const void* value)) {
+ LRUHandle* to_remove_head = nullptr;
+ {
+ MutexLock l(&_mutex);
+ LRUHandle* p = _lru_normal.next;
Review comment:
I understand that `LRUHandle* p` this local variable is not necessary.
It is modeled on the logic before `prune`, and `_lru_normal.next` will be
modified when `_prune_one`, so it can be changed to
while (_lru_normal.next != &_lru_normal) {
LRUHandle* old = _lru_normal.next;
if (pred(old->value)) {
_prune_one(old);
old->next = to_remove_head;
to_remove_head = old;
} else {
old = old->next;
}
}
The following part is the same
--
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]