* lib: threading: pre-sort the threaded results, add some more comments
This commit is contained in:
@ -548,10 +548,10 @@ thread_info_destroy (MuMsgIterThreadInfo *ti)
|
|||||||
|
|
||||||
|
|
||||||
struct _ThreadInfo {
|
struct _ThreadInfo {
|
||||||
GHashTable *hash;
|
GHashTable *hash;
|
||||||
const char* format;
|
const char *format;
|
||||||
};
|
};
|
||||||
typedef struct _ThreadInfo ThreadInfo;
|
typedef struct _ThreadInfo ThreadInfo;
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -589,7 +589,7 @@ thread_segment_format_string (size_t matchnum)
|
|||||||
/* get the number of digits needed in a hex-representation of
|
/* get the number of digits needed in a hex-representation of
|
||||||
* matchnum */
|
* matchnum */
|
||||||
digitnum = (unsigned) (ceil (log(matchnum)/log(16)));
|
digitnum = (unsigned) (ceil (log(matchnum)/log(16)));
|
||||||
snprintf (frmt, sizeof(frmt),"%%0%ux", digitnum);
|
snprintf (frmt, sizeof(frmt), "%%0%ux", digitnum);
|
||||||
|
|
||||||
return frmt;
|
return frmt;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,6 +57,9 @@ public:
|
|||||||
|
|
||||||
_matches = _enq.get_mset (0, maxnum);
|
_matches = _enq.get_mset (0, maxnum);
|
||||||
|
|
||||||
|
/* when threading, we calculate the threads for the
|
||||||
|
* set of matches, then requery/sort based on the
|
||||||
|
* threading */
|
||||||
if (threads && !_matches.empty()) {
|
if (threads && !_matches.empty()) {
|
||||||
|
|
||||||
_matches.fetch();
|
_matches.fetch();
|
||||||
|
|||||||
@ -335,12 +335,11 @@ get_enquire (MuQuery *self, const char *searchexpr, gboolean threads,
|
|||||||
{
|
{
|
||||||
Xapian::Enquire enq (self->db());
|
Xapian::Enquire enq (self->db());
|
||||||
|
|
||||||
/* note, when our result will be *threaded*, we sort
|
if (sortfieldid != MU_MSG_FIELD_ID_NONE)
|
||||||
* in our threading code (mu-threader etc.), and don't
|
enq.set_sort_by_value ((Xapian::valueno)sortfieldid,
|
||||||
* let Xapian do any sorting */
|
revert ? true : false);
|
||||||
if (!threads && sortfieldid != MU_MSG_FIELD_ID_NONE)
|
|
||||||
enq.set_sort_by_value ((Xapian::valueno)sortfieldid,
|
/* empty or "" means "matchall" */
|
||||||
revert ? true : false);
|
|
||||||
if (!mu_str_is_empty(searchexpr) &&
|
if (!mu_str_is_empty(searchexpr) &&
|
||||||
g_strcmp0 (searchexpr, "\"\"") != 0) /* NULL or "" or """" */
|
g_strcmp0 (searchexpr, "\"\"") != 0) /* NULL or "" or """" */
|
||||||
enq.set_query(get_query (self, searchexpr, err));
|
enq.set_query(get_query (self, searchexpr, err));
|
||||||
@ -367,15 +366,22 @@ mu_query_run (MuQuery *self, const char* searchexpr, gboolean threads,
|
|||||||
MuMsgIter *iter;
|
MuMsgIter *iter;
|
||||||
Xapian::Enquire enq (get_enquire(self, searchexpr, threads,
|
Xapian::Enquire enq (get_enquire(self, searchexpr, threads,
|
||||||
sortfieldid, revert, err));
|
sortfieldid, revert, err));
|
||||||
|
|
||||||
|
/* get the 'real' maxnum if it was specified as < 0 */
|
||||||
|
maxnum <= 0 ? self->db().get_doccount() : maxnum;
|
||||||
|
|
||||||
iter = mu_msg_iter_new (
|
iter = mu_msg_iter_new (
|
||||||
reinterpret_cast<XapianEnquire*>(&enq),
|
reinterpret_cast<XapianEnquire*>(&enq),
|
||||||
maxnum <= 0 ? self->db().get_doccount() : maxnum,
|
maxnum, threads,
|
||||||
threads, threads ? sortfieldid : MU_MSG_FIELD_ID_NONE,
|
/* in we were *not* using threads, no further sorting
|
||||||
|
* is needed since Xapian already sorted */
|
||||||
|
threads ? sortfieldid : MU_MSG_FIELD_ID_NONE,
|
||||||
revert, err);
|
revert, err);
|
||||||
|
|
||||||
if (err && *err && (*err)->code == MU_ERROR_XAPIAN_MODIFIED) {
|
if (err && *err && (*err)->code == MU_ERROR_XAPIAN_MODIFIED) {
|
||||||
g_clear_error (err);
|
g_clear_error (err);
|
||||||
return try_requery (self, searchexpr, threads, sortfieldid,
|
return try_requery (self, searchexpr, threads,
|
||||||
|
sortfieldid,
|
||||||
revert, maxnum, err);
|
revert, maxnum, err);
|
||||||
} else
|
} else
|
||||||
return iter;
|
return iter;
|
||||||
|
|||||||
@ -48,12 +48,12 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/* step 1 */ static GHashTable* create_containers (MuMsgIter *iter);
|
/* step 1 */ static GHashTable* create_containers (MuMsgIter *iter);
|
||||||
/* step 2 */ static MuContainer *find_root_set (GHashTable *ids);
|
/* step 2 */ static MuContainer *find_root_set (GHashTable *ids);
|
||||||
static MuContainer* prune_empty_containers (MuContainer *root);
|
static MuContainer* prune_empty_containers (MuContainer *root);
|
||||||
/* static void group_root_set_by_subject (GSList *root_set); */
|
/* static void group_root_set_by_subject (GSList *root_set); */
|
||||||
GHashTable* create_doc_id_thread_path_hash (MuContainer *root, size_t match_num);
|
GHashTable* create_doc_id_thread_path_hash (MuContainer *root,
|
||||||
|
size_t match_num);
|
||||||
|
|
||||||
/* msg threading algorithm, based on JWZ's algorithm,
|
/* msg threading algorithm, based on JWZ's algorithm,
|
||||||
* http://www.jwz.org/doc/threading.html */
|
* http://www.jwz.org/doc/threading.html */
|
||||||
@ -125,9 +125,8 @@ assert_no_duplicates (GHashTable *ids)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* a referred message is a message that is refered by some other
|
||||||
|
* message */
|
||||||
/* a referred message is a message that is refered by some other message */
|
|
||||||
static MuContainer*
|
static MuContainer*
|
||||||
find_or_create_referred (GHashTable *id_table, const char *msgid,
|
find_or_create_referred (GHashTable *id_table, const char *msgid,
|
||||||
gboolean *created)
|
gboolean *created)
|
||||||
@ -297,8 +296,7 @@ static GHashTable*
|
|||||||
create_containers (MuMsgIter *iter)
|
create_containers (MuMsgIter *iter)
|
||||||
{
|
{
|
||||||
GHashTable *id_table;
|
GHashTable *id_table;
|
||||||
id_table = g_hash_table_new_full (g_str_hash,
|
id_table = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||||
g_str_equal,
|
|
||||||
NULL,
|
NULL,
|
||||||
(GDestroyNotify)mu_container_destroy);
|
(GDestroyNotify)mu_container_destroy);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user