[dovecot-cvs] dovecot/src/plugins/fts-lucene fts-backend-lucene.c, 1.3, 1.4 lucene-wrapper.cc, 1.5, 1.6 lucene-wrapper.h, 1.3, 1.4
tss at dovecot.org
tss at dovecot.org
Wed Oct 25 21:25:05 UTC 2006
- Previous message: [dovecot-cvs] dovecot/src/plugins/fts fts-api-private.h, 1.4, 1.5 fts-api.c, 1.5, 1.6 fts-api.h, 1.4, 1.5 fts-storage.c, 1.7, 1.8
- Next message: [dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-sync-private.h, 1.56.2.1, 1.56.2.2 mbox-sync.c, 1.181.2.3, 1.181.2.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /var/lib/cvs/dovecot/src/plugins/fts-lucene
In directory talvi:/tmp/cvs-serv6167
Modified Files:
fts-backend-lucene.c lucene-wrapper.cc lucene-wrapper.h
Log Message:
Add support for expunges.
Index: fts-backend-lucene.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/fts-lucene/fts-backend-lucene.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- fts-backend-lucene.c 25 Oct 2006 20:02:59 -0000 1.3
+++ fts-backend-lucene.c 25 Oct 2006 20:25:03 -0000 1.4
@@ -138,6 +138,16 @@
return ret;
}
+static void
+fts_backend_lucene_expunge(struct fts_backend *_backend, struct mail *mail)
+{
+ struct lucene_fts_backend *backend =
+ (struct lucene_fts_backend *)_backend;
+
+ fts_backend_select(backend);
+ (void)lucene_index_expunge(backend->lstorage->index, mail->uid);
+}
+
static int
fts_backend_lucene_lookup(struct fts_backend *_backend, const char *key,
ARRAY_TYPE(seq_range) *result)
@@ -171,6 +181,7 @@
fts_backend_lucene_build_init,
fts_backend_lucene_build_more,
fts_backend_lucene_build_deinit,
+ fts_backend_lucene_expunge,
fts_backend_lucene_lookup,
fts_backend_lucene_filter
}
Index: lucene-wrapper.cc
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/fts-lucene/lucene-wrapper.cc,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- lucene-wrapper.cc 25 Oct 2006 20:02:59 -0000 1.5
+++ lucene-wrapper.cc 25 Oct 2006 20:25:03 -0000 1.6
@@ -334,6 +334,8 @@
index->doc->add(*Field::Text(_T("box"), index->tmailbox_name));
}
+ /* note that each addDocument() call adds a new document with a new
+ internal ID to the database. */
index->doc->add(*Field::Text(_T("contents"), dest));
index->writer->addDocument(index->doc);
return 0;
@@ -403,6 +405,40 @@
return ret;
}
+int lucene_index_expunge(struct lucene_index *index, uint32_t uid)
+{
+ char id[MAX_INT_STRLEN];
+ TCHAR tid[MAX_INT_STRLEN];
+ int ret;
+
+ if ((ret = lucene_index_open_search(index)) <= 0)
+ return ret;
+
+ i_snprintf(id, sizeof(id), "%u", uid);
+ STRCPY_AtoT(tid, id, MAX_INT_STRLEN);
+
+ Term mailbox_term(_T("box"), index->tmailbox_name);
+ Term uid_term(_T("uid"), tid);
+ TermQuery mailbox_query(&mailbox_term);
+ TermQuery uid_query(&uid_term);
+
+ BooleanQuery query;
+ query.add(&mailbox_query, true, false);
+ query.add(&uid_query, true, false);
+
+ try {
+ Hits *hits = index->searcher->search(&query);
+
+ for (int32_t i = 0; i < hits->length(); i++)
+ index->reader->deleteDocument(hits->id(i));
+ _CLDELETE(hits);
+ return 0;
+ } catch (CLuceneError &err) {
+ i_error("lucene: expunge search failed: %s", err.what());
+ return -1;
+ }
+}
+
int lucene_index_lookup(struct lucene_index *index, const char *key,
ARRAY_TYPE(seq_range) *result)
{
Index: lucene-wrapper.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/fts-lucene/lucene-wrapper.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- lucene-wrapper.h 25 Oct 2006 20:02:59 -0000 1.3
+++ lucene-wrapper.h 25 Oct 2006 20:25:03 -0000 1.4
@@ -15,6 +15,8 @@
const unsigned char *data, size_t size);
int lucene_index_build_deinit(struct lucene_index *index);
+int lucene_index_expunge(struct lucene_index *index, uint32_t uid);
+
int lucene_index_lookup(struct lucene_index *index, const char *key,
ARRAY_TYPE(seq_range) *result);
int lucene_index_filter(struct lucene_index *index, const char *key,
- Previous message: [dovecot-cvs] dovecot/src/plugins/fts fts-api-private.h, 1.4, 1.5 fts-api.c, 1.5, 1.6 fts-api.h, 1.4, 1.5 fts-storage.c, 1.7, 1.8
- Next message: [dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-sync-private.h, 1.56.2.1, 1.56.2.2 mbox-sync.c, 1.181.2.3, 1.181.2.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list