mirror of https://github.com/djcb/mu.git
mu-query: tweaks threaded/threaded querying
This commit is contained in:
parent
50511a7460
commit
bba8af8d51
|
@ -164,7 +164,7 @@ Query::Private::run_singular (const std::string& expr, MuMsgFieldId sortfieldid,
|
||||||
const auto threading{any_of(qflags & QueryFlags::Threading)};
|
const auto threading{any_of(qflags & QueryFlags::Threading)};
|
||||||
|
|
||||||
DeciderInfo minfo{};
|
DeciderInfo minfo{};
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wextra"
|
#pragma GCC diagnostic ignored "-Wextra"
|
||||||
auto enq{make_enquire(expr, threading ? MU_MSG_FIELD_ID_DATE : sortfieldid, qflags)};
|
auto enq{make_enquire(expr, threading ? MU_MSG_FIELD_ID_DATE : sortfieldid, qflags)};
|
||||||
#pragma GCC diagnostic ignored "-Wswitch-default"
|
#pragma GCC diagnostic ignored "-Wswitch-default"
|
||||||
|
@ -173,10 +173,8 @@ Query::Private::run_singular (const std::string& expr, MuMsgFieldId sortfieldid,
|
||||||
mset.fetch();
|
mset.fetch();
|
||||||
|
|
||||||
auto qres{QueryResults{mset, std::move(minfo.matches)}};
|
auto qres{QueryResults{mset, std::move(minfo.matches)}};
|
||||||
if (!threading)
|
|
||||||
return qres;
|
return threading ? run_threaded(qres, enq, qflags) : qres;
|
||||||
else
|
|
||||||
return run_threaded(qres, enq, qflags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -194,26 +192,24 @@ Query::Private::run_related (const std::string& expr, MuMsgFieldId sortfieldid,
|
||||||
const auto leader_qflags{QueryFlags::Leader | QueryFlags::GatherThreadIds};
|
const auto leader_qflags{QueryFlags::Leader | QueryFlags::GatherThreadIds};
|
||||||
const auto threading{any_of(qflags & QueryFlags::Threading)};
|
const auto threading{any_of(qflags & QueryFlags::Threading)};
|
||||||
|
|
||||||
// Run our first, "leader" query;
|
// Run our first, "leader" query
|
||||||
DeciderInfo minfo{};
|
DeciderInfo minfo{};
|
||||||
auto enq{make_enquire(expr, MU_MSG_FIELD_ID_DATE, leader_qflags)};
|
auto enq{make_enquire(expr, sortfieldid, leader_qflags)};
|
||||||
const auto mset{enq.get_mset(0, maxnum, {},
|
const auto mset{enq.get_mset(0, maxnum, {},
|
||||||
make_leader_decider(leader_qflags, minfo).get())};
|
make_leader_decider(leader_qflags, minfo).get())};
|
||||||
|
|
||||||
// Now, determine the "related query". In the threaded-case, we search
|
// Now, determine the "related query".
|
||||||
// among _all_ messages, since complete threads are preferred; no need
|
//
|
||||||
// to sort in that case since the search is unlimited and the sorting
|
// In the threaded-case, we search among _all_ messages, since complete
|
||||||
// happens during threading.
|
// threads are preferred; no need to sort in that case since the search
|
||||||
|
// is unlimited and the sorting happens during threading.
|
||||||
auto r_enq{make_related_enquire(enq.get_query(), minfo.thread_ids,
|
auto r_enq{make_related_enquire(enq.get_query(), minfo.thread_ids,
|
||||||
threading ? MU_MSG_FIELD_ID_NONE : sortfieldid, qflags)};
|
threading ? MU_MSG_FIELD_ID_NONE : sortfieldid, qflags)};
|
||||||
const auto r_mset{r_enq.get_mset(0, threading ? store_.size() : maxnum,
|
const auto r_mset{r_enq.get_mset(0, threading ? store_.size() : maxnum,
|
||||||
{}, make_related_decider(qflags, minfo).get())};
|
{}, make_related_decider(qflags, minfo).get())};
|
||||||
|
|
||||||
auto qres{QueryResults{r_mset, std::move(minfo.matches)}};
|
auto qres{QueryResults{r_mset, std::move(minfo.matches)}};
|
||||||
if (!threading)
|
|
||||||
return qres;
|
return threading ? run_threaded(qres, r_enq, qflags) : qres;
|
||||||
else
|
|
||||||
return run_threaded(qres, r_enq, qflags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Option<QueryResults>
|
Option<QueryResults>
|
||||||
|
@ -221,11 +217,15 @@ Query::Private::run (const std::string& expr, MuMsgFieldId sortfieldid,
|
||||||
QueryFlags qflags, size_t maxnum) const
|
QueryFlags qflags, size_t maxnum) const
|
||||||
{
|
{
|
||||||
const auto eff_maxnum{maxnum == 0 ? store_.size() : maxnum};
|
const auto eff_maxnum{maxnum == 0 ? store_.size() : maxnum};
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wextra"
|
||||||
|
const auto eff_sortfield{sortfieldid == MU_MSG_FIELD_ID_NONE ?
|
||||||
|
MU_MSG_FIELD_ID_DATE : sortfieldid };
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
if (any_of(qflags & QueryFlags::IncludeRelated))
|
if (any_of(qflags & QueryFlags::IncludeRelated))
|
||||||
return run_related (expr, sortfieldid, qflags, eff_maxnum);
|
return run_related (expr, eff_sortfield, qflags, eff_maxnum);
|
||||||
else
|
else
|
||||||
return run_singular(expr, sortfieldid, qflags, eff_maxnum);
|
return run_singular(expr, eff_sortfield, qflags, eff_maxnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,16 @@ public:
|
||||||
*/
|
*/
|
||||||
Query(Query&& other);
|
Query(Query&& other);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run a query on the store
|
||||||
|
*
|
||||||
|
* @param expr the search expression
|
||||||
|
* @param sortfieldid the sortfield-id. If the field is NONE, sort by DATE
|
||||||
|
* @param flags query flags
|
||||||
|
* @param maxnum maximum number of results to return. 0 for 'no limit'
|
||||||
|
*
|
||||||
|
* @return the query-results, or Nothing in case of error.
|
||||||
|
*/
|
||||||
Option<QueryResults> run(const std::string& expr="",
|
Option<QueryResults> run(const std::string& expr="",
|
||||||
MuMsgFieldId sortfieldid=MU_MSG_FIELD_ID_NONE,
|
MuMsgFieldId sortfieldid=MU_MSG_FIELD_ID_NONE,
|
||||||
QueryFlags flags=QueryFlags::None,
|
QueryFlags flags=QueryFlags::None,
|
||||||
|
|
Loading…
Reference in New Issue