From f16f570273b613b2baff92082fef5bbf21ec601e Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Sat, 23 Oct 2021 11:31:30 +0300 Subject: [PATCH] mu-query: honor maxnum for threaded queries --- lib/mu-query.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/mu-query.cc b/lib/mu-query.cc index 59e997348..9cd88d478 100644 --- a/lib/mu-query.cc +++ b/lib/mu-query.cc @@ -49,7 +49,7 @@ struct Query::Private { MuMsgFieldId sortfieldid, QueryFlags qflags) const; Option run_threaded (QueryResults&& qres, Xapian::Enquire& enq, - QueryFlags qflags) const; + QueryFlags qflags, size_t maxnum) const; Option run_singular (const std::string& expr, MuMsgFieldId sortfieldid, QueryFlags qflags, size_t maxnum) const; Option run_related (const std::string& expr, MuMsgFieldId sortfieldid, @@ -127,7 +127,7 @@ struct ThreadKeyMaker: public Xapian::KeyMaker { Option Query::Private::run_threaded (QueryResults&& qres, Xapian::Enquire& enq, - QueryFlags qflags) const + QueryFlags qflags, size_t maxnum) const { const auto descending{any_of(qflags & QueryFlags::Descending)}; @@ -138,7 +138,7 @@ Query::Private::run_threaded (QueryResults&& qres, Xapian::Enquire& enq, DeciderInfo minfo; minfo.matches = qres.query_matches(); - auto mset{enq.get_mset(0, store_.size(), {}, + auto mset{enq.get_mset(0, maxnum, {}, make_thread_decider(qflags, minfo).get())}; mset.fetch(); @@ -170,7 +170,7 @@ Query::Private::run_singular (const std::string& expr, MuMsgFieldId sortfieldid, auto qres{QueryResults{mset, std::move(minfo.matches)}}; - return threading ? run_threaded(std::move(qres), enq, qflags) : qres; + return threading ? run_threaded(std::move(qres), enq, qflags, maxnum) : qres; } static Option @@ -217,7 +217,7 @@ Query::Private::run_related (const std::string& expr, MuMsgFieldId sortfieldid, const auto r_mset{r_enq.get_mset(0, threading ? store_.size() : maxnum, {}, make_related_decider(qflags, minfo).get())}; auto qres{QueryResults{r_mset, std::move(minfo.matches)}}; - return threading ? run_threaded(std::move(qres), r_enq, qflags) : qres; + return threading ? run_threaded(std::move(qres), r_enq, qflags, maxnum) : qres; }