This is an automated email from the ASF dual-hosted git repository.
jianliangqi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 2995a78bc1d [fix](inverted index) fix incorrect case test_index_delete
(#33609)
2995a78bc1d is described below
commit 2995a78bc1da5d4fdd5fcd47992a2a2889190d69
Author: zzzxl <[email protected]>
AuthorDate: Thu Apr 18 10:03:07 2024 +0800
[fix](inverted index) fix incorrect case test_index_delete (#33609)
---
.../inverted_index/query/disjunction_query.cpp | 48 ++++++++--------------
.../inverted_index/query/disjunction_query.h | 7 ++--
2 files changed, 19 insertions(+), 36 deletions(-)
diff --git
a/be/src/olap/rowset/segment_v2/inverted_index/query/disjunction_query.cpp
b/be/src/olap/rowset/segment_v2/inverted_index/query/disjunction_query.cpp
index 0514e1a372a..650a88c0646 100644
--- a/be/src/olap/rowset/segment_v2/inverted_index/query/disjunction_query.cpp
+++ b/be/src/olap/rowset/segment_v2/inverted_index/query/disjunction_query.cpp
@@ -23,59 +23,43 @@ DisjunctionQuery::DisjunctionQuery(const
std::shared_ptr<lucene::search::IndexSe
const TQueryOptions& query_options)
: _searcher(searcher) {}
-DisjunctionQuery::~DisjunctionQuery() {
- for (auto& term_doc : _term_docs) {
- if (term_doc) {
- _CLDELETE(term_doc);
- }
- }
- for (auto& term : _terms) {
- if (term) {
- _CLDELETE(term);
- }
- }
-}
-
void DisjunctionQuery::add(const std::wstring& field_name, const
std::vector<std::string>& terms) {
if (terms.empty()) {
_CLTHROWA(CL_ERR_IllegalArgument, "DisjunctionQuery::add: terms
empty");
}
- for (const auto& term : terms) {
- std::wstring ws_term = StringUtil::string_to_wstring(term);
- Term* t = _CLNEW Term(field_name.c_str(), ws_term.c_str());
- _terms.push_back(t);
- TermDocs* term_doc = _searcher->getReader()->termDocs(t);
- _term_docs.push_back(term_doc);
- _term_iterators.emplace_back(term_doc);
- }
+ _field_name = field_name;
+ _terms = terms;
}
void DisjunctionQuery::search(roaring::Roaring& roaring) {
- roaring::Roaring result;
- auto func = [&roaring](const TermIterator& term_docs, bool first) {
- roaring::Roaring result;
+ auto func = [this, &roaring](const std::string& term, bool first) {
+ std::wstring ws_term = StringUtil::string_to_wstring(term);
+ auto* t = _CLNEW Term(_field_name.c_str(), ws_term.c_str());
+ auto* term_doc = _searcher->getReader()->termDocs(t);
+ TermIterator iterator(term_doc);
+
DocRange doc_range;
- while (term_docs.readRange(&doc_range)) {
+ roaring::Roaring result;
+ while (iterator.readRange(&doc_range)) {
if (doc_range.type_ == DocRangeType::kMany) {
result.addMany(doc_range.doc_many_size_,
doc_range.doc_many->data());
} else {
result.addRange(doc_range.doc_range.first,
doc_range.doc_range.second);
}
}
+
+ _CLDELETE(term_doc);
+ _CLDELETE(t);
+
if (first) {
roaring.swap(result);
} else {
roaring |= result;
}
};
- for (int i = 0; i < _term_iterators.size(); i++) {
- auto& iter = _term_iterators[i];
- if (i == 0) {
- func(iter, true);
- } else {
- func(iter, false);
- }
+ for (int i = 0; i < _terms.size(); i++) {
+ func(_terms[i], i == 0);
}
}
diff --git
a/be/src/olap/rowset/segment_v2/inverted_index/query/disjunction_query.h
b/be/src/olap/rowset/segment_v2/inverted_index/query/disjunction_query.h
index 9a1e5df759c..35783146157 100644
--- a/be/src/olap/rowset/segment_v2/inverted_index/query/disjunction_query.h
+++ b/be/src/olap/rowset/segment_v2/inverted_index/query/disjunction_query.h
@@ -28,7 +28,7 @@ class DisjunctionQuery : public Query {
public:
DisjunctionQuery(const std::shared_ptr<lucene::search::IndexSearcher>&
searcher,
const TQueryOptions& query_options);
- ~DisjunctionQuery() override;
+ ~DisjunctionQuery() override = default;
void add(const std::wstring& field_name, const std::vector<std::string>&
terms) override;
void search(roaring::Roaring& roaring) override;
@@ -36,9 +36,8 @@ public:
private:
std::shared_ptr<lucene::search::IndexSearcher> _searcher;
- std::vector<Term*> _terms;
- std::vector<TermDocs*> _term_docs;
- std::vector<TermIterator> _term_iterators;
+ std::wstring _field_name;
+ std::vector<std::string> _terms;
};
} // namespace doris::segment_v2
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]