Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/plugins/fts/fts-api-private.h @ 8004:6418d4c0ff16 HEAD
fts: Added a new lookup API where the backend can look up all the fields
using a single query. Implemented it to fts-solr.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 13 Jul 2008 18:04:19 +0300 |
parents | 983c6ea05de0 |
children | 0a3b5ddb0869 |
rev | line source |
---|---|
6410
e4eb71ae8e96
Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents:
5405
diff
changeset
|
1 #ifndef FTS_API_PRIVATE_H |
e4eb71ae8e96
Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents:
5405
diff
changeset
|
2 #define FTS_API_PRIVATE_H |
4609
48a16f1254b5
Added full text search plugin framework. Still missing support for handling
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
3 |
48a16f1254b5
Added full text search plugin framework. Still missing support for handling
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
4 #include "fts-api.h" |
48a16f1254b5
Added full text search plugin framework. Still missing support for handling
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
5 |
48a16f1254b5
Added full text search plugin framework. Still missing support for handling
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
6 struct fts_backend_vfuncs { |
4709
d2693511dd33
Let FTS backend init function take a struct mailbox instead of path.
Timo Sirainen <tss@iki.fi>
parents:
4618
diff
changeset
|
7 struct fts_backend *(*init)(struct mailbox *box); |
4609
48a16f1254b5
Added full text search plugin framework. Still missing support for handling
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
8 void (*deinit)(struct fts_backend *backend); |
48a16f1254b5
Added full text search plugin framework. Still missing support for handling
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
9 |
4712
70ca205ce6f1
Added fts_backend_get_last_uid() which is first used to check if
Timo Sirainen <tss@iki.fi>
parents:
4709
diff
changeset
|
10 int (*get_last_uid)(struct fts_backend *backend, uint32_t *last_uid_r); |
70ca205ce6f1
Added fts_backend_get_last_uid() which is first used to check if
Timo Sirainen <tss@iki.fi>
parents:
4709
diff
changeset
|
11 |
6898
e739cffd05ef
FTS API changes and Squat rewrite. Squat is still missing expunge handling.
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
12 int (*build_init)(struct fts_backend *backend, uint32_t *last_uid_r, |
e739cffd05ef
FTS API changes and Squat rewrite. Squat is still missing expunge handling.
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
13 struct fts_backend_build_context **ctx_r); |
4609
48a16f1254b5
Added full text search plugin framework. Still missing support for handling
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
14 int (*build_more)(struct fts_backend_build_context *ctx, uint32_t uid, |
5341
acd4ed841b01
Separate headers and body in building and searching. Added support for
Timo Sirainen <tss@iki.fi>
parents:
4942
diff
changeset
|
15 const unsigned char *data, size_t size, bool headers); |
4609
48a16f1254b5
Added full text search plugin framework. Still missing support for handling
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
16 int (*build_deinit)(struct fts_backend_build_context *ctx); |
48a16f1254b5
Added full text search plugin framework. Still missing support for handling
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
17 |
4714 | 18 void (*expunge)(struct fts_backend *backend, struct mail *mail); |
4854
09b9b1e8f73d
Added fts_backend_expunge_finish() virtual backend function.
Timo Sirainen <tss@iki.fi>
parents:
4714
diff
changeset
|
19 void (*expunge_finish)(struct fts_backend *backend, |
09b9b1e8f73d
Added fts_backend_expunge_finish() virtual backend function.
Timo Sirainen <tss@iki.fi>
parents:
4714
diff
changeset
|
20 struct mailbox *box, bool committed); |
4714 | 21 |
4877
63d3b76e44fe
Added lock/unlock backend operations.
Timo Sirainen <tss@iki.fi>
parents:
4854
diff
changeset
|
22 int (*lock)(struct fts_backend *backend); |
63d3b76e44fe
Added lock/unlock backend operations.
Timo Sirainen <tss@iki.fi>
parents:
4854
diff
changeset
|
23 void (*unlock)(struct fts_backend *backend); |
63d3b76e44fe
Added lock/unlock backend operations.
Timo Sirainen <tss@iki.fi>
parents:
4854
diff
changeset
|
24 |
6898
e739cffd05ef
FTS API changes and Squat rewrite. Squat is still missing expunge handling.
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
25 int (*lookup)(struct fts_backend *backend, const char *key, |
e739cffd05ef
FTS API changes and Squat rewrite. Squat is still missing expunge handling.
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
26 enum fts_lookup_flags flags, |
e739cffd05ef
FTS API changes and Squat rewrite. Squat is still missing expunge handling.
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
27 ARRAY_TYPE(seq_range) *definite_uids, |
e739cffd05ef
FTS API changes and Squat rewrite. Squat is still missing expunge handling.
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
28 ARRAY_TYPE(seq_range) *maybe_uids); |
e739cffd05ef
FTS API changes and Squat rewrite. Squat is still missing expunge handling.
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
29 int (*filter)(struct fts_backend *backend, const char *key, |
e739cffd05ef
FTS API changes and Squat rewrite. Squat is still missing expunge handling.
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
30 enum fts_lookup_flags flags, |
e739cffd05ef
FTS API changes and Squat rewrite. Squat is still missing expunge handling.
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
31 ARRAY_TYPE(seq_range) *definite_uids, |
e739cffd05ef
FTS API changes and Squat rewrite. Squat is still missing expunge handling.
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
32 ARRAY_TYPE(seq_range) *maybe_uids); |
8004
6418d4c0ff16
fts: Added a new lookup API where the backend can look up all the fields
Timo Sirainen <tss@iki.fi>
parents:
7238
diff
changeset
|
33 |
6418d4c0ff16
fts: Added a new lookup API where the backend can look up all the fields
Timo Sirainen <tss@iki.fi>
parents:
7238
diff
changeset
|
34 int (*lookup2)(struct fts_backend_lookup_context *ctx, |
6418d4c0ff16
fts: Added a new lookup API where the backend can look up all the fields
Timo Sirainen <tss@iki.fi>
parents:
7238
diff
changeset
|
35 ARRAY_TYPE(seq_range) *definite_uids, |
6418d4c0ff16
fts: Added a new lookup API where the backend can look up all the fields
Timo Sirainen <tss@iki.fi>
parents:
7238
diff
changeset
|
36 ARRAY_TYPE(seq_range) *maybe_uids); |
4609
48a16f1254b5
Added full text search plugin framework. Still missing support for handling
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
37 }; |
48a16f1254b5
Added full text search plugin framework. Still missing support for handling
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
38 |
4942
b382b21409b5
Added support for X-BODY-FAST and X-TEXT-FAST SEARCH arguments. FTS plugin
Timo Sirainen <tss@iki.fi>
parents:
4877
diff
changeset
|
39 enum fts_backend_flags { |
6898
e739cffd05ef
FTS API changes and Squat rewrite. Squat is still missing expunge handling.
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
40 /* If set, the backend is used for TEXT and BODY search |
4942
b382b21409b5
Added support for X-BODY-FAST and X-TEXT-FAST SEARCH arguments. FTS plugin
Timo Sirainen <tss@iki.fi>
parents:
4877
diff
changeset
|
41 optimizations. Otherwise only TEXT_FAST and BODY_FAST are |
b382b21409b5
Added support for X-BODY-FAST and X-TEXT-FAST SEARCH arguments. FTS plugin
Timo Sirainen <tss@iki.fi>
parents:
4877
diff
changeset
|
42 optimized. */ |
6898
e739cffd05ef
FTS API changes and Squat rewrite. Squat is still missing expunge handling.
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
43 FTS_BACKEND_FLAG_SUBSTRING_LOOKUPS = 0x01 |
4942
b382b21409b5
Added support for X-BODY-FAST and X-TEXT-FAST SEARCH arguments. FTS plugin
Timo Sirainen <tss@iki.fi>
parents:
4877
diff
changeset
|
44 }; |
b382b21409b5
Added support for X-BODY-FAST and X-TEXT-FAST SEARCH arguments. FTS plugin
Timo Sirainen <tss@iki.fi>
parents:
4877
diff
changeset
|
45 |
4609
48a16f1254b5
Added full text search plugin framework. Still missing support for handling
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
46 struct fts_backend { |
48a16f1254b5
Added full text search plugin framework. Still missing support for handling
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
47 const char *name; |
4942
b382b21409b5
Added support for X-BODY-FAST and X-TEXT-FAST SEARCH arguments. FTS plugin
Timo Sirainen <tss@iki.fi>
parents:
4877
diff
changeset
|
48 enum fts_backend_flags flags; |
4618 | 49 |
4609
48a16f1254b5
Added full text search plugin framework. Still missing support for handling
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
50 struct fts_backend_vfuncs v; |
7238
983c6ea05de0
Compile fix with some compilers
Timo Sirainen <tss@iki.fi>
parents:
7207
diff
changeset
|
51 struct mailbox *box; |
5405
22d04968449a
Don't crash if another search is started while we're still building the
Timo Sirainen <tss@iki.fi>
parents:
5341
diff
changeset
|
52 |
6898
e739cffd05ef
FTS API changes and Squat rewrite. Squat is still missing expunge handling.
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
53 unsigned int locked:1; |
5405
22d04968449a
Don't crash if another search is started while we're still building the
Timo Sirainen <tss@iki.fi>
parents:
5341
diff
changeset
|
54 unsigned int building:1; |
4609
48a16f1254b5
Added full text search plugin framework. Still missing support for handling
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
55 }; |
48a16f1254b5
Added full text search plugin framework. Still missing support for handling
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
56 |
48a16f1254b5
Added full text search plugin framework. Still missing support for handling
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
57 struct fts_backend_build_context { |
48a16f1254b5
Added full text search plugin framework. Still missing support for handling
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
58 struct fts_backend *backend; |
4618 | 59 |
60 unsigned int failed:1; | |
4609
48a16f1254b5
Added full text search plugin framework. Still missing support for handling
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
61 }; |
48a16f1254b5
Added full text search plugin framework. Still missing support for handling
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
62 |
8004
6418d4c0ff16
fts: Added a new lookup API where the backend can look up all the fields
Timo Sirainen <tss@iki.fi>
parents:
7238
diff
changeset
|
63 struct fts_backend_lookup_field { |
6418d4c0ff16
fts: Added a new lookup API where the backend can look up all the fields
Timo Sirainen <tss@iki.fi>
parents:
7238
diff
changeset
|
64 const char *key; |
6418d4c0ff16
fts: Added a new lookup API where the backend can look up all the fields
Timo Sirainen <tss@iki.fi>
parents:
7238
diff
changeset
|
65 enum fts_lookup_flags flags; |
6418d4c0ff16
fts: Added a new lookup API where the backend can look up all the fields
Timo Sirainen <tss@iki.fi>
parents:
7238
diff
changeset
|
66 }; |
6418d4c0ff16
fts: Added a new lookup API where the backend can look up all the fields
Timo Sirainen <tss@iki.fi>
parents:
7238
diff
changeset
|
67 |
6418d4c0ff16
fts: Added a new lookup API where the backend can look up all the fields
Timo Sirainen <tss@iki.fi>
parents:
7238
diff
changeset
|
68 struct fts_backend_lookup_context { |
6418d4c0ff16
fts: Added a new lookup API where the backend can look up all the fields
Timo Sirainen <tss@iki.fi>
parents:
7238
diff
changeset
|
69 struct fts_backend *backend; |
6418d4c0ff16
fts: Added a new lookup API where the backend can look up all the fields
Timo Sirainen <tss@iki.fi>
parents:
7238
diff
changeset
|
70 pool_t pool; |
6418d4c0ff16
fts: Added a new lookup API where the backend can look up all the fields
Timo Sirainen <tss@iki.fi>
parents:
7238
diff
changeset
|
71 |
6418d4c0ff16
fts: Added a new lookup API where the backend can look up all the fields
Timo Sirainen <tss@iki.fi>
parents:
7238
diff
changeset
|
72 ARRAY_DEFINE(fields, struct fts_backend_lookup_field); |
6418d4c0ff16
fts: Added a new lookup API where the backend can look up all the fields
Timo Sirainen <tss@iki.fi>
parents:
7238
diff
changeset
|
73 }; |
6418d4c0ff16
fts: Added a new lookup API where the backend can look up all the fields
Timo Sirainen <tss@iki.fi>
parents:
7238
diff
changeset
|
74 |
4609
48a16f1254b5
Added full text search plugin framework. Still missing support for handling
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
75 void fts_backend_register(const struct fts_backend *backend); |
48a16f1254b5
Added full text search plugin framework. Still missing support for handling
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
76 void fts_backend_unregister(const char *name); |
48a16f1254b5
Added full text search plugin framework. Still missing support for handling
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
77 |
8004
6418d4c0ff16
fts: Added a new lookup API where the backend can look up all the fields
Timo Sirainen <tss@iki.fi>
parents:
7238
diff
changeset
|
78 void fts_filter_uids(ARRAY_TYPE(seq_range) *definite_dest, |
6418d4c0ff16
fts: Added a new lookup API where the backend can look up all the fields
Timo Sirainen <tss@iki.fi>
parents:
7238
diff
changeset
|
79 const ARRAY_TYPE(seq_range) *definite_filter, |
6418d4c0ff16
fts: Added a new lookup API where the backend can look up all the fields
Timo Sirainen <tss@iki.fi>
parents:
7238
diff
changeset
|
80 ARRAY_TYPE(seq_range) *maybe_dest, |
6418d4c0ff16
fts: Added a new lookup API where the backend can look up all the fields
Timo Sirainen <tss@iki.fi>
parents:
7238
diff
changeset
|
81 const ARRAY_TYPE(seq_range) *maybe_filter); |
6418d4c0ff16
fts: Added a new lookup API where the backend can look up all the fields
Timo Sirainen <tss@iki.fi>
parents:
7238
diff
changeset
|
82 |
4609
48a16f1254b5
Added full text search plugin framework. Still missing support for handling
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
83 #endif |