Skip to content

Commit

Permalink
[Optimize](index) Optimize implement the new internal lucene index qu…
Browse files Browse the repository at this point in the history
…ery interface (apache#23389)
  • Loading branch information
zzzxl1993 authored Aug 25, 2023
1 parent d30bb80 commit 2847c5e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 13 deletions.
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

0 comments on commit 2847c5e

Please sign in to comment.