Skip to content

Commit

Permalink
mu-query: honor maxnum for threaded queries
Browse files Browse the repository at this point in the history
  • Loading branch information
djcb committed Oct 23, 2021
1 parent 8bb5b03 commit f16f570
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/mu-query.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct Query::Private {
MuMsgFieldId sortfieldid, QueryFlags qflags) const;

Option<QueryResults> run_threaded (QueryResults&& qres, Xapian::Enquire& enq,
QueryFlags qflags) const;
QueryFlags qflags, size_t maxnum) const;
Option<QueryResults> run_singular (const std::string& expr, MuMsgFieldId sortfieldid,
QueryFlags qflags, size_t maxnum) const;
Option<QueryResults> run_related (const std::string& expr, MuMsgFieldId sortfieldid,
Expand Down Expand Up @@ -127,7 +127,7 @@ struct ThreadKeyMaker: public Xapian::KeyMaker {

Option<QueryResults>
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)};

Expand All @@ -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();

Expand Down Expand Up @@ -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<std::string>
Expand Down Expand Up @@ -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;
}


Expand Down

0 comments on commit f16f570

Please sign in to comment.