Skip to content

Commit

Permalink
[optimize](invert index) avoid redundant checks for exist.
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzxl1993 committed Jan 21, 2024
1 parent 4a86690 commit 787f711
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
8 changes: 8 additions & 0 deletions be/src/olap/rowset/segment_v2/inverted_index_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ErrorCode::INVERTED_INDEX_FILE_NOT_FOUND>(
"inverted index path: {} not exist.", file_path);
}

cache_handle->owned = !use_cache;
IndexSearcherPtr index_searcher;
std::unique_ptr<IndexSearcherBuilder> index_builder = nullptr;
Expand Down
12 changes: 0 additions & 12 deletions be/src/olap/rowset/segment_v2/inverted_index_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,6 @@ Status FullTextIndexReader::query(OlapReaderStatistics* stats, RuntimeState* run
}
}

// check index file existence
if (!indexExists(index_file_path)) {
return Status::Error<ErrorCode::INVERTED_INDEX_FILE_NOT_FOUND>(
"inverted index path: {} not exist.", index_file_path.string());
}

std::unique_ptr<lucene::search::Query> query;
std::wstring field_ws = std::wstring(column_name.begin(), column_name.end());

Expand Down Expand Up @@ -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<ErrorCode::INVERTED_INDEX_FILE_NOT_FOUND>(
"inverted index path: {} not exist.", index_file_path.string());
}

switch (query_type) {
case InvertedIndexQueryType::MATCH_ANY_QUERY:
case InvertedIndexQueryType::MATCH_ALL_QUERY:
Expand Down

0 comments on commit 787f711

Please sign in to comment.