Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Optimize](search) Optimize implement the new query interface #23389

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 41 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 @@ -294,12 +294,28 @@ Status FullTextIndexReader::query(OlapReaderStatistics* stats, const std::string
}

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);
});
if (query_type == InvertedIndexQueryType::MATCH_ANY_QUERY ||
query_type == InvertedIndexQueryType::MATCH_ALL_QUERY ||
query_type == InvertedIndexQueryType::EQUAL_QUERY) {
SCOPED_RAW_TIMER(&stats->inverted_index_searcher_search_timer);
index_searcher->_search(query.get(), [&term_match_bitmap](DocRange* docRange) {
if (docRange->type_ == DocRangeType::kMany) {
term_match_bitmap->addMany(docRange->doc_many_size_,
docRange->doc_many.data());
} else {
term_match_bitmap->addRange(docRange->doc_range.first,
docRange->doc_range.second);
}
});
} else {
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) {
return Status::Error<ErrorCode::INVERTED_INDEX_CLUCENE_ERROR>(
"CLuceneError occured: {}", e.what());
Expand Down Expand Up @@ -518,12 +534,25 @@ Status StringTypeInvertedIndexReader::query(OlapReaderStatistics* stats,
read_null_bitmap(&null_bitmap_cache_handle, index_searcher->getReader()->directory());

try {
SCOPED_RAW_TIMER(&stats->inverted_index_searcher_search_timer);
index_searcher->_search(query.get(),
[&result](const int32_t docid, const float_t /*score*/) {
// docid equal to rowid in segment
result.add(docid);
});
if (query_type == InvertedIndexQueryType::MATCH_ANY_QUERY ||
query_type == InvertedIndexQueryType::MATCH_ALL_QUERY ||
query_type == InvertedIndexQueryType::EQUAL_QUERY) {
SCOPED_RAW_TIMER(&stats->inverted_index_searcher_search_timer);
index_searcher->_search(query.get(), [&result](DocRange* docRange) {
if (docRange->type_ == DocRangeType::kMany) {
result.addMany(docRange->doc_many_size_, docRange->doc_many.data());
} else {
result.addRange(docRange->doc_range.first, docRange->doc_range.second);
}
});
} else {
SCOPED_RAW_TIMER(&stats->inverted_index_searcher_search_timer);
index_searcher->_search(query.get(),
[&result](const int32_t docid, const float_t /*score*/) {
// docid equal to rowid in segment
result.add(docid);
});
}
} catch (const CLuceneError& e) {
if (_is_range_query(query_type) && e.number() == CL_ERR_TooManyClauses) {
return Status::Error<ErrorCode::INVERTED_INDEX_BYPASS>(
Expand Down