github-actions[bot] commented on code in PR #15823: URL: https://github.com/apache/doris/pull/15823#discussion_r1069577366
########## be/src/olap/rowset/segment_v2/inverted_index_reader.cpp: ########## @@ -17,30 +17,293 @@ #include "olap/rowset/segment_v2/inverted_index_reader.h" -#include "common/status.h" +#include <CLucene/search/BooleanQuery.h> +#include <CLucene/search/PhraseQuery.h> + +#include "common/config.h" +#include "gutil/strings/strip.h" +#include "io/fs/file_system.h" +#include "olap/key_coder.h" +#include "olap/rowset/segment_v2/inverted_index_compound_directory.h" +#include "olap/rowset/segment_v2/inverted_index_compound_reader.h" +#include "olap/rowset/segment_v2/inverted_index_desc.h" +#include "olap/tablet_schema.h" +#include "olap/utils.h" +#include "runtime/string_value.h" +#include "util/time.h" namespace doris { namespace segment_v2 { +bool InvertedIndexReader::_is_match_query(InvertedIndexQueryType query_type) { + return (query_type == InvertedIndexQueryType::MATCH_ANY_QUERY || + query_type == InvertedIndexQueryType::MATCH_ALL_QUERY || + query_type == InvertedIndexQueryType::MATCH_PHRASE_QUERY); +} + bool InvertedIndexReader::indexExists(io::Path& index_file_path) { bool exists = false; RETURN_IF_ERROR(_fs->exists(index_file_path, &exists)); return exists; } +std::vector<std::string> FullTextIndexReader::get_analyse_result( + const std::wstring& field_name, const std::wstring& value, + InvertedIndexQueryType query_type, InvertedIndexParserType analyser_type) { + std::vector<std::string> analyse_result; + std::shared_ptr<lucene::analysis::Analyzer> analyzer; + if (analyser_type == InvertedIndexParserType::PARSER_STANDARD) { + analyzer = std::make_shared<lucene::analysis::standard::StandardAnalyzer>(); + } else { + // default + analyzer = std::make_shared<lucene::analysis::SimpleAnalyzer<TCHAR>>(); + } + + std::unique_ptr<lucene::util::StringReader> reader( + new lucene::util::StringReader(value.c_str())); + std::unique_ptr<lucene::analysis::TokenStream> token_stream( + analyzer->tokenStream(field_name.c_str(), reader.get())); + + lucene::analysis::Token token; + + while (token_stream->next(&token)) { + std::string tk = + lucene::util::Misc::toString(token.termBuffer<TCHAR>(), token.termLength<TCHAR>()); + analyse_result.emplace_back(tk); + } + + if (token_stream != nullptr) { + token_stream->close(); + } + + if (query_type == InvertedIndexQueryType::MATCH_ANY_QUERY || + query_type == InvertedIndexQueryType::MATCH_ALL_QUERY) { + std::set<std::string> unrepeated_result(analyse_result.begin(), analyse_result.end()); + analyse_result.assign(unrepeated_result.begin(), unrepeated_result.end()); + } + + return analyse_result; +} + +Status FullTextIndexReader::new_iterator(const TabletIndex* index_meta, + InvertedIndexIterator** iterator) { + *iterator = new InvertedIndexIterator(index_meta, this); + return Status::OK(); +} + +Status FullTextIndexReader::query(const std::string& column_name, const void* query_value, + InvertedIndexQueryType query_type, + InvertedIndexParserType analyser_type, + roaring::Roaring* bit_map) { + std::string search_str = reinterpret_cast<const StringValue*>(query_value)->to_string(); + VLOG_DEBUG << column_name + << " begin to load the fulltext index from clucene, query_str=" << search_str; + std::unique_ptr<lucene::search::Query> query; + std::wstring field_ws = std::wstring(column_name.begin(), column_name.end()); + std::wstring search_str_ws = std::wstring(search_str.begin(), search_str.end()); + try { + std::vector<std::string> analyse_result = + std::move(get_analyse_result(field_ws, search_str_ws, query_type, analyser_type)); Review Comment: warning: moving a temporary object prevents copy elision [clang-diagnostic-pessimizing-move] ```cpp std::move(get_analyse_result(field_ws, search_str_ws, query_type, analyser_type)); ^ ``` **be/src/olap/rowset/segment_v2/inverted_index_reader.cpp:105:** remove std::move call here ```cpp std::move(get_analyse_result(field_ws, search_str_ws, query_type, analyser_type)); ^ ``` -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org