fts-backend-squat.c revision 0007969c084c671b9f9378706083fad47799c84e
/* Copyright (c) 2006-2012 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "str.h"
#include "unichar.h"
#include "mail-user.h"
#include "mail-namespace.h"
#include "mail-storage-private.h"
#include "mail-search-build.h"
#include "squat-trie.h"
#include "fts-squat-plugin.h"
#include <stdlib.h>
#define SQUAT_FILE_PREFIX "dovecot.index.search"
struct squat_fts_backend {
struct fts_backend backend;
struct squat_trie *trie;
unsigned int partial_len, full_len;
bool refresh;
};
struct squat_fts_backend_update_context {
struct fts_backend_update_context ctx;
struct squat_trie_build_context *build_ctx;
enum squat_index_type squat_type;
bool failed;
};
static struct fts_backend *fts_backend_squat_alloc(void)
{
struct squat_fts_backend *backend;
}
static int
{
struct squat_fts_backend *backend =
(struct squat_fts_backend *)_backend;
unsigned int len;
return 0;
return -1;
}
return -1;
}
} else {
return -1;
}
}
return 0;
}
static void
{
}
{
struct squat_fts_backend *backend =
(struct squat_fts_backend *)_backend;
}
static void
{
const struct mailbox_permissions *perm;
struct mail_storage *storage;
struct mailbox_status status;
const char *path;
enum squat_index_flags flags = 0;
return;
return;
if (backend->partial_len != 0)
}
static int
{
struct squat_fts_backend *backend =
(struct squat_fts_backend *)_backend;
}
static struct fts_backend_update_context *
{
struct squat_fts_backend_update_context *ctx;
}
{
struct mailbox_transaction_context *t;
struct mail_search_context *search_ctx;
struct mail_search_args *search_args;
int ret;
t = mailbox_transaction_begin(box, 0);
}
(void)mailbox_transaction_commit(&t);
return ret;
}
static int
{
int ret = 0;
return 0;
ret = -1;
return ret;
}
static int
{
struct squat_fts_backend *backend =
int ret = 0;
return 0;
if (fts_backend_squat_update_uid_changed(ctx) < 0)
ret = -1;
ret = -1;
} else {
ret = -1;
}
array_free(&uids);
return ret;
}
static int
{
struct squat_fts_backend_update_context *ctx =
(struct squat_fts_backend_update_context *)_ctx;
if (fts_backend_squat_build_deinit(ctx) < 0)
ret = -1;
return ret;
}
static void
{
struct squat_fts_backend_update_context *ctx =
(struct squat_fts_backend_update_context *)_ctx;
struct squat_fts_backend *backend =
if (fts_backend_squat_build_deinit(ctx) < 0)
}
}
static void
{
/* FIXME */
}
static bool
const struct fts_backend_build_key *key)
{
struct squat_fts_backend_update_context *ctx =
(struct squat_fts_backend_update_context *)_ctx;
return FALSE;
if (fts_backend_squat_update_uid_changed(ctx) < 0)
}
break;
break;
i_unreached();
}
return TRUE;
}
static void
{
struct squat_fts_backend_update_context *ctx =
(struct squat_fts_backend_update_context *)_ctx;
}
static int
{
struct squat_fts_backend_update_context *ctx =
(struct squat_fts_backend_update_context *)_ctx;
return 0;
}
}
{
struct squat_fts_backend *backend =
(struct squat_fts_backend *)_backend;
return 0;
}
{
/* FIXME: drop expunged messages */
return 0;
}
{
enum squat_index_type squat_type;
int ret;
case SEARCH_TEXT:
break;
case SEARCH_BODY:
break;
case SEARCH_HEADER:
case SEARCH_HEADER_ADDRESS:
break;
default:
return 0;
}
i_panic("squat: search key not utf8");
/* definite -> non-match
maybe -> maybe
non-match -> maybe */
i_unreached();
}
if (and_args) {
/* AND:
definite && definite -> definite
definite && maybe -> maybe
maybe && maybe -> maybe */
/* put definites among maybies, so they can be intersected */
/* remove duplicate maybies that are also definites */
} else {
/* OR:
definite || definite -> definite
definite || maybe -> definite
maybe || maybe -> maybe */
/* remove maybies that are now definites */
}
}
static int
struct fts_result *result)
{
struct squat_fts_backend *backend =
(struct squat_fts_backend *)_backend;
int ret;
return -1;
}
&result->maybe_uids);
if (ret < 0)
return -1;
if (ret > 0)
}
return 0;
}
struct fts_backend fts_backend_squat = {
.name = "squat",
{
NULL,
NULL,
}
};