From 51a6682d3806dc3bbf8ba214416a80f4e9b0c29e Mon Sep 17 00:00:00 2001 From: zzzxl1993 <474696115@qq.com> Date: Fri, 3 Nov 2023 17:16:48 +0800 Subject: [PATCH] [fix](invert index) Fix the timing error when opening the searcher --- .../rowset/segment_v2/inverted_index_reader.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 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 2776fa4a8da4c4..e870680ef50dbb 100644 --- a/be/src/olap/rowset/segment_v2/inverted_index_reader.cpp +++ b/be/src/olap/rowset/segment_v2/inverted_index_reader.cpp @@ -289,10 +289,12 @@ Status FullTextIndexReader::query(OlapReaderStatistics* stats, RuntimeState* run "inverted index path: {} not exist.", index_file_path.string()); } - InvertedIndexCacheHandle inverted_index_cache_handle; - static_cast(InvertedIndexSearcherCache::instance()->get_index_searcher( - _fs, index_dir.c_str(), index_file_name, &inverted_index_cache_handle, stats)); - auto index_searcher = inverted_index_cache_handle.get_index_searcher(); + auto get_index_search = [this, &index_dir, &index_file_name, &stats]() { + InvertedIndexCacheHandle inverted_index_cache_handle; + static_cast(InvertedIndexSearcherCache::instance()->get_index_searcher( + _fs, index_dir.c_str(), index_file_name, &inverted_index_cache_handle, stats)); + return inverted_index_cache_handle.get_index_searcher(); + }; std::unique_ptr query; std::wstring field_ws = std::wstring(column_name.begin(), column_name.end()); @@ -323,6 +325,8 @@ Status FullTextIndexReader::query(OlapReaderStatistics* stats, RuntimeState* run } else { stats->inverted_index_query_cache_miss++; + auto index_searcher = get_index_search(); + term_match_bitmap = std::make_shared(); Status res = Status::OK(); @@ -371,6 +375,8 @@ Status FullTextIndexReader::query(OlapReaderStatistics* stats, RuntimeState* run } else { stats->inverted_index_query_cache_miss++; + auto index_searcher = get_index_search(); + term_match_bitmap = std::make_shared(); // unique_ptr with custom deleter std::unique_ptr term {