summaryrefslogtreecommitdiffstats
path: root/src/plugins/fts-lucene/lucene-wrapper.h
blob: 270e9021b6baaaac57e23c0a15d1b5ea1454525b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef LUCENE_WRAPPER_H
#define LUCENE_WRAPPER_H

#include "fts-api-private.h"
#include "guid.h"

struct mailbox_list;
struct fts_expunge_log;
struct fts_lucene_settings;

#define MAILBOX_GUID_HEX_LENGTH (GUID_128_SIZE*2)

struct lucene_index_record {
	guid_128_t mailbox_guid;
	uint32_t uid, part_num;
};

HASH_TABLE_DEFINE_TYPE(wguid_result, wchar_t *, struct fts_result *);

struct lucene_index *
lucene_index_init(const char *path, struct mailbox_list *list,
		  const struct fts_lucene_settings *set)
	ATTR_NULL(2, 3);
void lucene_index_deinit(struct lucene_index *index);

void lucene_index_select_mailbox(struct lucene_index *index,
				 const wchar_t guid[MAILBOX_GUID_HEX_LENGTH]);
void lucene_index_unselect_mailbox(struct lucene_index *index);
int lucene_index_get_last_uid(struct lucene_index *index, uint32_t *last_uid_r);
int lucene_index_get_doc_count(struct lucene_index *index, uint32_t *count_r);

int lucene_index_build_init(struct lucene_index *index);
int lucene_index_build_more(struct lucene_index *index, uint32_t uid,
			    uint32_t part_num, const unsigned char *data,
			    size_t size, const char *hdr_name);
int lucene_index_build_deinit(struct lucene_index *index);

void lucene_index_close(struct lucene_index *index);
int lucene_index_rescan(struct lucene_index *index);
int lucene_index_expunge_from_log(struct lucene_index *index,
				  struct fts_expunge_log *log);
int lucene_index_optimize(struct lucene_index *index);

int lucene_index_lookup(struct lucene_index *index, 
			struct mail_search_arg *args,
			enum fts_lookup_flags flags,
			struct fts_result *result);

int lucene_index_lookup_multi(struct lucene_index *index,
			      HASH_TABLE_TYPE(wguid_result) guids,
			      struct mail_search_arg *args,
			      enum fts_lookup_flags flags,
			      struct fts_multi_result *result);

struct lucene_index_iter *
lucene_index_iter_init(struct lucene_index *index);
const struct lucene_index_record *
lucene_index_iter_next(struct lucene_index_iter *iter);
int lucene_index_iter_deinit(struct lucene_index_iter **iter);

/* internal: */
void lucene_utf8_n_to_tchar(const unsigned char *src, size_t srcsize,
			    wchar_t *dest, size_t destsize);

void lucene_shutdown(void);

#endif