From 26ef2c0507d00aefe87c867cc73da48c4c678568 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Tue, 14 Oct 2014 19:32:54 +0300 Subject: [PATCH] [PATCH] lib: make notmuch_query_count_messages exact --- e9/17650dd3ce12210f859e702dbcf3c4f0cbd745 | 130 ++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 e9/17650dd3ce12210f859e702dbcf3c4f0cbd745 diff --git a/e9/17650dd3ce12210f859e702dbcf3c4f0cbd745 b/e9/17650dd3ce12210f859e702dbcf3c4f0cbd745 new file mode 100644 index 000000000..51649db38 --- /dev/null +++ b/e9/17650dd3ce12210f859e702dbcf3c4f0cbd745 @@ -0,0 +1,130 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 2B732431FB6 + for ; Tue, 14 Oct 2014 09:33:08 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id r+QsW40HrO0c for ; + Tue, 14 Oct 2014 09:33:00 -0700 (PDT) +Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com + [209.85.212.171]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 08D56431FAF + for ; Tue, 14 Oct 2014 09:32:59 -0700 (PDT) +Received: by mail-wi0-f171.google.com with SMTP id em10so10638041wid.10 + for ; Tue, 14 Oct 2014 09:32:57 -0700 (PDT) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to + :references; + bh=/3OJ8ww6jEGA/3hb+JUd3YiOPju3T0QHJ875msdZhNg=; + b=b9LceQH4Vu++6mZhxG6vSED6xwepq0PnF73BA2wWmahVMscoi4rzCpcdNzjQ4cDt8u + /4Gp1siEWmK4w3ScjQKZaLXH19kWY6UNrU29rHLpxL9IuyL6592NeOYLpU2rf1LmVAow + SjlP6NjQtmhibOdZ+eujxIbejYQXIBiLce2ISwRH4IMO5prOUDoZJ7I/ZCL935YIggro + 7L2DEbITVOlezeWIMKKdcMqFaN7XX3stBe1Gvu8CX56M7gGDoB79kJreBQGkcRvnWT/9 + AJdJ1FJga0+JJFUSJYSx00RGSh1aF8O21IYaY/Wj5IN39HGyrB1nuIXeSyWPH9xPSCxX + n4Hg== +X-Gm-Message-State: + ALoCoQl5DoojswH99guuWWSfTi06E76djL81PNzs1idcg9sm7dY7UjjK/WRPWKXHWh42Iu0N7o5g +X-Received: by 10.194.239.164 with SMTP id vt4mr3383229wjc.131.1413304376948; + Tue, 14 Oct 2014 09:32:56 -0700 (PDT) +Received: from localhost (mobile-internet-5d6ad2-138.dhcp.inet.fi. + [93.106.210.138]) + by mx.google.com with ESMTPSA id ga7sm16287360wic.5.2014.10.14.09.32.55 + for + (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Tue, 14 Oct 2014 09:32:56 -0700 (PDT) +From: Jani Nikula +To: Sergei Shilovsky , + notmuch@notmuchmail.org +Subject: [PATCH] lib: make notmuch_query_count_messages exact +Date: Tue, 14 Oct 2014 19:32:54 +0300 +Message-Id: <1413304374-17997-1-git-send-email-jani@nikula.org> +X-Mailer: git-send-email 2.1.1 +In-Reply-To: <1413298112-19912-2-git-send-email-sshilovsky@gmail.com> +References: <1413298112-19912-2-git-send-email-sshilovsky@gmail.com> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Tue, 14 Oct 2014 16:33:08 -0000 + +Our tests have expected this to be exact all along, but maybe +inaccuracies only show up with big databases. +--- + devel/TODO | 5 ----- + lib/notmuch.h | 6 +++--- + lib/query.cc | 7 ++++++- + 3 files changed, 9 insertions(+), 9 deletions(-) + +diff --git a/devel/TODO b/devel/TODO +index 1cf4089f1d93..116194d82ad1 100644 +--- a/devel/TODO ++++ b/devel/TODO +@@ -188,11 +188,6 @@ into the shared-library interface. + Audit all libnotmuch entry points to ensure that all Xapian calls are + wrapped in a try/catch block. + +-Fix the "count" functionality to be exact as Olly explained in IRC: +- +- ojwb> cworth: if you set the check_at_least parameter to the +- database size, get_matches_estimated() will be exact +- + Fix the threading of a message that has a References: header but no + In-Reply-To: header (see id:"87lixxnxpb.fsf@yoom.home.cworth.org"). + +diff --git a/lib/notmuch.h b/lib/notmuch.h +index dae041640fdb..6091082617e7 100644 +--- a/lib/notmuch.h ++++ b/lib/notmuch.h +@@ -893,10 +893,10 @@ void + notmuch_threads_destroy (notmuch_threads_t *threads); + + /** +- * Return an estimate of the number of messages matching a search. ++ * Return the number of messages matching a search. + * +- * This function performs a search and returns Xapian's best +- * guess as to number of matching messages. ++ * This function performs a search and returns the number of matching ++ * messages. + * + * If a Xapian exception occurs, this function may return 0 (after + * printing a message). +diff --git a/lib/query.cc b/lib/query.cc +index 60ff8bd9a39e..ce26e3f3e4ed 100644 +--- a/lib/query.cc ++++ b/lib/query.cc +@@ -557,7 +557,12 @@ notmuch_query_count_messages (notmuch_query_t *query) + + enquire.set_query (final_query); + +- mset = enquire.get_mset (0, notmuch->xapian_db->get_doccount ()); ++ /* ++ * Set the checkatleast parameter to the number of documents ++ * in the database to make get_matches_estimated() exact. ++ */ ++ mset = enquire.get_mset (0, notmuch->xapian_db->get_doccount (), ++ notmuch->xapian_db->get_doccount ()); + + count = mset.get_matches_estimated(); + +-- +2.1.1 + -- 2.26.2