* mu-query: re-introduce MU_QUERY_FLAG_THREADS, and only calculate threads for
the _second_ query when doing an --include-related query
This commit is contained in:
@ -370,6 +370,8 @@ msg_iter_flags (MuQueryFlags flags)
|
|||||||
iflags |= MU_MSG_ITER_FLAG_SKIP_UNREADABLE;
|
iflags |= MU_MSG_ITER_FLAG_SKIP_UNREADABLE;
|
||||||
if (flags & MU_QUERY_FLAG_SKIP_DUPS)
|
if (flags & MU_QUERY_FLAG_SKIP_DUPS)
|
||||||
iflags |= MU_MSG_ITER_FLAG_SKIP_DUPS;
|
iflags |= MU_MSG_ITER_FLAG_SKIP_DUPS;
|
||||||
|
if (flags & MU_QUERY_FLAG_THREADS)
|
||||||
|
iflags |= MU_MSG_ITER_FLAG_THREADS;
|
||||||
|
|
||||||
return iflags;
|
return iflags;
|
||||||
}
|
}
|
||||||
@ -478,23 +480,38 @@ mu_query_run (MuQuery *self, const char *searchexpr, MuMsgFieldId sortfieldid,
|
|||||||
NULL);
|
NULL);
|
||||||
try {
|
try {
|
||||||
MuMsgIter *iter;
|
MuMsgIter *iter;
|
||||||
bool descending = flags & MU_QUERY_FLAG_DESCENDING;
|
MuQueryFlags first_flags;
|
||||||
|
bool inc_related = flags & MU_QUERY_FLAG_INCLUDE_RELATED;
|
||||||
|
bool descending = flags & MU_QUERY_FLAG_DESCENDING;
|
||||||
Xapian::Enquire enq (get_enquire(self, searchexpr, sortfieldid,
|
Xapian::Enquire enq (get_enquire(self, searchexpr, sortfieldid,
|
||||||
descending, err));
|
descending, err));
|
||||||
|
|
||||||
|
/* when we're doing a 'include-related query', we're
|
||||||
|
* actually doing /two/ queries; one to get the
|
||||||
|
* initial matches, and based on that one to get all
|
||||||
|
* messages in threads in those matches.
|
||||||
|
*/
|
||||||
|
|
||||||
/* get the 'real' maxnum if it was specified as < 0 */
|
/* get the 'real' maxnum if it was specified as < 0 */
|
||||||
maxnum = maxnum <= 0 ? self->db().get_doccount() : maxnum;
|
maxnum = maxnum < 0 ? self->db().get_doccount() : maxnum;
|
||||||
|
/* if we do a include-related query, it's wasted
|
||||||
|
* effort to calculate threads already in the first
|
||||||
|
* query since we can do it in the second one
|
||||||
|
*/
|
||||||
|
first_flags = inc_related ? (flags & ~MU_QUERY_FLAG_THREADS) : flags;
|
||||||
|
|
||||||
iter = mu_msg_iter_new (
|
iter = mu_msg_iter_new (
|
||||||
reinterpret_cast<XapianEnquire*>(&enq),
|
reinterpret_cast<XapianEnquire*>(&enq),
|
||||||
maxnum,
|
maxnum,
|
||||||
sortfieldid,
|
sortfieldid,
|
||||||
msg_iter_flags (flags),
|
msg_iter_flags (first_flags),
|
||||||
err);
|
err);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if we want related messages, do a second query,
|
* if we want related messages, do a second query,
|
||||||
* based on the message ids / refs of the first one
|
* based on the message ids / refs of the first one
|
||||||
* */
|
* */
|
||||||
if (flags & MU_QUERY_FLAG_INCLUDE_RELATED)
|
if (inc_related)
|
||||||
include_related (self, &iter, maxnum, sortfieldid, flags);
|
include_related (self, &iter, maxnum, sortfieldid, flags);
|
||||||
|
|
||||||
if (err && *err && (*err)->code == MU_ERROR_XAPIAN_MODIFIED) {
|
if (err && *err && (*err)->code == MU_ERROR_XAPIAN_MODIFIED) {
|
||||||
|
|||||||
@ -71,9 +71,10 @@ enum _MuQueryFlags {
|
|||||||
MU_QUERY_FLAG_DESCENDING = 1 << 0, /**< sort z->a */
|
MU_QUERY_FLAG_DESCENDING = 1 << 0, /**< sort z->a */
|
||||||
MU_QUERY_FLAG_SKIP_UNREADABLE = 1 << 1, /**< skip unreadable msgs */
|
MU_QUERY_FLAG_SKIP_UNREADABLE = 1 << 1, /**< skip unreadable msgs */
|
||||||
MU_QUERY_FLAG_SKIP_DUPS = 1 << 2, /**< skip duplicate msgs */
|
MU_QUERY_FLAG_SKIP_DUPS = 1 << 2, /**< skip duplicate msgs */
|
||||||
MU_QUERY_FLAG_INCLUDE_RELATED = 1 << 3 /**< include related msgs */
|
MU_QUERY_FLAG_INCLUDE_RELATED = 1 << 3, /**< include related msgs */
|
||||||
|
MU_QUERY_FLAG_THREADS = 1 << 4 /**< calculate threading info */
|
||||||
};
|
};
|
||||||
typedef enum _MuQueryFlags MuQueryFlags;
|
typedef int MuQueryFlags;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* run a Xapian query; for the syntax, please refer to the mu-find
|
* run a Xapian query; for the syntax, please refer to the mu-find
|
||||||
|
|||||||
Reference in New Issue
Block a user