airborne12 commented on code in PR #20156:
URL: https://github.com/apache/doris/pull/20156#discussion_r1209630261
##########
be/src/olap/rowset/segment_v2/inverted_index_reader.cpp:
##########
@@ -222,101 +223,148 @@ Status FullTextIndexReader::query(OlapReaderStatistics*
stats, const std::string
return Status::Error<ErrorCode::INVERTED_INDEX_NO_TERMS>();
}
+ auto index_search = [&](bool& null_bitmap_already_read,
+ std::shared_ptr<roaring::Roaring>&
term_match_bitmap,
+ InvertedIndexQueryCache* cache,
+ InvertedIndexQueryCache::CacheKey& cache_key,
+ InvertedIndexQueryCacheHandle& cache_handle) {
+ // check index file existence
+ if (!indexExists(index_file_path)) {
+ LOG(WARNING) << "inverted index path: " <<
index_file_path.string()
+ << " not exist.";
+ return
Status::Error<ErrorCode::INVERTED_INDEX_FILE_NOT_FOUND>();
+ }
+
+ InvertedIndexCacheHandle inverted_index_cache_handle;
+ 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();
+
+ // try to reuse index_searcher's directory to read null_bitmap to
cache
+ // to avoid open directory additionally for null_bitmap
+ if (!null_bitmap_already_read) {
+ InvertedIndexQueryCacheHandle null_bitmap_cache_handle;
+ read_null_bitmap(&null_bitmap_cache_handle,
+ index_searcher->getReader()->directory());
+ null_bitmap_already_read = true;
+ }
+
+ try {
+ SCOPED_RAW_TIMER(&stats->inverted_index_searcher_search_timer);
+ index_searcher->_search(
+ query.get(),
+ [&term_match_bitmap](const int32_t docid, const
float_t /*score*/) {
+ // docid equal to rowid in segment
+ term_match_bitmap->add(docid);
+ });
+ } catch (const CLuceneError& e) {
+ LOG(WARNING) << "CLuceneError occured: " << e.what();
+ return
Status::Error<ErrorCode::INVERTED_INDEX_CLUCENE_ERROR>();
+ }
+
+ {
+ // add to cache
+ term_match_bitmap->runOptimize();
+ cache->insert(cache_key, term_match_bitmap, &cache_handle);
+ }
+ return Status::OK();
+ };
+
roaring::Roaring query_match_bitmap;
- bool first = true;
bool null_bitmap_already_read = false;
- for (auto token_ws : analyse_result) {
- std::shared_ptr<roaring::Roaring> term_match_bitmap = nullptr;
+ if (query_type == InvertedIndexQueryType::MATCH_PHRASE_QUERY) {
+ std::wstring str_tokens;
+ auto* phrase_query = new lucene::search::PhraseQuery();
Review Comment:
if cache hit, phrase_query will not be released, memory leaks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]