[PATCH 3/4] lib: define specialized get_thread_id for use in thread subquery
Jani Nikula
jani at nikula.org
Sun May 6 11:03:39 PDT 2018
On Sat, 05 May 2018, David Bremner <david at tethera.net> wrote:
> The observation is that we are only using the messages to get there
> thread_id, which is kindof a pessimal access pattern for the current
> notmuch_message_get_thread_id
LGTM.
> ---
> lib/message.cc | 17 +++++++++++++++++
> lib/notmuch-private.h | 4 ++++
> lib/thread-fp.cc | 2 +-
> 3 files changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/lib/message.cc b/lib/message.cc
> index d5db89b6..b2067076 100644
> --- a/lib/message.cc
> +++ b/lib/message.cc
> @@ -318,6 +318,23 @@ _notmuch_message_get_term (notmuch_message_t *message,
> return value;
> }
>
> +/*
> + * For special applications where we only want the thread id, reading
> + * in all metadata is a heavy I/O penalty.
> + */
> +const char *
> +_notmuch_message_get_thread_id_only (notmuch_message_t *message)
> +{
> +
> + Xapian::TermIterator i = message->doc.termlist_begin ();
> + Xapian::TermIterator end = message->doc.termlist_end ();
> +
> + message->thread_id = _notmuch_message_get_term (message, i, end,
> + _find_prefix ("thread"));
> + return message->thread_id;
> +}
> +
> +
> static void
> _notmuch_message_ensure_metadata (notmuch_message_t *message, void *field)
> {
> diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
> index 1093429c..4598577f 100644
> --- a/lib/notmuch-private.h
> +++ b/lib/notmuch-private.h
> @@ -537,6 +537,10 @@ _notmuch_message_database (notmuch_message_t *message);
>
> void
> _notmuch_message_remove_unprefixed_terms (notmuch_message_t *message);
> +
> +const char *
> +_notmuch_message_get_thread_id_only(notmuch_message_t *message);
> +
> /* sha1.c */
>
> char *
> diff --git a/lib/thread-fp.cc b/lib/thread-fp.cc
> index dd292bf6..661d00dd 100644
> --- a/lib/thread-fp.cc
> +++ b/lib/thread-fp.cc
> @@ -50,7 +50,7 @@ ThreadFieldProcessor::operator() (const std::string & str)
> std::string term = thread_prefix;
> notmuch_message_t *message;
> message = notmuch_messages_get (messages);
> - term += notmuch_message_get_thread_id (message);
> + term += _notmuch_message_get_thread_id_only (message);
> terms.insert (term);
> }
> return Xapian::Query (Xapian::Query::OP_OR, terms.begin (), terms.end ());
> --
> 2.17.0
>
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch
More information about the notmuch
mailing list