1
0
mirror of https://github.com/djcb/mu.git synced 2024-06-29 07:51:04 +02:00

* mu-query: create the query in a smarter way, which makes --include-related *much* faster

This commit is contained in:
djcb 2012-12-26 10:12:25 +02:00
parent e70f66647c
commit e456998e7d
2 changed files with 8 additions and 12 deletions

View File

@ -422,7 +422,7 @@ get_related_query (MuMsgIter *iter)
{ {
GHashTable *hash; GHashTable *hash;
GList *id_list, *cur; GList *id_list, *cur;
Xapian::Query query; std::vector<Xapian::Query> qvec;
static std::string pfx (1, mu_msg_field_xapian_prefix static std::string pfx (1, mu_msg_field_xapian_prefix
(MU_MSG_FIELD_ID_THREAD_ID)); (MU_MSG_FIELD_ID_THREAD_ID));
@ -432,20 +432,16 @@ get_related_query (MuMsgIter *iter)
* References. */ * References. */
id_list = g_hash_table_get_keys (hash); id_list = g_hash_table_get_keys (hash);
/* now, let's create a new query matching all of those */ // now, we create a vector with queries for each of the
// g_print ("list: %u\n", (unsigned) g_list_length (id_list)); // thread-ids, which we combine below. This is /much/ faster
for (cur = id_list; cur; cur = g_list_next(cur)) { // than creating the query as 'query = Query (OR, query)'...
query = Xapian::Query (Xapian::Query::OP_OR, for (cur = id_list; cur; cur = g_list_next(cur))
query, qvec.push_back (Xapian::Query((std::string (pfx + (char*)cur->data))));
Xapian::Query((std::string
(pfx + (char*)cur->data))));
}
g_hash_table_destroy (hash); g_hash_table_destroy (hash);
g_list_free (id_list); g_list_free (id_list);
/* now, `query' should match all related messages */ return Xapian::Query (Xapian::Query::OP_OR, qvec.begin(), qvec.end());
return query;
} }

View File

@ -439,7 +439,7 @@ same message, which is a common occurence when using e.g. Gmail together with
the matched messages -- i.e.. include messages that are part of the same the matched messages -- i.e.. include messages that are part of the same
message thread as some matched messages. This is useful if you want message thread as some matched messages. This is useful if you want
Gmail-style 'conversations'. Note, finding these related messages can take a Gmail-style 'conversations'. Note, finding these related messages can take a
bit of time if there are more than a thousand matches. bit of time if there are thousands of matches.
.TP .TP
\fB\-t\fR, \fB\-\-threads\fR show messages in a 'threaded' format -- that is, \fB\-t\fR, \fB\-\-threads\fR show messages in a 'threaded' format -- that is,