[PATCH v2 9/9] cli: do not sort addresses on --output=count or --deduplicate=address
authorJani Nikula <jani@nikula.org>
Thu, 3 Sep 2015 19:40:05 +0000 (22:40 +0300)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 21:49:30 +0000 (14:49 -0700)
8e/19233da0c288dc7dba23065ccec7ed726c27eb [new file with mode: 0644]

diff --git a/8e/19233da0c288dc7dba23065ccec7ed726c27eb b/8e/19233da0c288dc7dba23065ccec7ed726c27eb
new file mode 100644 (file)
index 0000000..72549db
--- /dev/null
@@ -0,0 +1,113 @@
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 876C96DE1BA2\r
+ for <notmuch@notmuchmail.org>; Thu,  3 Sep 2015 12:40:46 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.436\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.436 tagged_above=-999 required=5 tests=[AWL=0.284,\r
+  RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id rYNw0f0TZc8B for <notmuch@notmuchmail.org>;\r
+ Thu,  3 Sep 2015 12:40:45 -0700 (PDT)\r
+Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com\r
+ [209.85.212.176])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 5EE916DE1603\r
+ for <notmuch@notmuchmail.org>; Thu,  3 Sep 2015 12:40:31 -0700 (PDT)\r
+Received: by wiclk2 with SMTP id lk2so19117989wic.1\r
+ for <notmuch@notmuchmail.org>; Thu, 03 Sep 2015 12:40:30 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
+ :references:in-reply-to:references;\r
+ bh=GitxrUYi7OnKyIbW4mMXWa9Ll04gxSDAPuoo+JHf0bI=;\r
+ b=jBL0OcEq1O9Q6TZYWHKClp/5T3JGX7YEy6vzRgF496YIt5EJCjk9seRpM+oPoZPHZr\r
+ 7hZUBXrMUtrWAn4U1jzrvuD314yOFWS3LJArTBDbrdpRpcDFjR8+iwwqvzYuzZnMmLZq\r
+ 2XfYqI3E2dt4I5HnsrqV3XwTumhZGLurg+Ty/+n09WjjclWnA8Uym/UQZQoTIO24RqX9\r
+ GWRtsfS4DKUx4XEXwtFxdbyQQ3rvb5AC5rvJ3OfCnimlrlgCdNd5fKa+j3ICp/6TWld0\r
+ sTNhSxyWmQYFi1Qb+sPLkyacn60rvajoDKLCJs0YEOkjkh3L4Oh5aCCI4Ff64bMdhD7z\r
+ KvOw==\r
+X-Gm-Message-State:\r
+ ALoCoQmOyPGEdftEQ6yfja8ae8p+61i/38FieamLmctUMi+lls+DJOt0+657/K2ZqF+SebAL/n6N\r
+X-Received: by 10.194.250.40 with SMTP id yz8mr59364384wjc.37.1441309229962;\r
+ Thu, 03 Sep 2015 12:40:29 -0700 (PDT)\r
+Received: from localhost (mobile-access-bcee4f-131.dhcp.inet.fi.\r
+ [188.238.79.131])\r
+ by smtp.gmail.com with ESMTPSA id i3sm35049480wja.42.2015.09.03.12.40.29\r
+ (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Thu, 03 Sep 2015 12:40:29 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 9/9] cli: do not sort addresses on --output=count or\r
+ --deduplicate=address\r
+Date: Thu,  3 Sep 2015 22:40:05 +0300\r
+Message-Id:\r
+ <01c4430a6715f72498b6f2d2b250523872531785.1441308761.git.jani@nikula.org>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <cover.1441308761.git.jani@nikula.org>\r
+References: <cover.1441308761.git.jani@nikula.org>\r
+In-Reply-To: <cover.1441308761.git.jani@nikula.org>\r
+References: <cover.1441308761.git.jani@nikula.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 03 Sep 2015 19:40:46 -0000\r
+\r
+The order of the results with --output=count and --deduplicate=address\r
+are unspecified as they're based on a hash table traversal. This being\r
+the case, optimize the query by explicitly requesting unsorted\r
+results. Clarify the documentation accordingly.\r
+---\r
+ doc/man1/notmuch-address.rst | 4 +++-\r
+ notmuch-search.c             | 5 +++++\r
+ 2 files changed, 8 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/doc/man1/notmuch-address.rst b/doc/man1/notmuch-address.rst\r
+index b85cc37213e5..cbdb851980a8 100644\r
+--- a/doc/man1/notmuch-address.rst\r
++++ b/doc/man1/notmuch-address.rst\r
+@@ -85,7 +85,9 @@ Supported options for **address** include\r
+         By default, results will be displayed in reverse chronological\r
+         order, (that is, the newest results will be displayed first).\r
\r
+-        This option is not supported with --output=count.\r
++        However, if either --output=count or --deduplicate=address is\r
++        specified, this option is ignored and the order of the results\r
++        is unspecified.\r
\r
+     ``--exclude=(true|false)``\r
+         A message is called "excluded" if it matches at least one tag in\r
+diff --git a/notmuch-search.c b/notmuch-search.c\r
+index deb9e58a747c..b58496bf09d5 100644\r
+--- a/notmuch-search.c\r
++++ b/notmuch-search.c\r
+@@ -885,6 +885,11 @@ notmuch_address_command (notmuch_config_t *config, int argc, char *argv[])\r
+                                           _talloc_free_for_g_hash,\r
+                                           _list_free_for_g_hash);\r
\r
++    /* The order is not guaranteed if a full pass is required, so go\r
++     * for fastest. */\r
++    if (ctx->output & OUTPUT_COUNT || ctx->dedup == DEDUP_ADDRESS)\r
++      notmuch_query_set_sort (ctx->query, NOTMUCH_SORT_UNSORTED);\r
++\r
+     ret = do_search_messages (ctx);\r
\r
+     g_hash_table_unref (ctx->addresses);\r
+-- \r
+2.1.4\r
+\r