]> git.notmuchmail.org Git - notmuch/commitdiff
Shuffle the value numbers around in the database.
authorCarl Worth <cworth@cworth.org>
Sun, 25 Oct 2009 06:05:08 +0000 (23:05 -0700)
committerCarl Worth <cworth@cworth.org>
Sun, 25 Oct 2009 06:05:08 +0000 (23:05 -0700)
First, it's nice that for now we don't have any users yet, so we
can make incompatible changes to the database layout like this
without causing trouble. ;-)

There are a few reasons for this change. First, we now use value 0
uniformly as a timestamp for both mail and timestamp documents, (which
lets us cleanup an ugly and fragile bare 0 in the add_value and
get_value calls in the timestamp code).

Second, I want to drop the thread value entirely, so putting it at the
end of the list means we can drop it as compatible change in the
future. (I almost want to drop the message-ID value too, but it's nice
to be able to sort on it to get diff-able output from "notmuch dump".)

But the thread value we never use as a value, (we would never sort on
it, for example). And it's totally redundant with the thread terms we
store already. So expect it to disappear soon.

database.cc
message.cc
notmuch-private.h
query.cc

index 928e91ba7585617f9a64c3634b3ef2f39f6a3f0f..aaad710552f9d4c496098ea19945f9f6b8ab1d26 100644 (file)
@@ -588,7 +588,8 @@ notmuch_database_set_timestamp (notmuch_database_t *notmuch,
     try {
        status = find_timestamp_document (notmuch, db_key, &doc, &doc_id);
 
-       doc.add_value (0, Xapian::sortable_serialise (timestamp));
+       doc.add_value (NOTMUCH_VALUE_TIMESTAMP,
+                      Xapian::sortable_serialise (timestamp));
 
        if (status == NOTMUCH_PRIVATE_STATUS_NO_DOCUMENT_FOUND) {
            char *term = talloc_asprintf (NULL, "%s%s",
@@ -630,7 +631,7 @@ notmuch_database_get_timestamp (notmuch_database_t *notmuch, const char *key)
        if (status == NOTMUCH_PRIVATE_STATUS_NO_DOCUMENT_FOUND)
            goto DONE;
 
-       ret =  Xapian::sortable_unserialise (doc.get_value (0));
+       ret =  Xapian::sortable_unserialise (doc.get_value (NOTMUCH_VALUE_TIMESTAMP));
     } catch (Xapian::Error &error) {
        goto DONE;
     }
index 78b6fed6bb2d8725e52f3637088fd513f5e0a748..f2405ac69a627a64be652c17b5cbced4b5774f23 100644 (file)
@@ -268,7 +268,7 @@ _notmuch_message_set_date (notmuch_message_t *message,
 
     time_value = notmuch_parse_date (date, NULL);
 
-    message->doc.add_value (NOTMUCH_VALUE_DATE,
+    message->doc.add_value (NOTMUCH_VALUE_TIMESTAMP,
                            Xapian::sortable_serialise (time_value));
 }
 
index 88b01bd3029f0c0b39387a44f05d1376f2120a8f..53e99bdd8a23634e815b2c62141c0039be17f8e4 100644 (file)
@@ -67,13 +67,10 @@ NOTMUCH_BEGIN_DECLS
 #endif
 #endif
 
-/* These value numbers are chosen to be sup compatible (for now at
- * least). */
-
 typedef enum {
-    NOTMUCH_VALUE_MESSAGE_ID = 0,
-    NOTMUCH_VALUE_THREAD = 1,
-    NOTMUCH_VALUE_DATE = 2
+    NOTMUCH_VALUE_TIMESTAMP = 0,
+    NOTMUCH_VALUE_MESSAGE_ID,
+    NOTMUCH_VALUE_THREAD
 } notmuch_value_t;
 
 /* Xapian (with flint backend) complains if we provide a term longer
index ae986d35c9d1499bfb5695a252959a054a18357b..c68bd37ad7fdb4bab5cc6f35cffcda8792b70919 100644 (file)
--- a/query.cc
+++ b/query.cc
@@ -114,10 +114,10 @@ notmuch_query_search (notmuch_query_t *query)
 
        switch (query->sort) {
        case NOTMUCH_SORT_DATE_OLDEST_FIRST:
-           enquire.set_sort_by_value (NOTMUCH_VALUE_DATE, FALSE);
+           enquire.set_sort_by_value (NOTMUCH_VALUE_TIMESTAMP, FALSE);
            break;
        case NOTMUCH_SORT_DATE_NEWEST_FIRST:
-           enquire.set_sort_by_value (NOTMUCH_VALUE_DATE, TRUE);
+           enquire.set_sort_by_value (NOTMUCH_VALUE_TIMESTAMP, TRUE);
            break;
        case NOTMUCH_SORT_MESSAGE_ID:
            enquire.set_sort_by_value (NOTMUCH_VALUE_MESSAGE_ID, FALSE);