diff options
| author | Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> | 2021-06-04 00:44:28 +0300 |
|---|---|---|
| committer | Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> | 2021-06-04 00:54:28 +0300 |
| commit | 047c10453a48e6638fe04d6fae6725342d8410c0 (patch) | |
| tree | d072ad34abea0c8614c4138cf758810b8f69b916 | |
| parent | 212641669e1f2b9ed553b82d8b1018bf13bed43c (diff) | |
query: gather related ids from mset, not match-decider
Since we only want the (smaller) set from the mset, not the (full) set
that the match-decider sees.
| -rw-r--r-- | lib/mu-query-match-deciders.cc | 4 | ||||
| -rw-r--r-- | lib/mu-query.cc | 16 |
2 files changed, 17 insertions, 3 deletions
diff --git a/lib/mu-query-match-deciders.cc b/lib/mu-query-match-deciders.cc index 9f5a8ae..b0d0732 100644 --- a/lib/mu-query-match-deciders.cc +++ b/lib/mu-query-match-deciders.cc @@ -140,8 +140,8 @@ struct MatchDeciderLeader final: public MatchDecider { it.first->second.flags |= QueryMatch::Flags::Leader; if (should_include(it.first->second)) { - if (any_of(qflags_ & QueryFlags::GatherThreadIds)) - gather_thread_ids(doc); + // if (any_of(qflags_ & QueryFlags::GatherThreadIds)) + // gather_thread_ids(doc); return true; } return false; diff --git a/lib/mu-query.cc b/lib/mu-query.cc index 9f36e2c..0a1adb7 100644 --- a/lib/mu-query.cc +++ b/lib/mu-query.cc @@ -1,5 +1,5 @@ /* -** Copyright (C) 2008-2020 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> +** Copyright (C) 2008-2021 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -175,6 +175,11 @@ Query::Private::run_singular (const std::string& expr, MuMsgFieldId sortfieldid, return threading ? run_threaded(std::move(qres), enq, qflags, maxnum) : qres; } +static Option<std::string> +opt_string(const Xapian::Document& doc, MuMsgFieldId id) noexcept try { + auto&& val{doc.get_value(id)}; + return val.empty() ? Nothing : Some(val); +} MU_XAPIAN_CATCH_BLOCK_RETURN (Nothing); Option<QueryResults> Query::Private::run_related (const std::string& expr, MuMsgFieldId sortfieldid, @@ -196,6 +201,14 @@ Query::Private::run_related (const std::string& expr, MuMsgFieldId sortfieldid, const auto mset{enq.get_mset(0, maxnum, {}, make_leader_decider(leader_qflags, minfo).get())}; + // Gather the thread-ids we found + mset.fetch(); + for (auto it = mset.begin(); it != mset.end(); ++it) { + auto thread_id{opt_string(it.get_document(), MU_MSG_FIELD_ID_THREAD_ID)}; + if (thread_id) + minfo.thread_ids.emplace(std::move(*thread_id)); + } + // Now, determine the "related query". // // In the threaded-case, we search among _all_ messages, since complete @@ -210,6 +223,7 @@ Query::Private::run_related (const std::string& expr, MuMsgFieldId sortfieldid, return threading ? run_threaded(std::move(qres), r_enq, qflags, maxnum) : qres; } + Option<QueryResults> Query::Private::run (const std::string& expr, MuMsgFieldId sortfieldid, QueryFlags qflags, size_t maxnum) const |
