Skip to content

Commit

Permalink
[fix](invert index) Fix the timing error when opening the searcher (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzxl1993 authored and seawinde committed Nov 8, 2023
1 parent 11b516a commit 68fa264
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions be/src/olap/rowset/segment_v2/inverted_index_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>(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<void>(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<lucene::search::Query> query;
std::wstring field_ws = std::wstring(column_name.begin(), column_name.end());
Expand Down Expand Up @@ -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<roaring::Roaring>();

Status res = Status::OK();
Expand Down Expand Up @@ -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<roaring::Roaring>();
// unique_ptr with custom deleter
std::unique_ptr<lucene::index::Term, void (*)(lucene::index::Term*)> term {
Expand Down

0 comments on commit 68fa264

Please sign in to comment.