Skysheepwang commented on a change in pull request #5008:
URL: https://github.com/apache/incubator-doris/pull/5008#discussion_r542993632



##########
File path: be/src/olap/page_cache.cpp
##########
@@ -21,35 +21,48 @@ namespace doris {
 
 StoragePageCache* StoragePageCache::_s_instance = nullptr;
 
-void StoragePageCache::create_global_cache(size_t capacity) {
+void StoragePageCache::create_global_cache(size_t capacity, int32_t 
index_cache_percentage) {
     DCHECK(_s_instance == nullptr);
-    static StoragePageCache instance(capacity);
+    static StoragePageCache instance(capacity, index_cache_percentage);
     _s_instance = &instance;
 }
 
-StoragePageCache::StoragePageCache(size_t capacity)
-        : _cache(new_lru_cache("StoragePageCache", capacity)) {}
+StoragePageCache::StoragePageCache(size_t capacity, int32_t 
index_cache_percentage)
+        : _index_cache_percentage(index_cache_percentage) {
+    if (index_cache_percentage == 0) {
+        _data_page_cache = 
std::unique_ptr<Cache>(new_lru_cache("DataPageCache", capacity));
+    } else if (index_cache_percentage == 100) {
+        _index_page_cache = 
std::unique_ptr<Cache>(new_lru_cache("IndexPageCache", capacity));
+    } else if (index_cache_percentage > 0 && index_cache_percentage < 100) {
+        _data_page_cache = 
std::unique_ptr<Cache>(new_lru_cache("DataPageCache", capacity * (100 - 
index_cache_percentage) / 100));
+        _index_page_cache = 
std::unique_ptr<Cache>(new_lru_cache("IndexPageCache", capacity * 
index_cache_percentage / 100));
+    } else {
+        CHECK(false) << "invalid index page cache percentage";
+    }
+}
 
-bool StoragePageCache::lookup(const CacheKey& key, PageCacheHandle* handle) {
-    auto lru_handle = _cache->lookup(key.encode());
+bool StoragePageCache::lookup(const CacheKey& key, PageCacheHandle* handle, 
segment_v2::PageTypePB page_type) {
+    auto cache = _get_page_cache(page_type);

Review comment:
       Actually not because the `is_cache_available()` check will be called 
before using the `lookup()` method.




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

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