* mu-msg-iter: support reverse sorting
This commit is contained in:
@ -52,7 +52,7 @@ private:
|
|||||||
struct _MuMsgIter {
|
struct _MuMsgIter {
|
||||||
public:
|
public:
|
||||||
_MuMsgIter (Xapian::Enquire &enq, size_t maxnum,
|
_MuMsgIter (Xapian::Enquire &enq, size_t maxnum,
|
||||||
gboolean threads, MuMsgFieldId sortfield):
|
gboolean threads, MuMsgFieldId sortfield, bool revert):
|
||||||
_enq(enq), _thread_hash (0), _msg(0) {
|
_enq(enq), _thread_hash (0), _msg(0) {
|
||||||
|
|
||||||
_matches = _enq.get_mset (0, maxnum);
|
_matches = _enq.get_mset (0, maxnum);
|
||||||
@ -61,7 +61,8 @@ public:
|
|||||||
|
|
||||||
_matches.fetch();
|
_matches.fetch();
|
||||||
_thread_hash = mu_threader_calculate
|
_thread_hash = mu_threader_calculate
|
||||||
(this, _matches.size(), sortfield);
|
(this, _matches.size(), sortfield,
|
||||||
|
revert ? TRUE: FALSE);
|
||||||
|
|
||||||
ThreadKeyMaker keymaker(_thread_hash);
|
ThreadKeyMaker keymaker(_thread_hash);
|
||||||
|
|
||||||
@ -111,7 +112,7 @@ private:
|
|||||||
|
|
||||||
MuMsgIter*
|
MuMsgIter*
|
||||||
mu_msg_iter_new (XapianEnquire *enq, size_t maxnum,
|
mu_msg_iter_new (XapianEnquire *enq, size_t maxnum,
|
||||||
gboolean threads, MuMsgFieldId sortfield)
|
gboolean threads, MuMsgFieldId sortfield, gboolean revert)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (enq, NULL);
|
g_return_val_if_fail (enq, NULL);
|
||||||
/* sortfield should be set to .._NONE when we're not threading */
|
/* sortfield should be set to .._NONE when we're not threading */
|
||||||
@ -122,7 +123,7 @@ mu_msg_iter_new (XapianEnquire *enq, size_t maxnum,
|
|||||||
FALSE);
|
FALSE);
|
||||||
try {
|
try {
|
||||||
return new MuMsgIter ((Xapian::Enquire&)*enq, maxnum, threads,
|
return new MuMsgIter ((Xapian::Enquire&)*enq, maxnum, threads,
|
||||||
sortfield);
|
sortfield, revert ? true : false);
|
||||||
|
|
||||||
} MU_XAPIAN_CATCH_BLOCK_RETURN(NULL);
|
} MU_XAPIAN_CATCH_BLOCK_RETURN(NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,13 +47,14 @@ typedef struct _MuMsgIter MuMsgIter;
|
|||||||
* @param threads whether to calculate threads
|
* @param threads whether to calculate threads
|
||||||
* @param sorting field when using threads; note, when 'threads' is
|
* @param sorting field when using threads; note, when 'threads' is
|
||||||
* FALSE, this should be MU_MSG_FIELD_ID_NONE
|
* FALSE, this should be MU_MSG_FIELD_ID_NONE
|
||||||
|
* @param if TRUE, revert the sorting order
|
||||||
*
|
*
|
||||||
* @return a new MuMsgIter, or NULL in case of error
|
* @return a new MuMsgIter, or NULL in case of error
|
||||||
*/
|
*/
|
||||||
MuMsgIter *mu_msg_iter_new (XapianEnquire *enq,
|
MuMsgIter *mu_msg_iter_new (XapianEnquire *enq,
|
||||||
size_t batchsize,
|
size_t batchsize, gboolean threads,
|
||||||
gboolean threads,
|
MuMsgFieldId threadsortfield,
|
||||||
MuMsgFieldId threadsortfield) G_GNUC_WARN_UNUSED_RESULT;
|
gboolean revert) G_GNUC_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the next message (which you got from
|
* get the next message (which you got from
|
||||||
|
|||||||
Reference in New Issue
Block a user