Mercurial > dovecot > original-hg > dovecot-1.2
changeset 368:44751b4d92e1 HEAD
Compress index when 50% of it is deleted.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 06 Oct 2002 10:41:06 +0300 |
parents | 9b36fc3c1385 |
children | d037915978ca |
files | src/lib-index/mail-index.c src/lib-index/mail-index.h |
diffstat | 2 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-index.c Sun Oct 06 09:10:12 2002 +0300 +++ b/src/lib-index/mail-index.c Sun Oct 06 10:41:06 2002 +0300 @@ -699,10 +699,16 @@ return TRUE; } +#define INDEX_NEED_COMPRESS(records, hdr) \ + ((records) > INDEX_MIN_RECORDS_COUNT && \ + (records) * (100-INDEX_COMPRESS_PERCENTAGE) / 100 > \ + (hdr)->messages_count) + int mail_index_expunge(MailIndex *index, MailIndexRecord *rec, unsigned int seq, int external_change) { MailIndexHeader *hdr; + unsigned int records; uoff_t pos; i_assert(index->lock_type == MAIL_LOCK_EXCLUSIVE); @@ -782,9 +788,12 @@ /* the hole reaches end of file, truncate it */ (void)mail_index_truncate_hole(index); } else { - /* update deleted_space in data file */ (void)mail_index_data_add_deleted_space(index->data, rec->data_size); + + records = MAIL_INDEX_RECORD_COUNT(index); + if (INDEX_NEED_COMPRESS(records, hdr)) + hdr->flags |= MAIL_INDEX_FLAG_COMPRESS; } return TRUE;
--- a/src/lib-index/mail-index.h Sun Oct 06 09:10:12 2002 +0300 +++ b/src/lib-index/mail-index.h Sun Oct 06 10:41:06 2002 +0300 @@ -422,6 +422,8 @@ #define INDEX_TRUNCATE_PERCENTAGE 30 /* don't truncate whole file anyway, keep n% of the empty space */ #define INDEX_TRUNCATE_KEEP_PERCENTAGE 10 +/* Compress the file when deleted space reaches n% of total size */ +#define INDEX_COMPRESS_PERCENTAGE 50 /* uoff_t to index file for given record */ #define INDEX_FILE_POSITION(index, ptr) \