evolution-data-server r9104 - branches/camel-db-summary/camel
- From: sragavan svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r9104 - branches/camel-db-summary/camel
- Date: Thu, 10 Jul 2008 05:32:24 +0000 (UTC)
Author: sragavan
Date: Thu Jul 10 05:32:24 2008
New Revision: 9104
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9104&view=rev
Log:
Please delete your existing indices and 'folders' table for things to work cool. this sort of redoes a bit on stare summary.
Modified:
branches/camel-db-summary/camel/camel-db.c
branches/camel-db-summary/camel/camel-db.h
branches/camel-db-summary/camel/camel-folder-summary.c
branches/camel-db-summary/camel/camel-folder-summary.h
branches/camel-db-summary/camel/camel-folder.c
branches/camel-db-summary/camel/camel-vee-store.c
Modified: branches/camel-db-summary/camel/camel-db.c
==============================================================================
--- branches/camel-db-summary/camel/camel-db.c (original)
+++ branches/camel-db-summary/camel/camel-db.c Thu Jul 10 05:32:24 2008
@@ -482,7 +482,7 @@
if (cond)
sqlite3_free (cond);
- g_print ("QUEY %s\n", sel_query);
+ g_print ("QUERY %s\n", sel_query);
#warning "handle return values"
array = g_ptr_array_new ();
camel_db_select (db, sel_query, read_uids_callback, array, ex);
@@ -536,7 +536,7 @@
int
camel_db_create_folders_table (CamelDB *cdb, CamelException *ex)
{
- char *query = "CREATE TABLE IF NOT EXISTS folders ( folder_name TEXT PRIMARY KEY, version REAL, flags INTEGER, nextuid INTEGER, time NUMERIC, saved_count INTEGER, unread_count INTEGER, deleted_count INTEGER, junk_count INTEGER, bdata TEXT )";
+ char *query = "CREATE TABLE IF NOT EXISTS folders ( folder_name TEXT PRIMARY KEY, version REAL, flags INTEGER, nextuid INTEGER, time NUMERIC, saved_count INTEGER, unread_count INTEGER, deleted_count INTEGER, junk_count INTEGER, visible_count INTEGER, jnd_count INTEGER, bdata TEXT )";
CAMEL_DB_RELEASE_SQLITE_MEMORY;
return ((camel_db_command (cdb, query, ex)));
}
@@ -553,8 +553,8 @@
sqlite3_free (table_creation_query);
- safe_index = g_strdup_printf("INDEX-%s", folder_name);
- table_creation_query = sqlite3_mprintf ("CREATE INDEX IF NOT EXISTS %Q ON %Q (uid, read, junk, deleted)", safe_index, folder_name);
+ safe_index = g_strdup_printf("SINDEX-%s", folder_name);
+ table_creation_query = sqlite3_mprintf ("CREATE INDEX IF NOT EXISTS %Q ON %Q (uid, flags, size, dsent, dreceived, subject, mail_from, mail_to, mail_cc, mlist, part, labels, usertags, cinfo)", safe_index, folder_name);
ret = camel_db_add_to_transaction (cdb, table_creation_query, ex);
g_free (safe_index);
sqlite3_free (table_creation_query);
@@ -609,11 +609,11 @@
char *del_query;
char *ins_query;
- ins_query = sqlite3_mprintf ("INSERT INTO folders VALUES ( %Q, %d, %d, %d, %d, %d, %d, %d, %d, %Q ) ",
+ ins_query = sqlite3_mprintf ("INSERT INTO folders VALUES ( %Q, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %Q ) ",
record->folder_name, record->version,
record->flags, record->nextuid, record->time,
record->saved_count, record->unread_count,
- record->deleted_count, record->junk_count, record->bdata);
+ record->deleted_count, record->junk_count, record->visible_count, record->jnd_count, record->bdata);
del_query = sqlite3_mprintf ("DELETE FROM folders WHERE folder_name = %Q", record->folder_name);
@@ -678,7 +678,10 @@
else if (!strcmp (name [i], "junk_count"))
record->junk_count = cols [i] ? strtoul (cols [i], NULL, 10) : 0;
-
+ else if (!strcmp (name [i], "visible_count"))
+ record->visible_count = cols [i] ? strtoul (cols [i], NULL, 10) : 0;
+ else if (!strcmp (name [i], "jnd_count"))
+ record->jnd_count = cols [i] ? strtoul (cols [i], NULL, 10) : 0;
else if (!strcmp (name [i], "bdata"))
record->bdata = g_strdup (cols [i]);
Modified: branches/camel-db-summary/camel/camel-db.h
==============================================================================
--- branches/camel-db-summary/camel/camel-db.h (original)
+++ branches/camel-db-summary/camel/camel-db.h Thu Jul 10 05:32:24 2008
@@ -77,10 +77,11 @@
guint32 nextuid;
time_t time;
guint32 saved_count;
- /* Are these three really required? Can we just query it*/
guint32 unread_count;
guint32 deleted_count;
guint32 junk_count;
+ guint32 visible_count;
+ guint32 jnd_count; /* Junked not deleted */
char *bdata;
} CamelFIRecord;
Modified: branches/camel-db-summary/camel/camel-folder-summary.c
==============================================================================
--- branches/camel-db-summary/camel/camel-folder-summary.c (original)
+++ branches/camel-db-summary/camel/camel-folder-summary.c Thu Jul 10 05:32:24 2008
@@ -65,7 +65,7 @@
/* To switch between e-memchunk and g-alloc */
#define ALWAYS_ALLOC 1
#define USE_GSLICE 1
-#define SUMMARY_CACHE_DROP 180
+#define SUMMARY_CACHE_DROP 120
static pthread_mutex_t info_lock = PTHREAD_MUTEX_INITIALIZER;
/* this lock is ONLY for the standalone messageinfo stuff */
@@ -84,7 +84,7 @@
extern int strdup_count, malloc_count, free_count;
#endif
-#define CAMEL_FOLDER_SUMMARY_VERSION (13)
+#define CAMEL_FOLDER_SUMMARY_VERSION (14)
#define _PRIVATE(o) (((CamelFolderSummary *)(o))->priv)
@@ -717,7 +717,7 @@
struct _CamelFolderSummaryPrivate *p = _PRIVATE(s);
/* Attempt to release 2MB*/
- /* sqlite3_release_memory(CAMEL_DB_FREE_CACHE_SIZE); */
+ sqlite3_release_memory(CAMEL_DB_FREE_CACHE_SIZE);
if (time(NULL) - s->cache_load_time < SUMMARY_CACHE_DROP)
return TRUE;
@@ -788,12 +788,13 @@
folder_name = s->folder->full_name;
cdb = s->folder->cdb;
-
+#if 0
/* FIXME FOR SANKAR: No need to pass the address of summary here. */
data.summary = s;
data.add = TRUE;
data.double_ref = FALSE;
ret = camel_db_read_message_info_records (cdb, folder_name, (gpointer) &data, camel_read_mir_callback, ex);
+#endif
s->cache_load_time = time (NULL);
#warning "LRU please and not timeouts"
s->timeout_handle = g_timeout_add_seconds (SUMMARY_CACHE_DROP, remove_cache, s);
@@ -2193,7 +2194,9 @@
s->unread_count = record->unread_count;
s->deleted_count = record->deleted_count;
s->junk_count = record->junk_count;
-
+ s->visible_count = record->visible_count;
+ s->junk_not_deleted_count = record->jnd_count;
+
return 0;
}
@@ -2270,7 +2273,11 @@
record->deleted_count = 0;
if (camel_db_count_unread_message_info (db, table_name, &(record->unread_count), NULL))
record->unread_count = 0;
-
+ if (camel_db_count_visible_message_info (db, table_name, &(record->visible_count), NULL))
+ record->visible_count = 0;
+ if (camel_db_count_junk_not_deleted_message_info (db, table_name, &(record->jnd_count), NULL))
+ record->jnd_count = 0;
+
return record;
}
@@ -4152,9 +4159,18 @@
{
guint32 old;
CamelMessageInfoBase *mi = (CamelMessageInfoBase *)info;
-
+ int read=0, deleted=0, junk=0;
/* TODO: locking? */
+ if (flags & CAMEL_MESSAGE_SEEN && ((set & CAMEL_MESSAGE_SEEN) != (mi->flags & CAMEL_MESSAGE_SEEN)))
+ { read = set & CAMEL_MESSAGE_SEEN ? 1 : -1; printf("Setting read as %d\n", set & CAMEL_MESSAGE_SEEN ? 1 : 0);}
+
+ if (flags & CAMEL_MESSAGE_DELETED && ((set & CAMEL_MESSAGE_DELETED) != (mi->flags & CAMEL_MESSAGE_DELETED)))
+ { deleted = set & CAMEL_MESSAGE_DELETED ? 1 : -1; ;printf("Setting deleted as %d\n", set & CAMEL_MESSAGE_DELETED ? 1 : 0);}
+
+ if (flags & CAMEL_MESSAGE_JUNK && ((set & CAMEL_MESSAGE_JUNK) != (mi->flags & CAMEL_MESSAGE_JUNK)))
+ { junk = set & CAMEL_MESSAGE_JUNK ? 1 : -1; ;printf("Setting junk as %d\n", set & CAMEL_MESSAGE_JUNK ? 1 : 0);}
+
old = mi->flags;
mi->flags = (old & ~flags) | (set & flags);
if (old != mi->flags) {
@@ -4175,6 +4191,20 @@
camel_folder_change_info_free(changes);
}
+ if (mi->summary) {
+ if (read)
+ mi->summary->unread_count -= read;
+ if (deleted)
+ mi->summary->deleted_count += deleted;
+ if (junk)
+ mi->summary->junk_count += junk;
+ if (junk && !deleted)
+ mi->summary->junk_not_deleted_count += junk;
+ if (junk || deleted)
+ mi->summary->visible_count -= junk ? junk : deleted;
+ }
+
+ d(printf("%d %d %d %d %d\n", mi->summary->unread_count, mi->summary->deleted_count, mi->summary->junk_count, mi->summary->junk_not_deleted_count, mi->summary->visible_count));
return TRUE;
}
Modified: branches/camel-db-summary/camel/camel-folder-summary.h
==============================================================================
--- branches/camel-db-summary/camel/camel-folder-summary.h (original)
+++ branches/camel-db-summary/camel/camel-folder-summary.h Thu Jul 10 05:32:24 2008
@@ -221,7 +221,9 @@
guint32 unread_count; /* handy totals */
guint32 deleted_count;
guint32 junk_count;
-
+ guint32 junk_not_deleted_count;
+ guint32 visible_count;
+
/* sizes of memory objects */
guint32 message_info_size;
guint32 content_info_size;
Modified: branches/camel-db-summary/camel/camel-folder.c
==============================================================================
--- branches/camel-db-summary/camel/camel-folder.c (original)
+++ branches/camel-db-summary/camel/camel-folder.c Thu Jul 10 05:32:24 2008
@@ -384,39 +384,51 @@
CamelMessageInfo *info;
if (!CAMEL_IS_VEE_FOLDER (folder)) {
- /* TODO: Locking? */
- #warning "unread should be unread and not del/junk and take care of dirty infos also"
- // camel_folder_summary_save_to_db (folder->summary, NULL);
- camel_db_count_visible_unread_message_info (folder->cdb, folder->full_name, &unread, ex);
- camel_db_count_junk_message_info (folder->cdb, folder->full_name, &junked, ex);
- camel_db_count_deleted_message_info (folder->cdb, folder->full_name, &deleted, ex);
- camel_db_count_junk_not_deleted_message_info (folder->cdb, folder->full_name, &junked_not_deleted, ex);
- camel_db_count_visible_message_info (folder->cdb, folder->full_name, &visible, ex);
+ /* TODO: Locking? */
+ unread = folder->summary->unread_count;
+ deleted = folder->summary->deleted_count;
+ junked = folder->summary->junk_count;
+ junked_not_deleted = folder->summary->junk_not_deleted_count;
+ visible = folder->summary->visible_count;
+ #warning "unread should be unread and not del/junk and take care of dirty infos also"
+ // camel_folder_summary_save_to_db (folder->summary, NULL);
+ //camel_db_count_visible_unread_message_info (folder->cdb, folder->full_name, &unread, ex);
+ //camel_db_count_junk_message_info (folder->cdb, folder->full_name, &junked, ex);
+ //camel_db_count_deleted_message_info (folder->cdb, folder->full_name, &deleted, ex);
+ //camel_db_count_junk_not_deleted_message_info (folder->cdb, folder->full_name, &junked_not_deleted, ex);
+ //camel_db_count_visible_message_info (folder->cdb, folder->full_name, &visible, ex);
} else {
- count = camel_folder_summary_count (folder->summary);
- for (j = 0; j < count; j++) {
- if ((info = camel_folder_summary_index (folder->summary, j))) {
- guint32 flags = camel_message_info_flags(info);
-
- if ((flags & (CAMEL_MESSAGE_SEEN|CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_JUNK)) == 0)
- unread++;
- if (flags & CAMEL_MESSAGE_DELETED)
- deleted++;
- if (flags & CAMEL_MESSAGE_JUNK) {
- junked++;
- if (! (flags & CAMEL_MESSAGE_DELETED))
- junked_not_deleted++;
+ count = camel_folder_summary_count (folder->summary);
+ for (j = 0; j < count; j++) {
+ if ((info = camel_folder_summary_index (folder->summary, j))) {
+ guint32 flags = camel_message_info_flags(info);
+
+ if ((flags & (CAMEL_MESSAGE_SEEN|CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_JUNK)) == 0)
+ unread++;
+ if (flags & CAMEL_MESSAGE_DELETED)
+ deleted++;
+ if (flags & CAMEL_MESSAGE_JUNK) {
+ junked++;
+ if (! (flags & CAMEL_MESSAGE_DELETED))
+ junked_not_deleted++;
+ }
+ if ((flags & (CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_JUNK)) == 0)
+ visible++;
+ camel_message_info_free(info);
}
- if ((flags & (CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_JUNK)) == 0)
- visible++;
- camel_message_info_free(info);
+
+ }
+ #warning "I added it for vfolders summary storage, does it harm ?"
+ if (unread == -1) {
+ unread = folder->summary->unread_count;
+ /*
+ folder->summary->junk_count = junked;
+ folder->summary->deleted_count = deleted;
+ printf("*************************** %s %d %d %d\n", folder->full_name, folder->summary->unread_count, unread, count);
+ folder->summary->unread_count = unread; */
}
}
- }
- #warning "I added it for vfolders summary storage, does it harm ?"
- folder->summary->junk_count = junked;
- folder->summary->deleted_count = deleted;
- folder->summary->unread_count = unread;
+
}
switch (tag & CAMEL_ARG_TAG) {
Modified: branches/camel-db-summary/camel/camel-vee-store.c
==============================================================================
--- branches/camel-db-summary/camel/camel-vee-store.c (original)
+++ branches/camel-db-summary/camel/camel-vee-store.c Thu Jul 10 05:32:24 2008
@@ -349,7 +349,8 @@
g_hash_table_destroy(infos_hash);
/* and always add UNMATCHED, if scanning from top/etc */
- if (top == NULL || top[0] == 0 || strncmp(top, CAMEL_UNMATCHED_NAME, strlen(CAMEL_UNMATCHED_NAME)) == 0) {
+ #warning "comment it out well"
+ if (0 && (top == NULL || top[0] == 0 || strncmp(top, CAMEL_UNMATCHED_NAME, strlen(CAMEL_UNMATCHED_NAME)) == 0)) {
info = camel_folder_info_new ();
url = camel_url_new("vfolder:", NULL);
camel_url_set_path(url, ((CamelService *)store)->url->path);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]