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


##########
be/src/olap/rowset/segment_v2/inverted_index_cache.h:
##########
@@ -163,5 +165,105 @@ class InvertedIndexCacheHandle {
     DISALLOW_COPY_AND_ASSIGN(InvertedIndexCacheHandle);
 };
 
+
+
+enum class InvertedIndexQueryType;
+
+class InvertedIndexQueryCacheHandle;
+
+class InvertedIndexQueryCache {
+public:
+    // cache key
+    struct CacheKey {
+        io::Path index_path; // index file path
+        std::string column_name; // column name
+        InvertedIndexQueryType query_type; // query type
+        std::wstring value; // query value
+
+        // Encode to a flat binary which can be used as LRUCache's key
+        std::string encode() const {
+            std::string key_buf(index_path.string());
+            key_buf.append("/");
+            key_buf.append(column_name);
+            key_buf.append("/");
+            key_buf.append(1, static_cast<char>(query_type));
+            key_buf.append("/");
+            key_buf.append(lucene::util::Misc::toString(value.c_str()));
+            return key_buf;
+        }
+    };
+
+    using CacheValue = roaring::Roaring;
+
+    // Create global instance of this class
+    static void create_global_cache(size_t capacity, int32_t 
index_cache_percentage,
+                                    uint32_t num_shards = 16) {
+        DCHECK(_s_instance == nullptr);
+        static InvertedIndexQueryCache instance(capacity, 
index_cache_percentage, num_shards);
+        _s_instance = &instance;
+    }
+
+    // Return global instance.
+    // Client should call create_global_cache before.
+    static InvertedIndexQueryCache* instance() { return _s_instance; }
+
+    InvertedIndexQueryCache() = delete;
+
+    InvertedIndexQueryCache(size_t capacity, int32_t index_cache_percentage, 
uint32_t num_shards) {
+        _cache = std::unique_ptr<Cache>(
+                new_lru_cache("InvertedIndexQueryCache", capacity, 
LRUCacheType::SIZE, num_shards));
+    }
+
+    bool lookup(const CacheKey& key, InvertedIndexQueryCacheHandle* handle);
+
+    void insert(const CacheKey& key, roaring::Roaring* bitmap,
+                InvertedIndexQueryCacheHandle* handle);
+
+private:
+    static InvertedIndexQueryCache* _s_instance;
+    std::unique_ptr<Cache> _cache {nullptr};
+};
+
+class InvertedIndexQueryCacheHandle {
+public:
+    InvertedIndexQueryCacheHandle() {}

Review Comment:
   warning: use '= default' to define a trivial default constructor 
[modernize-use-equals-default]
   
   ```suggestion
       InvertedIndexQueryCacheHandle() = default;
   ```
   



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