* mu-msg-iter.{cc,h}: hook up the msg-iter with threading

This commit is contained in:
Dirk-Jan C. Binnema 2011-06-19 21:04:40 +03:00
parent d28319bc27
commit 0e4b4f7a55
2 changed files with 25 additions and 7 deletions

View File

@ -51,14 +51,14 @@ private:
struct _MuMsgIter {
_MuMsgIter (Xapian::Enquire &enq, size_t maxnum):
_MuMsgIter (Xapian::Enquire &enq, size_t maxnum, gboolean threads):
_enq(enq), _msg(0), _threadhash (0) {
_matches = _enq.get_mset (0, maxnum);
if (!_matches.empty()) {
if (threads && !_matches.empty()) {
_matches.fetch();
_threadhash = mu_msg_threader_calculate (this);
_threadhash = mu_msg_threader_calculate (this, _matches.size());
ThreadKeyMaker keymaker(_threadhash);
enq.set_sort_by_key (&keymaker, false);
_matches = _enq.get_mset (0, maxnum);
@ -76,7 +76,8 @@ struct _MuMsgIter {
if (_msg)
mu_msg_unref (_msg);
g_hash_table_destroy (_threadhash);
if (_threadhash)
g_hash_table_destroy (_threadhash);
}
const Xapian::Enquire _enq;
@ -90,12 +91,12 @@ struct _MuMsgIter {
MuMsgIter*
mu_msg_iter_new (XapianEnquire *enq, size_t maxnum)
mu_msg_iter_new (XapianEnquire *enq, size_t maxnum, gboolean threads)
{
g_return_val_if_fail (enq, NULL);
try {
return new MuMsgIter ((Xapian::Enquire&)*enq, maxnum);
return new MuMsgIter ((Xapian::Enquire&)*enq, maxnum, threads);
} MU_XAPIAN_CATCH_BLOCK_RETURN(NULL);
}

View File

@ -44,11 +44,12 @@ typedef struct _MuMsgIter MuMsgIter;
* @param enq a Xapian::Enquire* cast to XapianEnquire* (because this
* is C, not C++),providing access to search results
* @param batchsize how many results to retrieve at once
* @param threads whether to calculate threads
*
* @return a new MuMsgIter, or NULL in case of error
*/
MuMsgIter *mu_msg_iter_new (XapianEnquire *enq,
size_t batchsize) G_GNUC_WARN_UNUSED_RESULT;
size_t batchsize, gboolean threads) G_GNUC_WARN_UNUSED_RESULT;
/**
* get the next message (which you got from
@ -117,7 +118,23 @@ MuMsg* mu_msg_iter_get_msg (MuMsgIter *iter, GError **err)
unsigned int mu_msg_iter_get_docid (MuMsgIter *iter);
/**
* calculate the message threads
*
* @param iter a valid MuMsgIter iterator
*
* @return TRUE if it worked, FALSE otherwsie.
*/
gboolean mu_msg_iter_calculate_threads (MuMsgIter *iter);
/**
* get a sortable string describing the path of a thread
*
* @param iter a valid MuMsgIter iterator
*
* @return a thread path
*/
const char* mu_msg_iter_get_thread_path (MuMsgIter *iter);
/**