This is an automated email from the ASF dual-hosted git repository.

jianliangqi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new a032ece525c [opt](inverted index) Add Inverted Index Cache Toggle 
(#45718)
a032ece525c is described below

commit a032ece525c1b4bc5e15826e6f54fc82d5ccbee9
Author: zzzxl <yangs...@selectdb.com>
AuthorDate: Mon Dec 23 14:52:17 2024 +0800

    [opt](inverted index) Add Inverted Index Cache Toggle (#45718)
    
    Problem Summary:
    1. Adding an inverted index cache toggle can help with debugging.
---
 .../rowset/segment_v2/inverted_index_reader.cpp    |  74 ++++++++---
 .../olap/rowset/segment_v2/inverted_index_reader.h |  38 +++---
 .../java/org/apache/doris/qe/SessionVariable.java  |  16 +++
 gensrc/thrift/PaloInternalService.thrift           |   4 +
 .../test_inverted_index_cache.out                  |  22 ++++
 .../test_inverted_index_cache.groovy               | 144 +++++++++++++++++++++
 6 files changed, 260 insertions(+), 38 deletions(-)

diff --git a/be/src/olap/rowset/segment_v2/inverted_index_reader.cpp 
b/be/src/olap/rowset/segment_v2/inverted_index_reader.cpp
index b40f9121125..9790d7273e1 100644
--- a/be/src/olap/rowset/segment_v2/inverted_index_reader.cpp
+++ b/be/src/olap/rowset/segment_v2/inverted_index_reader.cpp
@@ -164,16 +164,48 @@ Status InvertedIndexReader::read_null_bitmap(const 
io::IOContext* io_ctx,
     return Status::OK();
 }
 
+Status InvertedIndexReader::handle_query_cache(RuntimeState* runtime_state,
+                                               InvertedIndexQueryCache* cache,
+                                               const 
InvertedIndexQueryCache::CacheKey& cache_key,
+                                               InvertedIndexQueryCacheHandle* 
cache_handler,
+                                               OlapReaderStatistics* stats,
+                                               
std::shared_ptr<roaring::Roaring>& bit_map) {
+    const auto& query_options = runtime_state->query_options();
+    if (query_options.enable_inverted_index_query_cache &&
+        cache->lookup(cache_key, cache_handler)) {
+        DBUG_EXECUTE_IF("InvertedIndexReader.handle_query_cache_hit", {
+            return Status::Error<ErrorCode::INTERNAL_ERROR>("handle query 
cache hit");
+        });
+        stats->inverted_index_query_cache_hit++;
+        SCOPED_RAW_TIMER(&stats->inverted_index_query_bitmap_copy_timer);
+        bit_map = cache_handler->get_bitmap();
+        return Status::OK();
+    }
+    DBUG_EXECUTE_IF("InvertedIndexReader.handle_query_cache_miss", {
+        return Status::Error<ErrorCode::INTERNAL_ERROR>("handle query cache 
miss");
+    });
+    stats->inverted_index_query_cache_miss++;
+    return Status::Error<ErrorCode::KEY_NOT_FOUND>("cache miss");
+}
+
 Status InvertedIndexReader::handle_searcher_cache(
-        InvertedIndexCacheHandle* inverted_index_cache_handle, const 
io::IOContext* io_ctx,
-        OlapReaderStatistics* stats) {
+        RuntimeState* runtime_state, InvertedIndexCacheHandle* 
inverted_index_cache_handle,
+        const io::IOContext* io_ctx, OlapReaderStatistics* stats) {
     auto index_file_key = 
_inverted_index_file_reader->get_index_file_cache_key(&_index_meta);
     InvertedIndexSearcherCache::CacheKey searcher_cache_key(index_file_key);
-    if (InvertedIndexSearcherCache::instance()->lookup(searcher_cache_key,
+    const auto& query_options = runtime_state->query_options();
+    if (query_options.enable_inverted_index_searcher_cache &&
+        InvertedIndexSearcherCache::instance()->lookup(searcher_cache_key,
                                                        
inverted_index_cache_handle)) {
+        DBUG_EXECUTE_IF("InvertedIndexReader.handle_searcher_cache_hit", {
+            return Status::Error<ErrorCode::INTERNAL_ERROR>("handle searcher 
cache hit");
+        });
         stats->inverted_index_searcher_cache_hit++;
         return Status::OK();
     } else {
+        DBUG_EXECUTE_IF("InvertedIndexReader.handle_searcher_cache_miss", {
+            return Status::Error<ErrorCode::INTERNAL_ERROR>("handle searcher 
cache miss");
+        });
         // searcher cache miss
         stats->inverted_index_searcher_cache_miss++;
         auto mem_tracker = 
std::make_unique<MemTracker>("InvertedIndexSearcherCacheWithRead");
@@ -311,14 +343,16 @@ Status FullTextIndexReader::query(const io::IOContext* 
io_ctx, OlapReaderStatist
         InvertedIndexQueryCacheHandle cache_handler;
 
         std::shared_ptr<roaring::Roaring> term_match_bitmap = nullptr;
-        auto cache_status = handle_query_cache(cache, cache_key, 
&cache_handler, stats, bit_map);
+        auto cache_status =
+                handle_query_cache(runtime_state, cache, cache_key, 
&cache_handler, stats, bit_map);
         if (cache_status.ok()) {
             return Status::OK();
         }
         FulltextIndexSearcherPtr* searcher_ptr = nullptr;
 
         InvertedIndexCacheHandle inverted_index_cache_handle;
-        RETURN_IF_ERROR(handle_searcher_cache(&inverted_index_cache_handle, 
io_ctx, stats));
+        RETURN_IF_ERROR(
+                handle_searcher_cache(runtime_state, 
&inverted_index_cache_handle, io_ctx, stats));
         auto searcher_variant = 
inverted_index_cache_handle.get_index_searcher();
         searcher_ptr = 
std::get_if<FulltextIndexSearcherPtr>(&searcher_variant);
         if (searcher_ptr != nullptr) {
@@ -379,7 +413,8 @@ Status StringTypeInvertedIndexReader::query(const 
io::IOContext* io_ctx,
                                                  search_str};
     auto* cache = InvertedIndexQueryCache::instance();
     InvertedIndexQueryCacheHandle cache_handler;
-    auto cache_status = handle_query_cache(cache, cache_key, &cache_handler, 
stats, bit_map);
+    auto cache_status =
+            handle_query_cache(runtime_state, cache, cache_key, 
&cache_handler, stats, bit_map);
     if (cache_status.ok()) {
         return Status::OK();
     }
@@ -393,7 +428,8 @@ Status StringTypeInvertedIndexReader::query(const 
io::IOContext* io_ctx,
     auto result = std::make_shared<roaring::Roaring>();
     FulltextIndexSearcherPtr* searcher_ptr = nullptr;
     InvertedIndexCacheHandle inverted_index_cache_handle;
-    RETURN_IF_ERROR(handle_searcher_cache(&inverted_index_cache_handle, 
io_ctx, stats));
+    RETURN_IF_ERROR(
+            handle_searcher_cache(runtime_state, &inverted_index_cache_handle, 
io_ctx, stats));
     auto searcher_variant = inverted_index_cache_handle.get_index_searcher();
     searcher_ptr = std::get_if<FulltextIndexSearcherPtr>(&searcher_variant);
     if (searcher_ptr != nullptr) {
@@ -609,11 +645,12 @@ Status BkdIndexReader::invoke_bkd_query(const void* 
query_value, InvertedIndexQu
 }
 
 Status BkdIndexReader::try_query(const io::IOContext* io_ctx, 
OlapReaderStatistics* stats,
-                                 const std::string& column_name, const void* 
query_value,
-                                 InvertedIndexQueryType query_type, uint32_t* 
count) {
+                                 RuntimeState* runtime_state, const 
std::string& column_name,
+                                 const void* query_value, 
InvertedIndexQueryType query_type,
+                                 uint32_t* count) {
     try {
         std::shared_ptr<lucene::util::bkd::bkd_reader> r;
-        auto st = get_bkd_reader(r, io_ctx, stats);
+        auto st = get_bkd_reader(r, io_ctx, stats, runtime_state);
         if (!st.ok()) {
             LOG(WARNING) << "get bkd reader for  "
                          << 
_inverted_index_file_reader->get_index_file_path(&_index_meta)
@@ -629,7 +666,8 @@ Status BkdIndexReader::try_query(const io::IOContext* 
io_ctx, OlapReaderStatisti
         auto* cache = InvertedIndexQueryCache::instance();
         InvertedIndexQueryCacheHandle cache_handler;
         std::shared_ptr<roaring::Roaring> bit_map;
-        auto cache_status = handle_query_cache(cache, cache_key, 
&cache_handler, stats, bit_map);
+        auto cache_status =
+                handle_query_cache(runtime_state, cache, cache_key, 
&cache_handler, stats, bit_map);
         if (cache_status.ok()) {
             *count = bit_map->cardinality();
             return Status::OK();
@@ -653,7 +691,7 @@ Status BkdIndexReader::query(const io::IOContext* io_ctx, 
OlapReaderStatistics*
 
     try {
         std::shared_ptr<lucene::util::bkd::bkd_reader> r;
-        auto st = get_bkd_reader(r, io_ctx, stats);
+        auto st = get_bkd_reader(r, io_ctx, stats, runtime_state);
         if (!st.ok()) {
             LOG(WARNING) << "get bkd reader for  "
                          << 
_inverted_index_file_reader->get_index_file_path(&_index_meta)
@@ -668,7 +706,8 @@ Status BkdIndexReader::query(const io::IOContext* io_ctx, 
OlapReaderStatistics*
                                                      query_str};
         auto* cache = InvertedIndexQueryCache::instance();
         InvertedIndexQueryCacheHandle cache_handler;
-        auto cache_status = handle_query_cache(cache, cache_key, 
&cache_handler, stats, bit_map);
+        auto cache_status =
+                handle_query_cache(runtime_state, cache, cache_key, 
&cache_handler, stats, bit_map);
         if (cache_status.ok()) {
             return Status::OK();
         }
@@ -690,10 +729,11 @@ Status BkdIndexReader::query(const io::IOContext* io_ctx, 
OlapReaderStatistics*
 }
 
 Status BkdIndexReader::get_bkd_reader(BKDIndexSearcherPtr& bkd_reader, const 
io::IOContext* io_ctx,
-                                      OlapReaderStatistics* stats) {
+                                      OlapReaderStatistics* stats, 
RuntimeState* runtime_state) {
     BKDIndexSearcherPtr* bkd_searcher = nullptr;
     InvertedIndexCacheHandle inverted_index_cache_handle;
-    RETURN_IF_ERROR(handle_searcher_cache(&inverted_index_cache_handle, 
io_ctx, stats));
+    RETURN_IF_ERROR(
+            handle_searcher_cache(runtime_state, &inverted_index_cache_handle, 
io_ctx, stats));
     auto searcher_variant = inverted_index_cache_handle.get_index_searcher();
     bkd_searcher = std::get_if<BKDIndexSearcherPtr>(&searcher_variant);
     if (bkd_searcher) {
@@ -1138,8 +1178,8 @@ Status 
InvertedIndexIterator::try_read_from_inverted_index(const std::string& co
         query_type == InvertedIndexQueryType::LESS_EQUAL_QUERY ||
         query_type == InvertedIndexQueryType::LESS_THAN_QUERY ||
         query_type == InvertedIndexQueryType::EQUAL_QUERY) {
-        RETURN_IF_ERROR(
-                _reader->try_query(&_io_ctx, _stats, column_name, query_value, 
query_type, count));
+        RETURN_IF_ERROR(_reader->try_query(&_io_ctx, _stats, _runtime_state, 
column_name,
+                                           query_value, query_type, count));
     }
     return Status::OK();
 }
diff --git a/be/src/olap/rowset/segment_v2/inverted_index_reader.h 
b/be/src/olap/rowset/segment_v2/inverted_index_reader.h
index a1445603286..bbd148fae52 100644
--- a/be/src/olap/rowset/segment_v2/inverted_index_reader.h
+++ b/be/src/olap/rowset/segment_v2/inverted_index_reader.h
@@ -190,8 +190,9 @@ public:
                          const void* query_value, InvertedIndexQueryType 
query_type,
                          std::shared_ptr<roaring::Roaring>& bit_map) = 0;
     virtual Status try_query(const io::IOContext* io_ctx, 
OlapReaderStatistics* stats,
-                             const std::string& column_name, const void* 
query_value,
-                             InvertedIndexQueryType query_type, uint32_t* 
count) = 0;
+                             RuntimeState* runtime_state, const std::string& 
column_name,
+                             const void* query_value, InvertedIndexQueryType 
query_type,
+                             uint32_t* count) = 0;
 
     Status read_null_bitmap(const io::IOContext* io_ctx, OlapReaderStatistics* 
stats,
                             InvertedIndexQueryCacheHandle* cache_handle,
@@ -208,22 +209,14 @@ public:
     [[nodiscard]] bool has_null() const { return _has_null; }
     void set_has_null(bool has_null) { _has_null = has_null; }
 
-    virtual Status handle_query_cache(InvertedIndexQueryCache* cache,
+    virtual Status handle_query_cache(RuntimeState* runtime_state, 
InvertedIndexQueryCache* cache,
                                       const InvertedIndexQueryCache::CacheKey& 
cache_key,
                                       InvertedIndexQueryCacheHandle* 
cache_handler,
                                       OlapReaderStatistics* stats,
-                                      std::shared_ptr<roaring::Roaring>& 
bit_map) {
-        if (cache->lookup(cache_key, cache_handler)) {
-            stats->inverted_index_query_cache_hit++;
-            SCOPED_RAW_TIMER(&stats->inverted_index_query_bitmap_copy_timer);
-            bit_map = cache_handler->get_bitmap();
-            return Status::OK();
-        }
-        stats->inverted_index_query_cache_miss++;
-        return Status::Error<ErrorCode::KEY_NOT_FOUND>("cache miss");
-    }
+                                      std::shared_ptr<roaring::Roaring>& 
bit_map);
 
-    virtual Status handle_searcher_cache(InvertedIndexCacheHandle* 
inverted_index_cache_handle,
+    virtual Status handle_searcher_cache(RuntimeState* runtime_state,
+                                         InvertedIndexCacheHandle* 
inverted_index_cache_handle,
                                          const io::IOContext* io_ctx, 
OlapReaderStatistics* stats);
     std::string get_index_file_path();
     static Status create_index_searcher(lucene::store::Directory* dir, 
IndexSearcherPtr* searcher,
@@ -262,8 +255,9 @@ public:
                  const void* query_value, InvertedIndexQueryType query_type,
                  std::shared_ptr<roaring::Roaring>& bit_map) override;
     Status try_query(const io::IOContext* io_ctx, OlapReaderStatistics* stats,
-                     const std::string& column_name, const void* query_value,
-                     InvertedIndexQueryType query_type, uint32_t* count) 
override {
+                     RuntimeState* runtime_state, const std::string& 
column_name,
+                     const void* query_value, InvertedIndexQueryType 
query_type,
+                     uint32_t* count) override {
         return Status::Error<ErrorCode::NOT_IMPLEMENTED_ERROR>(
                 "FullTextIndexReader not support try_query");
     }
@@ -289,8 +283,9 @@ public:
                  const void* query_value, InvertedIndexQueryType query_type,
                  std::shared_ptr<roaring::Roaring>& bit_map) override;
     Status try_query(const io::IOContext* io_ctx, OlapReaderStatistics* stats,
-                     const std::string& column_name, const void* query_value,
-                     InvertedIndexQueryType query_type, uint32_t* count) 
override {
+                     RuntimeState* runtime_state, const std::string& 
column_name,
+                     const void* query_value, InvertedIndexQueryType 
query_type,
+                     uint32_t* count) override {
         return Status::Error<ErrorCode::NOT_IMPLEMENTED_ERROR>(
                 "StringTypeInvertedIndexReader not support try_query");
     }
@@ -350,8 +345,9 @@ public:
                  const void* query_value, InvertedIndexQueryType query_type,
                  std::shared_ptr<roaring::Roaring>& bit_map) override;
     Status try_query(const io::IOContext* io_ctx, OlapReaderStatistics* stats,
-                     const std::string& column_name, const void* query_value,
-                     InvertedIndexQueryType query_type, uint32_t* count) 
override;
+                     RuntimeState* runtime_state, const std::string& 
column_name,
+                     const void* query_value, InvertedIndexQueryType 
query_type,
+                     uint32_t* count) override;
     Status invoke_bkd_try_query(const void* query_value, 
InvertedIndexQueryType query_type,
                                 std::shared_ptr<lucene::util::bkd::bkd_reader> 
r, uint32_t* count);
     Status invoke_bkd_query(const void* query_value, InvertedIndexQueryType 
query_type,
@@ -364,7 +360,7 @@ public:
 
     InvertedIndexReaderType type() override;
     Status get_bkd_reader(BKDIndexSearcherPtr& reader, const io::IOContext* 
io_ctx,
-                          OlapReaderStatistics* stats);
+                          OlapReaderStatistics* stats, RuntimeState* 
runtime_state);
 
 private:
     const TypeInfo* _type_info {};
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java 
b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
index 75f21c786b8..cf26cce7383 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
@@ -679,6 +679,8 @@ public class SessionVariable implements Serializable, 
Writable {
 
     public static final String ENABLE_MATCH_WITHOUT_INVERTED_INDEX = 
"enable_match_without_inverted_index";
     public static final String ENABLE_FALLBACK_ON_MISSING_INVERTED_INDEX = 
"enable_fallback_on_missing_inverted_index";
+    public static final String ENABLE_INVERTED_INDEX_SEARCHER_CACHE = 
"enable_inverted_index_searcher_cache";
+    public static final String ENABLE_INVERTED_INDEX_QUERY_CACHE = 
"enable_inverted_index_query_cache";
 
     public static final String IN_LIST_VALUE_COUNT_THRESHOLD = 
"in_list_value_count_threshold";
 
@@ -2304,6 +2306,18 @@ public class SessionVariable implements Serializable, 
Writable {
     })
     public boolean enableFallbackOnMissingInvertedIndex = true;
 
+    @VariableMgr.VarAttr(name = ENABLE_INVERTED_INDEX_SEARCHER_CACHE, 
description = {
+        "开启后会缓存倒排索引searcher",
+        "Enabling this will cache the inverted index searcher."
+    })
+    public boolean enableInvertedIndexSearcherCache = true;
+
+    @VariableMgr.VarAttr(name = ENABLE_INVERTED_INDEX_QUERY_CACHE, description 
= {
+        "开启后会缓存倒排索引查询结果",
+        "Enabling this will cache the results of inverted index queries."
+    })
+    public boolean enableInvertedIndexQueryCache = true;
+
     @VariableMgr.VarAttr(name = IN_LIST_VALUE_COUNT_THRESHOLD, description = {
         "in条件value数量大于这个threshold后将不会走fast_execute",
         "When the number of values in the IN condition exceeds this threshold,"
@@ -3990,6 +4004,8 @@ public class SessionVariable implements Serializable, 
Writable {
 
         
tResult.setEnableMatchWithoutInvertedIndex(enableMatchWithoutInvertedIndex);
         
tResult.setEnableFallbackOnMissingInvertedIndex(enableFallbackOnMissingInvertedIndex);
+        
tResult.setEnableInvertedIndexSearcherCache(enableInvertedIndexSearcherCache);
+        
tResult.setEnableInvertedIndexQueryCache(enableInvertedIndexQueryCache);
         tResult.setHiveOrcUseColumnNames(hiveOrcUseColumnNames);
         tResult.setHiveParquetUseColumnNames(hiveParquetUseColumnNames);
         tResult.setKeepCarriageReturn(keepCarriageReturn);
diff --git a/gensrc/thrift/PaloInternalService.thrift 
b/gensrc/thrift/PaloInternalService.thrift
index 0a1ea4a98fc..f4d367659e4 100644
--- a/gensrc/thrift/PaloInternalService.thrift
+++ b/gensrc/thrift/PaloInternalService.thrift
@@ -360,6 +360,10 @@ struct TQueryOptions {
   141: optional bool ignore_runtime_filter_error = false;
   142: optional bool enable_fixed_len_to_uint32_v2 = false;
   143: optional bool enable_shared_exchange_sink_buffer = true;
+
+  144: optional bool enable_inverted_index_searcher_cache = true;
+  145: optional bool enable_inverted_index_query_cache = true;
+
   // For cloud, to control if the content would be written into file cache
   // In write path, to control if the content would be written into file cache.
   // In read path, read from file cache or remote storage when execute query.
diff --git 
a/regression-test/data/fault_injection_p0/test_inverted_index_cache.out 
b/regression-test/data/fault_injection_p0/test_inverted_index_cache.out
new file mode 100644
index 00000000000..7d166b8b78d
--- /dev/null
+++ b/regression-test/data/fault_injection_p0/test_inverted_index_cache.out
@@ -0,0 +1,22 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql --
+863
+
+-- !sql --
+863
+
+-- !sql --
+863
+
+-- !sql --
+863
+
+-- !sql --
+350
+
+-- !sql --
+863
+
+-- !sql --
+350
+
diff --git 
a/regression-test/suites/fault_injection_p0/test_inverted_index_cache.groovy 
b/regression-test/suites/fault_injection_p0/test_inverted_index_cache.groovy
new file mode 100644
index 00000000000..fd250a7d4fd
--- /dev/null
+++ b/regression-test/suites/fault_injection_p0/test_inverted_index_cache.groovy
@@ -0,0 +1,144 @@
+// 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.
+
+suite("test_inverted_index_cache", "nonConcurrent") {
+    // define a sql table
+    def indexTbName = "test_inverted_index_cache"
+
+    sql "DROP TABLE IF EXISTS ${indexTbName}"
+    sql """
+      CREATE TABLE ${indexTbName} (
+        `@timestamp` int(11) NULL COMMENT "",
+        `clientip` varchar(20) NULL COMMENT "",
+        `request` text NULL COMMENT "",
+        `status` int(11) NULL COMMENT "",
+        `size` int(11) NULL COMMENT "",
+        INDEX request_idx (`request`) USING INVERTED PROPERTIES("parser" = 
"english", "support_phrase" = "true") COMMENT '',
+      ) ENGINE=OLAP
+      DUPLICATE KEY(`@timestamp`)
+      COMMENT "OLAP"
+      DISTRIBUTED BY RANDOM BUCKETS 1
+      PROPERTIES (
+        "replication_allocation" = "tag.location.default: 1",
+        "disable_auto_compaction" = "true"
+      );
+    """
+
+    def load_httplogs_data = {table_name, label, read_flag, format_flag, 
file_name, ignore_failure=false,
+                        expected_succ_rows = -1, load_to_single_tablet = 
'true' ->
+
+        // load the json data
+        streamLoad {
+            table "${table_name}"
+
+            // set http request header params
+            set 'label', label + "_" + UUID.randomUUID().toString()
+            set 'read_json_by_line', read_flag
+            set 'format', format_flag
+            file file_name // import json file
+            time 10000 // limit inflight 10s
+            if (expected_succ_rows >= 0) {
+                set 'max_filter_ratio', '1'
+            }
+
+            // if declared a check callback, the default check condition will 
ignore.
+            // So you must check all condition
+            check { result, exception, startTime, endTime ->
+                       if (ignore_failure && expected_succ_rows < 0) { return }
+                    if (exception != null) {
+                        throw exception
+                    }
+                    log.info("Stream load result: ${result}".toString())
+                    def json = parseJson(result)
+            }
+        }
+    }
+
+    load_httplogs_data.call(indexTbName, 'test_index_inlist_fault_injection', 
'true', 'json', 'documents-1000.json')
+    sql "sync"
+
+    qt_sql """ select count() from ${indexTbName} where (request match 
'images');  """
+
+    // query cache hit
+    // searcher cache hit
+    try {
+      sql """ set enable_inverted_index_query_cache = true """
+      sql """ set enable_inverted_index_searcher_cache = true """
+
+      
GetDebugPoint().enableDebugPointForAllBEs("InvertedIndexReader.handle_query_cache_miss")
+      
GetDebugPoint().enableDebugPointForAllBEs("InvertedIndexReader.handle_searcher_cache_miss")
+
+      qt_sql """ select count() from ${indexTbName} where (request match 
'images');  """
+
+    } finally {
+      
GetDebugPoint().disableDebugPointForAllBEs("InvertedIndexReader.handle_query_cache_miss")
+      
GetDebugPoint().disableDebugPointForAllBEs("InvertedIndexReader.handle_searcher_cache_miss")
+    }
+
+    // query cache miss
+    // searcher cache hit
+    try {
+      sql """ set enable_inverted_index_query_cache = false """
+      sql """ set enable_inverted_index_searcher_cache = true """
+
+      
GetDebugPoint().enableDebugPointForAllBEs("InvertedIndexReader.handle_query_cache_hit")
+      
GetDebugPoint().enableDebugPointForAllBEs("InvertedIndexReader.handle_searcher_cache_miss")
+
+      qt_sql """ select count() from ${indexTbName} where (request match 
'images');  """
+
+    } finally {
+      
GetDebugPoint().disableDebugPointForAllBEs("InvertedIndexReader.handle_query_cache_hit")
+      
GetDebugPoint().disableDebugPointForAllBEs("InvertedIndexReader.handle_searcher_cache_miss")
+    }
+
+    // query cache hit
+    // searcher cache miss
+    try {
+      sql """ set enable_inverted_index_query_cache = true """
+      sql """ set enable_inverted_index_searcher_cache = false """
+
+      
GetDebugPoint().enableDebugPointForAllBEs("InvertedIndexReader.handle_query_cache_miss")
+      
GetDebugPoint().enableDebugPointForAllBEs("InvertedIndexReader.handle_searcher_cache_hit")
+
+      qt_sql """ select count() from ${indexTbName} where (request match 
'images');  """
+      qt_sql """ select count() from ${indexTbName} where (request match 
'english');  """
+
+    } finally {
+      
GetDebugPoint().disableDebugPointForAllBEs("InvertedIndexReader.handle_query_cache_miss")
+      
GetDebugPoint().disableDebugPointForAllBEs("InvertedIndexReader.handle_searcher_cache_hit")
+    }
+
+    // query cache miss
+    // searcher cache miss
+    try {
+      sql """ set enable_inverted_index_query_cache = false """
+      sql """ set enable_inverted_index_searcher_cache = false """
+
+      
GetDebugPoint().enableDebugPointForAllBEs("InvertedIndexReader.handle_query_cache_hit")
+      
GetDebugPoint().enableDebugPointForAllBEs("InvertedIndexReader.handle_searcher_cache_hit")
+
+      qt_sql """ select count() from ${indexTbName} where (request match 
'images');  """
+      qt_sql """ select count() from ${indexTbName} where (request match 
'english');  """
+
+    } finally {
+      
GetDebugPoint().disableDebugPointForAllBEs("InvertedIndexReader.handle_query_cache_hit")
+      
GetDebugPoint().disableDebugPointForAllBEs("InvertedIndexReader.handle_searcher_cache_hit")
+    }
+
+    sql """ set enable_inverted_index_query_cache = true """
+    sql """ set enable_inverted_index_searcher_cache = true """
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to