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 E3ABB431FC0; Fri, 18 Dec 2009 14:29:22 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org 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 tZopULiqJp5p; Fri, 18 Dec 2009 14:29:22 -0800 (PST) Received: from yoom.home.cworth.org (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 078E6431FAE; Fri, 18 Dec 2009 14:29:22 -0800 (PST) Received: by yoom.home.cworth.org (Postfix, from userid 1000) id B46A3254306; Fri, 18 Dec 2009 14:29:21 -0800 (PST) From: Carl Worth To: James Westby , notmuch@notmuchmail.org In-Reply-To: <1261171263-29687-1-git-send-email-jw+debian@jameswestby.net> References: <87my1grrdi.fsf@jameswestby.net> <1261171263-29687-1-git-send-email-jw+debian@jameswestby.net> Date: Fri, 18 Dec 2009 14:29:21 -0800 Message-ID: <871virzzjy.fsf@yoom.home.cworth.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Subject: Re: [notmuch] [PATCH] Store the size of the file for each message X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.12 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: Fri, 18 Dec 2009 22:29:23 -0000 --=-=-= On Fri, 18 Dec 2009 21:21:03 +0000, James Westby wrote: > Here's the first part, storing the filesize. I'm using > add_value so that we can make it sortable, is that valid > for retrieving it as well? Yes, a value makes sense here and should make the value easy to retrieve. > The only thing I'm not sure about is if it works. Is there > a way to inspect a document to see the values that are > stored? I usually use a little tool I wrote called xapian-dump. It currently exists only in the git history of notmuch. Look at commit: 22691064666c03c5e76bc787395bfe586929f4cc or so. > Doing a search isn't working, so I imagine I made a mistake. Let's see... (just reviewing here, not testing).. > +struct FilesizeValueRangeProcessor : public Xapian::ValueRangeProcessor { > + FilesizeValueRangeProcessor() {} > + > + Xapian::valueno operator()(std::string &begin, std::string &) { > + if (begin.substr(0, 9) != "filesize:") > + return Xapian::BAD_VALUENO; > + begin.erase(0, 9); > + return NOTMUCH_VALUE_FILESIZE; > + } > +}; If the file size is just an integer, then you shouldn't need a custom ValueRangeProcessor. One of the existing processors in Xapian should work fine. Having not ever written a custom processor, I can't say whether the one above is correct or not. -Carl --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iD8DBQFLLAJB6JDdNq8qSWgRAjcxAJ9M6oKCVctLVuZchZ6Sf+wrZrMyPwCaAl7y SOEkN9ksCt39zetus6rMQT0= =c+YE -----END PGP SIGNATURE----- --=-=-=--