From aa1bfb45a53cda888fdee8ec60ccf24e3826bbce Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Tue, 28 Oct 2014 19:36:11 +0200 Subject: [PATCH] Re: [PATCH] lib: make notmuch_query_count_messages exact --- 52/fecb12177ab1ee97ab0667332ede449700b5ba | 147 ++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 52/fecb12177ab1ee97ab0667332ede449700b5ba diff --git a/52/fecb12177ab1ee97ab0667332ede449700b5ba b/52/fecb12177ab1ee97ab0667332ede449700b5ba new file mode 100644 index 000000000..2a05ac3c0 --- /dev/null +++ b/52/fecb12177ab1ee97ab0667332ede449700b5ba @@ -0,0 +1,147 @@ +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 1BB04431FB6 + for ; Tue, 28 Oct 2014 10:36:25 -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 az0uozS+Ssur for ; + Tue, 28 Oct 2014 10:36:17 -0700 (PDT) +Received: from mail-wg0-f44.google.com (mail-wg0-f44.google.com + [74.125.82.44]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + 422CE431FBC for ; Tue, 28 Oct 2014 10:36:17 -0700 + (PDT) +Received: by mail-wg0-f44.google.com with SMTP id y10so19954wgg.31 + for ; Tue, 28 Oct 2014 10:36:16 -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:subject:in-reply-to:references + :user-agent:date:message-id:mime-version:content-type; + bh=qfq7qQvWejqq1t3l6g5khj8MfYtpFTuXfTF349GV+5o=; + b=Q5Qghj3h7laJlto4elLkFSQfg8HgT/b3tgcEJJ3P5d+kJ5FYk2cUXZ2Xi8KhLMsoxC + JOu5DQ9BUC7LpdH5TzWEs/Vu+R6P8fJCjn89J/Z2rOrOcHuZwhFz9H2m4aqOtWuupDMR + TKixcapa1PYgvIkqdTQPslfMgya2m2FJ4Lg3jJ5GEXU2Mfx7i5v1AyhkKtazM2rnLEbB + kgB7KNzGaUsVC1fX27QxggV5aJAY3BlylxmIasMUNwHIRYiYcAZRax6/EXKU//n7eNmM + t/scMCaj/OSjOmfV2yUBfBHIjI8qsRc/gahJqihcdLWBBa3TV25i6zb2U0MZFl682odk + kjVQ== +X-Gm-Message-State: + ALoCoQnL/OZLrw1EZRWaxclhJjboUSdrdWytpLJb/Hfq0kG7k2rxq9pNBCKKk+amaOfygflm2QOK +X-Received: by 10.194.185.167 with SMTP id fd7mr6306758wjc.108.1414517774439; + Tue, 28 Oct 2014 10:36:14 -0700 (PDT) +Received: from localhost (dsl-hkibrasgw2-58c36d-48.dhcp.inet.fi. + [88.195.109.48]) + by mx.google.com with ESMTPSA id eu8sm11205161wic.1.2014.10.28.10.36.13 + for + (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Tue, 28 Oct 2014 10:36:13 -0700 (PDT) +From: Jani Nikula +To: Sergei Shilovsky , notmuch@notmuchmail.org +Subject: Re: [PATCH] lib: make notmuch_query_count_messages exact +In-Reply-To: <1413304374-17997-1-git-send-email-jani@nikula.org> +References: <1413298112-19912-2-git-send-email-sshilovsky@gmail.com> + <1413304374-17997-1-git-send-email-jani@nikula.org> +User-Agent: Notmuch/0.18.2+148~g0318cd3 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-pc-linux-gnu) +Date: Tue, 28 Oct 2014 19:36:11 +0200 +Message-ID: <87lho0nlkk.fsf@nikula.org> +MIME-Version: 1.0 +Content-Type: text/plain +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, 28 Oct 2014 17:36:25 -0000 + +On Tue, 14 Oct 2014, Jani Nikula wrote: +> Our tests have expected this to be exact all along, but maybe +> inaccuracies only show up with big databases. + +>From my IRC logs on Thu Oct 16 2014 + +j4ni olly: does this do what it claims? + http://mid.gmane.org/1413304374-17997-1-git-send-email-jani@nikula.org +olly j4ni: not really +olly if you don't set check at least it defaults to the number of + requested matches +olly so the code part is effectively a no-op +olly but the reported number will be exact already so the comment + changes are right +olly i guess you could argue there's some merit in passing it explicitly + in case someone decreases the request number of results + +> --- +> 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