unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Austin Clements <amdragon@MIT.EDU>
To: Sebastian Spaeth <Sebastian@sspaeth.de>
Cc: notmuch@notmuchmail.org
Subject: Re: [python] segfaults at Message.get_date
Date: Mon, 20 Jun 2011 12:53:29 -0400	[thread overview]
Message-ID: <20110620165329.GN16025@mit.edu> (raw)
In-Reply-To: <878vsxvu3x.fsf@SSpaeth.de>

Quoth Sebastian Spaeth on Jun 20 at  9:29 am:
> On Sun, 19 Jun 2011 19:51:11 -0400, Austin Clements <amdragon@mit.edu> wrote:
> > A double will precisely represent integers up to 2^53, so this
> > conversion shouldn't be a problem until the year 285422109 or so.
> 
> But given that it works, is it actually necessary, that xapian
> apparently pulls an int from the database, returns a std::string to
> libnotmuch, which calls a helper function to unserialize it to a double
> and casts it to time_t before handing it to the user how probably uses
> it as a long?
> 
> Can't we easily put in longs and get longs back?

Xapian only knows about strings, so there has to be serialization
somewhere and the serialized form has to have the same collation order
as the numerical order of the original numbers.  You could do this by
storing the bytes of the long in big-endian form, but that's basically
what sortable_serialise does: roughly, the first byte stores the
number of bits needed to represent the number, followed by enough
bytes to hold those bits in big-endian.  Since POSIX permits a wide
range of types to implement time_t, sortable_serialise also has the
major advantage that it can handle any of them.  So, taking
portability and time_t as assumptions, there are no unnecessary
conversion steps here (and, really, it's just string->double->time_t
on Linux and just string->time_t on a platform that uses floating
point time_t's).

Alternatively, notmuch could switch to using long instead of time_t
for dates, but that seems like a lot of effort for little gain and
results in portability friction whenever notmuch wants to use the
standard C time API's.

      reply	other threads:[~2011-06-20 16:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-16 21:54 [python] segfaults at Message.get_date Patrick Totzke
2011-06-17  6:34 ` Sebastian Spaeth
2011-06-17 16:10   ` Patrick Totzke
2011-06-18 10:30     ` Sebastian Spaeth
2011-06-19  9:45       ` Dmitry Kurochkin
2011-06-19 14:53         ` Sebastian Spaeth
2011-06-19 23:51         ` Austin Clements
2011-06-20  7:29           ` Sebastian Spaeth
2011-06-20 16:53             ` Austin Clements [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110620165329.GN16025@mit.edu \
    --to=amdragon@mit.edu \
    --cc=Sebastian@sspaeth.de \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).