1 Return-Path: <mi@kismala.com>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 1AD7C431FD0
\r
6 for <notmuch@notmuchmail.org>; Mon, 16 May 2011 00:33:39 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id XPi-WwaB0Jpg for <notmuch@notmuchmail.org>;
\r
16 Mon, 16 May 2011 00:33:36 -0700 (PDT)
\r
17 Received: from imarko.xen.prgmr.com (imarko.xen.prgmr.com [72.13.95.244])
\r
18 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 16857431FB6
\r
21 for <notmuch@notmuchmail.org>; Mon, 16 May 2011 00:33:36 -0700 (PDT)
\r
22 Received: from localhost ([127.0.0.1] helo=zsu.kismala.com)
\r
23 by imarko.xen.prgmr.com with esmtp (Exim 4.75)
\r
24 (envelope-from <mi@kismala.com>)
\r
25 id 1QLsIz-0004PY-Nr; Mon, 16 May 2011 00:33:29 -0700
\r
26 From: Istvan Marko <notmuch@kismala.com>
\r
27 To: Austin Clements <amdragon@mit.edu>
\r
28 Subject: Re: storing From and Subject in xapian
\r
29 References: <m3sjsv2kw2.fsf@zsu.kismala.com>
\r
30 <BANLkTinVzQL2qRDbt4WhcPdL1D7D3N=aQg@mail.gmail.com>
\r
31 Date: Mon, 16 May 2011 00:33:29 -0700
\r
32 In-Reply-To: <BANLkTinVzQL2qRDbt4WhcPdL1D7D3N=aQg@mail.gmail.com> (Austin
\r
33 Clements's message of "Sat, 14 May 2011 21:37:25 -0400")
\r
34 Message-ID: <m3pqnj2j7a.fsf@zsu.kismala.com>
\r
35 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
\r
37 Content-Type: multipart/mixed; boundary="=-=-="
\r
38 Cc: notmuch@notmuchmail.org
\r
39 X-BeenThere: notmuch@notmuchmail.org
\r
40 X-Mailman-Version: 2.1.13
\r
42 List-Id: "Use and development of the notmuch mail system."
\r
43 <notmuch.notmuchmail.org>
\r
44 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
45 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
46 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
47 List-Post: <mailto:notmuch@notmuchmail.org>
\r
48 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
49 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
50 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
51 X-List-Received-Date: Mon, 16 May 2011 07:33:39 -0000
\r
54 Content-Type: text/plain
\r
56 Austin Clements <amdragon@mit.edu> writes:
\r
58 > I wonder if a better approach would be to use
\r
59 > notmuch_message_get_header everywhere, rather than introducing
\r
60 > _notmuch_message_get_header_value, and have it simply recognize
\r
61 > headers that can be retrieved directly from the database. Then
\r
62 > library callers could take advantage of this optimization and it could
\r
63 > be trivially extended to other headers in the future.
\r
65 That's a good idea, updated patch below. This version also has fallback
\r
66 handling for database entries that don't have the new header value
\r
69 I couldn't find a way to have the Xapian API differentiate between
\r
70 undefined and blank value fields so empty subject lines are encoded as a
\r
73 Also, the address completion discussion made me think that maybe a value
\r
74 field containing To/Cc/Bcc could be added too to avoid message file
\r
75 parsing for the address search case but I haven't tried implementing
\r
80 Content-Type: text/x-patch
\r
81 Content-Disposition: inline; filename=notmuch-value3.patch
\r
83 diff --git a/lib/database.cc b/lib/database.cc
\r
84 index 7f8a830..d30c1b0 100644
\r
85 --- a/lib/database.cc
\r
86 +++ b/lib/database.cc
\r
87 @@ -1698,7 +1698,7 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
\r
90 date = notmuch_message_file_get_header (message_file, "date");
\r
91 - _notmuch_message_set_date (message, date);
\r
92 + _notmuch_message_set_header_values (message, date, from, subject);
\r
94 _notmuch_message_index_file (message, filename);
\r
96 diff --git a/lib/message.cc b/lib/message.cc
\r
97 index e8cf8d9..2a76dc1 100644
\r
98 --- a/lib/message.cc
\r
99 +++ b/lib/message.cc
\r
100 @@ -414,6 +414,27 @@ _notmuch_message_ensure_message_file (notmuch_message_t *message)
\r
102 notmuch_message_get_header (notmuch_message_t *message, const char *header)
\r
104 + std::string value;
\r
106 + // fetch header from the appropriate xapian value field if available
\r
107 + if (strcmp(header,"from") == 0)
\r
108 + value=message->doc.get_value(NOTMUCH_VALUE_FROM);
\r
109 + else if (strcmp(header,"subject") == 0)
\r
110 + value=message->doc.get_value (NOTMUCH_VALUE_SUBJECT);
\r
111 + else if (strcmp(header,"message-id") == 0)
\r
112 + value=message->doc.get_value (NOTMUCH_VALUE_MESSAGE_ID);
\r
114 + if (!value.empty()) {
\r
115 + // empty headers are encoded as a single space because xapian
\r
116 + // doesn't seem to differentiat between unset and empty value
\r
118 + if (value == " ")
\r
121 + return talloc_strdup (message, value.c_str ());
\r
124 + // otherwise fall back to parsing the file
\r
125 _notmuch_message_ensure_message_file (message);
\r
126 if (message->message_file == NULL)
\r
128 @@ -771,8 +792,10 @@ notmuch_message_set_author (notmuch_message_t *message,
\r
132 -_notmuch_message_set_date (notmuch_message_t *message,
\r
133 - const char *date)
\r
134 +_notmuch_message_set_header_values (notmuch_message_t *message,
\r
135 + const char *date,
\r
136 + const char *from,
\r
137 + const char *subject)
\r
141 @@ -785,6 +808,9 @@ _notmuch_message_set_date (notmuch_message_t *message,
\r
143 message->doc.add_value (NOTMUCH_VALUE_TIMESTAMP,
\r
144 Xapian::sortable_serialise (time_value));
\r
145 + message->doc.add_value (NOTMUCH_VALUE_FROM, from);
\r
146 + // empty subject is encoded as a single space
\r
147 + message->doc.add_value (NOTMUCH_VALUE_SUBJECT, (*subject==0) ? " " : subject);
\r
150 /* Synchronize changes made to message->doc out into the database. */
\r
151 diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
\r
152 index 0856751..ed3d32d 100644
\r
153 --- a/lib/notmuch-private.h
\r
154 +++ b/lib/notmuch-private.h
\r
155 @@ -105,7 +105,9 @@ _internal_error (const char *format, ...) PRINTF_ATTRIBUTE (1, 2);
\r
158 NOTMUCH_VALUE_TIMESTAMP = 0,
\r
159 - NOTMUCH_VALUE_MESSAGE_ID
\r
160 + NOTMUCH_VALUE_MESSAGE_ID,
\r
161 + NOTMUCH_VALUE_FROM,
\r
162 + NOTMUCH_VALUE_SUBJECT
\r
165 /* Xapian (with flint backend) complains if we provide a term longer
\r
166 @@ -281,9 +283,10 @@ void
\r
167 _notmuch_message_ensure_thread_id (notmuch_message_t *message);
\r
170 -_notmuch_message_set_date (notmuch_message_t *message,
\r
171 - const char *date);
\r
173 +_notmuch_message_set_header_values (notmuch_message_t *message,
\r
174 + const char *date,
\r
175 + const char *from,
\r
176 + const char *subject);
\r
178 _notmuch_message_sync (notmuch_message_t *message);
\r
182 Content-Type: text/plain
\r