mirror of
https://github.com/MariaDB/server.git
synced 2026-05-17 20:37:12 +02:00
Merge 10.2 into 10.3
This commit is contained in:
commit
e9aaa10c11
27 changed files with 304 additions and 318 deletions
3
storage/mroonga/vendor/groonga/lib/db.c
vendored
3
storage/mroonga/vendor/groonga/lib/db.c
vendored
|
|
@ -445,6 +445,9 @@ grn_db_close(grn_ctx *ctx, grn_obj *db)
|
|||
|
||||
ctx_used_db = ctx->impl && ctx->impl->db == db;
|
||||
if (ctx_used_db) {
|
||||
#ifdef GRN_WITH_MECAB
|
||||
grn_db_fin_mecab_tokenizer(ctx);
|
||||
#endif
|
||||
grn_ctx_loader_clear(ctx);
|
||||
if (ctx->impl->parser) {
|
||||
grn_expr_parser_close(ctx);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ grn_rc grn_tokenizers_init(void);
|
|||
grn_rc grn_tokenizers_fin(void);
|
||||
|
||||
grn_rc grn_db_init_mecab_tokenizer(grn_ctx *ctx);
|
||||
void grn_db_fin_mecab_tokenizer(grn_ctx *ctx);
|
||||
grn_rc grn_db_init_builtin_tokenizers(grn_ctx *ctx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
30
storage/mroonga/vendor/groonga/lib/tokenizers.c
vendored
30
storage/mroonga/vendor/groonga/lib/tokenizers.c
vendored
|
|
@ -797,6 +797,36 @@ grn_db_init_mecab_tokenizer(grn_ctx *ctx)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
grn_db_fin_mecab_tokenizer(grn_ctx *ctx)
|
||||
{
|
||||
switch (GRN_CTX_GET_ENCODING(ctx)) {
|
||||
case GRN_ENC_EUC_JP :
|
||||
case GRN_ENC_UTF8 :
|
||||
case GRN_ENC_SJIS :
|
||||
#if defined(GRN_EMBEDDED) && defined(GRN_WITH_MECAB)
|
||||
{
|
||||
GRN_PLUGIN_DECLARE_FUNCTIONS(tokenizers_mecab);
|
||||
GRN_PLUGIN_IMPL_NAME_TAGGED(fin, tokenizers_mecab)(ctx);
|
||||
}
|
||||
#else /* defined(GRN_EMBEDDED) && defined(GRN_WITH_MECAB) */
|
||||
{
|
||||
const char *mecab_plugin_name = "tokenizers/mecab";
|
||||
char *path;
|
||||
path = grn_plugin_find_path(ctx, mecab_plugin_name);
|
||||
if (path) {
|
||||
GRN_FREE(path);
|
||||
grn_plugin_unregister(ctx, mecab_plugin_name);
|
||||
}
|
||||
}
|
||||
#endif /* defined(GRN_EMBEDDED) && defined(GRN_WITH_MECAB) */
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#define DEF_TOKENIZER(name, init, next, fin, vars)\
|
||||
(grn_proc_create(ctx, (name), (sizeof(name) - 1),\
|
||||
GRN_PROC_TOKENIZER, (init), (next), (fin), 3, (vars)))
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
static unsigned int sole_mecab_init_counter = 0;
|
||||
static mecab_t *sole_mecab = NULL;
|
||||
static grn_plugin_mutex *sole_mecab_mutex = NULL;
|
||||
static grn_encoding sole_mecab_encoding = GRN_ENC_NONE;
|
||||
|
|
@ -563,6 +564,11 @@ check_mecab_dictionary_encoding(grn_ctx *ctx)
|
|||
grn_rc
|
||||
GRN_PLUGIN_INIT(grn_ctx *ctx)
|
||||
{
|
||||
++sole_mecab_init_counter;
|
||||
if (sole_mecab_init_counter > 1)
|
||||
{
|
||||
return GRN_SUCCESS;
|
||||
}
|
||||
{
|
||||
char env[GRN_ENV_BUFFER_SIZE];
|
||||
|
||||
|
|
@ -636,6 +642,11 @@ GRN_PLUGIN_REGISTER(grn_ctx *ctx)
|
|||
grn_rc
|
||||
GRN_PLUGIN_FIN(grn_ctx *ctx)
|
||||
{
|
||||
--sole_mecab_init_counter;
|
||||
if (sole_mecab_init_counter > 0)
|
||||
{
|
||||
return GRN_SUCCESS;
|
||||
}
|
||||
if (sole_mecab) {
|
||||
mecab_destroy(sole_mecab);
|
||||
sole_mecab = NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue