unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Austin Clements <amdragon@MIT.EDU>
To: Mark Walters <markwalters1009@gmail.com>
Cc: notmuch@notmuchmail.org
Subject: Re: [RFC PATCH 2/4] Add NOTMUCH_MESSAGE_FLAG_EXCLUDED flag
Date: Mon, 23 Jan 2012 21:45:21 -0500	[thread overview]
Message-ID: <20120124024521.GY16740@mit.edu> (raw)
In-Reply-To: <1327367923-18228-2-git-send-email-markwalters1009@gmail.com>

The overall structure of this series looks great.  There's obviously a
lot of clean up to do, but I'll reply with a few high-level comments.

Quoth Mark Walters on Jan 24 at  1:18 am:
> Form excluded doc_ids set and use that to exclude messages.
> Should be no functional change.
> 
> ---
>  lib/notmuch-private.h |    1 +
>  lib/query.cc          |   28 ++++++++++++++++++++++++++--
>  2 files changed, 27 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
> index 7bf153e..e791bb0 100644
> --- a/lib/notmuch-private.h
> +++ b/lib/notmuch-private.h
> @@ -401,6 +401,7 @@ typedef struct _notmuch_message_list {
>   */
>  struct visible _notmuch_messages {
>      notmuch_bool_t is_of_list_type;
> +    notmuch_doc_id_set_t *excluded_doc_ids;
>      notmuch_message_node_t *iterator;
>  };
>  
> diff --git a/lib/query.cc b/lib/query.cc
> index c25b301..92fa834 100644
> --- a/lib/query.cc
> +++ b/lib/query.cc
> @@ -57,6 +57,11 @@ struct visible _notmuch_threads {
>      notmuch_doc_id_set_t match_set;
>  };
>  
> +static notmuch_bool_t
> +_notmuch_doc_id_set_init (void *ctx,
> +			  notmuch_doc_id_set_t *doc_ids,
> +			  GArray *arr);
> +
>  notmuch_query_t *
>  notmuch_query_create (notmuch_database_t *notmuch,
>  		      const char *query_string)
> @@ -173,6 +178,7 @@ notmuch_query_search_messages (notmuch_query_t *query)
>  						   "mail"));
>  	Xapian::Query string_query, final_query, exclude_query;
>  	Xapian::MSet mset;
> +	Xapian::MSetIterator iterator;
>  	unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN |
>  			      Xapian::QueryParser::FLAG_PHRASE |
>  			      Xapian::QueryParser::FLAG_LOVEHATE |
> @@ -193,8 +199,21 @@ notmuch_query_search_messages (notmuch_query_t *query)
>  
>  	exclude_query = _notmuch_exclude_tags (query, final_query);
>  
> -	final_query = Xapian::Query (Xapian::Query::OP_AND_NOT,
> -					 final_query, exclude_query);
> +	enquire.set_weighting_scheme (Xapian::BoolWeight());
> +	enquire.set_query (exclude_query);
> +
> +	mset = enquire.get_mset (0, notmuch->xapian_db->get_doccount ());
> +
> +	GArray *excluded_doc_ids = g_array_new (FALSE, FALSE, sizeof (unsigned int));
> +
> +	for (iterator = mset.begin (); iterator != mset.end (); iterator++)
> +	{
> +	    unsigned int doc_id = *iterator;
> +	    g_array_append_val (excluded_doc_ids, doc_id);
> +	}
> +	messages->base.excluded_doc_ids = talloc (query, _notmuch_doc_id_set);
> +	_notmuch_doc_id_set_init (query, messages->base.excluded_doc_ids,
> +				  excluded_doc_ids);

This might be inefficient for message-only queries, since it will
fetch *all* excluded docids.  This highlights a basic difference
between message and thread search: thread search can return messages
that don't match the original query and hence needs to know all
potentially excluded messages, while message search can only return
messages that match the original query.

It's entirely possible this doesn't matter because Xapian probably
still needs to fetch the full posting lists of the excluded terms, but
it would be worth doing a quick/hacky benchmark to verify this, with
enough excluded messages to make the cost non-trivial.

If it does matter, you could pass in a flag indicating if the exclude
query should be limited by the original query or not.  Or you could do
the limited exclude query in notmuch_query_search_messages and a
separate open-ended exclude query in notmuch_query_search_threads.

>  
>  	enquire.set_weighting_scheme (Xapian::BoolWeight());
>  
> @@ -294,6 +313,11 @@ _notmuch_mset_messages_move_to_next (notmuch_messages_t *messages)
>      mset_messages = (notmuch_mset_messages_t *) messages;
>  
>      mset_messages->iterator++;
> +
> +    while ((mset_messages->iterator != mset_messages->iterator_end) &&
> +	   (_notmuch_doc_id_set_contains (messages->excluded_doc_ids,
> +					  *mset_messages->iterator)))
> +	mset_messages->iterator++;

This seemed a little weird, since you remove it in the next patch.  Is
this just to keep the tests happy?  (If so, it would be worth
mentioning in the commit message; other reviewers will definitely have
the same question.)

>  }
>  
>  static notmuch_bool_t

  reply	other threads:[~2012-01-24  2:45 UTC|newest]

Thread overview: 176+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-07 22:28 another attempt to add delete functionality in emacs Jameson Graef Rollins
2012-01-07 22:28 ` [PATCH 1/4] emacs: new customization variable to exclude "deleted" messages from search Jameson Graef Rollins
2012-01-07 22:28   ` [PATCH 2/4] emacs: repurpose notmuch-show-archive-thread-internal function for general thread tagging Jameson Graef Rollins
2012-01-07 22:28     ` [PATCH 3/4] emacs: add ability to "delete" messages and threads Jameson Graef Rollins
2012-01-07 22:28       ` [PATCH 4/4] emacs: modify help message for notmuch-search-line-faces to reflect preferred "deleted" tag name Jameson Graef Rollins
2012-01-08  1:26       ` change to default archive/delete key bindings Jameson Graef Rollins
2012-01-08  1:26         ` [PATCH 1/4] emacs: add show-mode functions to archive/delete only current message Jameson Graef Rollins
2012-01-08  1:26           ` [PATCH 2/4] emacs: add option to notmuch-show-next-open-message to pop out to parent buffer if at end Jameson Graef Rollins
2012-01-08  1:26             ` [PATCH 3/4] emacs: modify the default show-mode key bindings for archiving/deleting Jameson Graef Rollins
2012-01-08  1:26               ` [PATCH 4/4] emacs: use pop-at-end functionality in archive/delete-message functions Jameson Graef Rollins
2012-01-08 18:56                 ` [PATCH 4/4 v2] " Jameson Graef Rollins
2012-01-08 19:28                   ` [PATCH 4/4 v3] " Jameson Graef Rollins
2012-01-09  1:12             ` [PATCH 2/4] emacs: add option to notmuch-show-next-open-message to pop out to parent buffer if at end Aaron Ecay
2012-01-08 19:09           ` [PATCH 1/4 v2] emacs: add show-mode functions to archive/delete only current message Jameson Graef Rollins
2012-01-10  7:43             ` David Edmondson
2012-01-10  7:48         ` change to default archive/delete key bindings David Edmondson
2012-01-09  1:08     ` [PATCH 2/4] emacs: repurpose notmuch-show-archive-thread-internal function for general thread tagging Aaron Ecay
2012-01-09  2:49       ` Jameson Graef Rollins
2012-01-09  5:02         ` Aaron Ecay
2012-01-11  2:56           ` Jameson Graef Rollins
2012-01-11  5:53             ` Aaron Ecay
2012-01-11  7:07               ` Jameson Graef Rollins
2012-01-09  1:14   ` [PATCH 1/4] emacs: new customization variable to exclude "deleted" messages from search Aaron Ecay
2012-01-09  1:49     ` Austin Clements
2012-01-09  2:34       ` Jameson Graef Rollins
2012-01-09  2:46         ` Austin Clements
2012-01-09  4:31       ` Austin Clements
2012-01-11  5:02         ` [PATCH 0/3] Automatic tag-based exclusion Austin Clements
2012-01-11  5:02           ` [PATCH 1/3] count: Convert to new-style argument parsing Austin Clements
2012-01-11  8:17             ` Jani Nikula
2012-01-11 18:26               ` Austin Clements
2012-01-11 18:27               ` Jani Nikula
2012-01-11  5:02           ` [PATCH 2/3] lib: Add support for automatically excluding tags from queries Austin Clements
2012-01-11 10:11             ` Jani Nikula
2012-01-11 18:48               ` Austin Clements
2012-01-11  5:02           ` [PATCH 3/3] search: Support automatic tag exclusions Austin Clements
2012-01-11 19:27             ` Jani Nikula
2012-01-11  7:05           ` [PATCH 0/3] Automatic tag-based exclusion Jameson Graef Rollins
2012-01-13 23:07           ` [PATCH v2 0/3] Austin Clements
2012-01-13 23:07             ` [PATCH v2 1/3] count: Convert to new-style argument parsing Austin Clements
2012-01-14  1:49               ` David Bremner
2012-01-13 23:07             ` [PATCH v2 2/3] lib: Add support for automatically excluding tags from queries Austin Clements
2012-01-14 23:38               ` Jameson Graef Rollins
2012-01-15  0:05                 ` Austin Clements
2012-01-13 23:07             ` [PATCH v2 3/3] search: Support automatic tag exclusions Austin Clements
2012-01-14 23:40               ` Jameson Graef Rollins
2012-01-15  0:14                 ` Austin Clements
2012-01-16  9:12                 ` David Edmondson
2012-01-16 19:28                   ` Austin Clements
2012-01-16 22:18                     ` Jeremy Nickurak
2012-01-16 22:25                       ` Jameson Graef Rollins
     [not found]                     ` <CA+eQo_3xxuhgUUXWXWyVD1LFhvhkw2psbA3ZnFnZk=BjjHXy8w@mail.gmail.com>
2012-01-17  9:08                       ` David Edmondson
2012-01-17 20:32                         ` Austin Clements
2012-01-18  8:38                           ` David Edmondson
2012-01-18  8:52                             ` Jameson Graef Rollins
2012-01-18  9:52                               ` David Edmondson
2012-01-18 18:51                                 ` Jameson Graef Rollins
2012-01-16 19:34                   ` Jameson Graef Rollins
2012-01-14 23:38             ` [PATCH v2 0/3] Jameson Graef Rollins
2012-01-15  0:17             ` [PATCH v3 0/2] Automatic tag-based exclusion Austin Clements
2012-01-15  0:17               ` [PATCH v3 1/2] lib: Add support for automatically excluding tags from queries Austin Clements
2012-01-15  0:17               ` [PATCH v3 2/2] search: Support automatic tag exclusions Austin Clements
2012-01-19 19:19                 ` Pieter Praet
2012-01-19 19:19                   ` [PATCH 1/4] search: rename auto_exclude_tags to {search, }exclude_tags Pieter Praet
2012-01-19 19:41                     ` [PATCH 1/4] search: rename auto_exclude_tags to {search,}exclude_tags Austin Clements
2012-01-19 21:14                       ` [PATCH 1/4] search: rename auto_exclude_tags to {search, }exclude_tags Pieter Praet
2012-01-19 19:19                   ` [PATCH 2/4] test: only exclude "deleted" messages from search if explicitly configured Pieter Praet
2012-01-19 19:19                   ` [PATCH 3/4] config: only set search.exclude_tags to "deleted; spam; " during setup Pieter Praet
2012-01-22 22:14                     ` Xavier Maillard
2012-01-22 22:53                       ` Jameson Graef Rollins
2012-01-23  5:05                         ` Pieter Praet
2012-01-23  5:34                           ` Jameson Graef Rollins
2012-01-23  7:35                             ` Pieter Praet
2012-01-23  7:22                           ` Jani Nikula
2012-01-23  7:38                             ` Jameson Graef Rollins
2012-01-23  8:24                               ` Jani Nikula
2012-01-23  8:45                                 ` Jameson Graef Rollins
2012-01-25  0:43                                 ` Pieter Praet
2012-01-23  8:03                             ` Pieter Praet
2012-01-23  8:31                               ` Jani Nikula
2012-01-25  0:42                                 ` Pieter Praet
2012-01-23  4:16                       ` Pieter Praet
2012-01-19 19:19                   ` [PATCH 4/4] setup: prompt user for search.exclude_tags value Pieter Praet
2012-01-19 19:44                     ` Austin Clements
2012-01-19 21:16                       ` Pieter Praet
2012-01-20  4:19                         ` Austin Clements
2012-01-22  6:55                           ` Pieter Praet
2012-01-22 17:08                             ` Austin Clements
2012-01-23  4:17                               ` Pieter Praet
2012-01-23  4:22                                 ` [PATCH v2 1/6] search: rename auto_exclude_tags to {search, }exclude_tags Pieter Praet
2012-01-23 23:28                                   ` David Bremner
2012-01-23  4:22                                 ` [PATCH v2 2/6] test: only exclude "deleted" messages from search if explicitly configured Pieter Praet
2012-01-23  4:22                                 ` [PATCH v2 3/6] config: only exclude messages if 'search.exclude_tags' is explicitly set Pieter Praet
2012-01-23  4:22                                 ` [PATCH v2 4/6] setup: move tag printing and parsing into separate functions Pieter Praet
2012-01-23  5:07                                   ` Austin Clements
2012-01-23  5:50                                     ` [PATCH v3 4/6] setup: Create functions for tag list printing and parsing Pieter Praet
2012-01-23  4:22                                 ` [PATCH v2 5/6] setup: prompt user for search.exclude_tags value Pieter Praet
2012-01-23  4:34                                   ` Austin Clements
2012-01-23  5:40                                     ` [PATCH v3 " Pieter Praet
2012-01-23  4:22                                 ` [PATCH v2 6/6] NEWS: update "Tag exclusion" section Pieter Praet
2012-01-23  4:41                                   ` Austin Clements
2012-01-23  5:41                                     ` [PATCH v3 " Pieter Praet
2012-01-23 14:49                                       ` Austin Clements
2012-01-19 19:36                   ` [PATCH v3 2/2] search: Support automatic tag exclusions Austin Clements
2012-01-19 20:06                     ` markwalters1009
2012-01-19 20:16                       ` Aaron Ecay
2012-01-19 20:23                         ` Mark Walters
2012-01-19 20:28                           ` Austin Clements
2012-01-19 22:01                             ` Mark Walters
2012-01-19 22:03                               ` [PATCH] Automatically exclude tags in notmuch-show Mark Walters
2012-01-19 22:59                                 ` Austin Clements
2012-01-19 23:54                                   ` Pieter Praet
2012-01-20  0:10                                   ` Mark Walters
2012-01-20 17:18                                     ` Austin Clements
2012-01-22  0:38                                       ` Mark Walters
2012-01-22 17:31                                         ` Austin Clements
2012-01-22 18:16                                       ` Austin Clements
2012-01-22 18:47                                         ` Mark Walters
2012-01-23  1:13                                         ` Mark Walters
2012-01-23  1:52                                           ` Austin Clements
2012-01-24  1:05                                             ` Mark Walters
2012-01-24  1:16                                               ` Austin Clements
2012-01-24  1:18                                                 ` [RFC PATCH 1/4] Add NOTMUCH_MESSAGE_FLAG_EXCLUDED flag Mark Walters
2012-01-24  1:18                                                 ` [RFC PATCH 2/4] " Mark Walters
2012-01-24  2:45                                                   ` Austin Clements [this message]
2012-01-24 11:20                                                     ` Mark Walters
2012-01-28 10:51                                                     ` Mark Walters
2012-01-28 18:33                                                       ` Austin Clements
2012-01-28 23:57                                                         ` Mark Walters
2012-01-29  0:04                                                           ` [PATCH 1/4] Add exclude flag Mark Walters
2012-01-29  0:04                                                           ` [PATCH 2/4] " Mark Walters
2012-01-29  0:04                                                           ` [PATCH 3/4] " Mark Walters
2012-01-29  0:04                                                           ` [PATCH 4/4] " Mark Walters
2012-01-29 10:37                                                           ` [RFC PATCH 2/4] Add NOTMUCH_MESSAGE_FLAG_EXCLUDED flag Mark Walters
2012-01-29 18:36                                                             ` Mark Walters
2012-01-29 18:39                                                               ` [PATCH 1/7] cli: add --do-not-exclude option to count and search Mark Walters
2012-01-31  4:17                                                                 ` Austin Clements
2012-01-31 11:40                                                                   ` Mark Walters
2012-01-31 16:18                                                                     ` Austin Clements
2012-01-31 16:31                                                                     ` Jameson Graef Rollins
2012-02-11 18:44                                                                 ` Jameson Graef Rollins
2012-02-11 18:50                                                                   ` Austin Clements
2012-02-11 19:00                                                                     ` Jameson Graef Rollins
2012-01-29 18:39                                                               ` [PATCH 2/7] lib: Rearrange the exclude code in query.cc Mark Walters
2012-01-29 18:39                                                               ` [PATCH 3/7] lib: Make notmuch_query_search_messages set the exclude flag Mark Walters
2012-01-31  4:43                                                                 ` Austin Clements
2012-01-31 11:45                                                                   ` Mark Walters
2012-01-31 16:25                                                                     ` Austin Clements
2012-02-01 18:00                                                                       ` Mark Walters
2012-01-29 18:39                                                               ` [PATCH 4/7] lib: Add the exclude flag to notmuch_query_search_threads Mark Walters
2012-01-31  4:50                                                                 ` Austin Clements
2012-01-31 11:47                                                                   ` Mark Walters
2012-01-31  5:07                                                                 ` Austin Clements
2012-01-29 18:39                                                               ` [PATCH 5/7] cli: Make notmuch-show respect excludes Mark Walters
2012-01-31  4:56                                                                 ` Austin Clements
2012-01-31 12:30                                                                   ` Mark Walters
2012-01-29 18:39                                                               ` [PATCH 6/7] cli: omit excluded messages in results where appropriate Mark Walters
2012-01-29 18:39                                                               ` [PATCH 7/7] emacs: show: recognize the exclude flag Mark Walters
2012-01-31  5:08                                                               ` [RFC PATCH 2/4] Add NOTMUCH_MESSAGE_FLAG_EXCLUDED flag Austin Clements
2012-01-24  1:18                                                 ` [RFC PATCH 3/4] " Mark Walters
2012-01-24  2:53                                                   ` Austin Clements
2012-01-24  1:18                                                 ` [PATCH 4/4] " Mark Walters
2012-01-19 22:44                               ` [PATCH v3 2/2] search: Support automatic tag exclusions Pieter Praet
2012-01-19 21:21                     ` Pieter Praet
2012-01-22 22:09                   ` Xavier Maillard
2012-01-23  4:15                     ` Pieter Praet
2012-01-16 19:35               ` [PATCH v3 0/2] Automatic tag-based exclusion Jameson Graef Rollins
2012-01-17  1:08               ` David Bremner
2012-01-18 20:58               ` [PATCH] News for tag exclusion Austin Clements
2012-01-10  7:47 ` another attempt to add delete functionality in emacs David Edmondson
2012-01-10 20:01   ` David Bremner
2012-01-11  3:12     ` Jameson Graef Rollins
2012-01-11  5:16       ` Jani Nikula
2012-01-11  5:38         ` Austin Clements
2012-01-11  8:26       ` David Edmondson
2012-01-11  2:56   ` Jameson Graef Rollins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120124024521.GY16740@mit.edu \
    --to=amdragon@mit.edu \
    --cc=markwalters1009@gmail.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).