[notmuch] [PATCH] Store the size of the file for each message

Carl Worth cworth at cworth.org
Fri Dec 18 14:29:21 PST 2009

On Fri, 18 Dec 2009 21:21:03 +0000, James Westby <jw+debian at jameswestby.net> 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

>   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:


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.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20091218/8d9da30f/attachment.pgp>

More information about the notmuch mailing list