You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@doris.apache.org by GitBox <gi...@apache.org> on 2019/08/09 01:39:24 UTC

[GitHub] [incubator-doris] morningman commented on a change in pull request #1607: Add page cache for column page in BetaRowset

morningman commented on a change in pull request #1607: Add page cache for column page in BetaRowset
URL: https://github.com/apache/incubator-doris/pull/1607#discussion_r312301542
 
 

 ##########
 File path: be/src/olap/page_cache.h
 ##########
 @@ -0,0 +1,121 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <string>
+#include <memory>
+#include <utility>
+
+#include "gutil/macros.h" // for DISALLOW_COPY_AND_ASSIGN
+#include "olap/lru_cache.h"
+
+namespace doris {
+
+class PageCacheHandle;
+
+// Warpper around Cache, and used for cache page of column datas
+// in Segment.
+// TODO(zc): We should add some metric to see cache hit/miss rate.
+class StoragePageCache {
+public:
+    // The unique key identifying entries in the page cache.
+    // Each cached page corresponds to a specific offset within
+    // a file.
+    //
+    // TODO(zc): Now we use file name(std::string) as a part of
+    // key, which is not efficient. We should make it better later
+    struct CacheKey {
+        CacheKey(std::string fname_, int64_t offset_) : fname(std::move(fname_)), offset(offset_) { }
+        std::string fname;
+        int64_t offset;
+
+        // Encode to a flat binary which can be used as LRUCache's key
+        std::string encode() const {
+            std::string key_buf(fname);
+            key_buf.append((char*)&offset, sizeof(offset));
+            return key_buf;
+        }
+    };
+
+    // Create global instance of this class
+    static void create_global_cache(size_t capacity);
+
+    // Return global instance.
+    // Client should call create_global_cache before.
+    static StoragePageCache* instance() { return _s_instance; }
+
+    StoragePageCache(size_t capacity);
+
+    // Lookup the given page in the cache.
+    //
+    // If the page is found, the cache entry will be written into handle.
+    // PageCacheHandle will releaase cache entry to cache when it
 
 Review comment:
   ```suggestion
       // PageCacheHandle will release cache entry to cache when it
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@doris.apache.org
For additional commands, e-mail: dev-help@doris.apache.org