From 787f711934e1f23f1d232a079c4c79fb7a23a981 Mon Sep 17 00:00:00 2001 From: zzzxl1993 <474696115@qq.com> Date: Sun, 21 Jan 2024 13:06:51 +0800 Subject: [PATCH] [optimize](invert index) avoid redundant checks for exist. --- .../olap/rowset/segment_v2/inverted_index_cache.cpp | 8 ++++++++ .../olap/rowset/segment_v2/inverted_index_reader.cpp | 12 ------------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/be/src/olap/rowset/segment_v2/inverted_index_cache.cpp b/be/src/olap/rowset/segment_v2/inverted_index_cache.cpp index d424d841694db12..744aceecc724d64 100644 --- a/be/src/olap/rowset/segment_v2/inverted_index_cache.cpp +++ b/be/src/olap/rowset/segment_v2/inverted_index_cache.cpp @@ -145,6 +145,14 @@ Status InvertedIndexSearcherCache::get_index_searcher( return Status::OK(); } + // check index file existence + bool exists = false; + Status st = fs->exists(file_path, &exists); + if (!st.ok() || !exists) { + return Status::Error( + "inverted index path: {} not exist.", file_path); + } + cache_handle->owned = !use_cache; IndexSearcherPtr index_searcher; std::unique_ptr index_builder = nullptr; 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 172679f1fa6f3da..34bb42eac6748dd 100644 --- a/be/src/olap/rowset/segment_v2/inverted_index_reader.cpp +++ b/be/src/olap/rowset/segment_v2/inverted_index_reader.cpp @@ -285,12 +285,6 @@ Status FullTextIndexReader::query(OlapReaderStatistics* stats, RuntimeState* run } } - // check index file existence - if (!indexExists(index_file_path)) { - return Status::Error( - "inverted index path: {} not exist.", index_file_path.string()); - } - std::unique_ptr query; std::wstring field_ws = std::wstring(column_name.begin(), column_name.end()); @@ -575,12 +569,6 @@ Status StringTypeInvertedIndexReader::query(OlapReaderStatistics* stats, stats->inverted_index_query_cache_miss++; } - // check index file existence - if (!indexExists(index_file_path)) { - return Status::Error( - "inverted index path: {} not exist.", index_file_path.string()); - } - switch (query_type) { case InvertedIndexQueryType::MATCH_ANY_QUERY: case InvertedIndexQueryType::MATCH_ALL_QUERY: