summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorKentoku SHIBA <kentokushiba@gmail.com>2020-05-28 10:21:46 +0900
committerKentoku SHIBA <kentokushiba@gmail.com>2020-05-29 21:48:30 +0900
commit6e6a4227c050eefda70fd5d4f906e9274cb12f39 (patch)
tree522eaa775e8adab4fa307852d8b41d37b2fdb017 /storage
parent069200267db4cb79bbd55d06cd7ea9e1acd86ce8 (diff)
downloadmariadb-git-6e6a4227c050eefda70fd5d4f906e9274cb12f39.tar.gz
Add grn_db_fin_mecab_tokenizer to finalyze mecab tokenizer
Diffstat (limited to 'storage')
-rw-r--r--storage/mroonga/vendor/groonga/lib/db.c3
-rw-r--r--storage/mroonga/vendor/groonga/lib/tokenizers.c30
2 files changed, 33 insertions, 0 deletions
diff --git a/storage/mroonga/vendor/groonga/lib/db.c b/storage/mroonga/vendor/groonga/lib/db.c
index cba22aa0e64..f3769f9aa4c 100644
--- a/storage/mroonga/vendor/groonga/lib/db.c
+++ b/storage/mroonga/vendor/groonga/lib/db.c
@@ -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);
diff --git a/storage/mroonga/vendor/groonga/lib/tokenizers.c b/storage/mroonga/vendor/groonga/lib/tokenizers.c
index 11f274e72db..3daacce7ef9 100644
--- a/storage/mroonga/vendor/groonga/lib/tokenizers.c
+++ b/storage/mroonga/vendor/groonga/lib/tokenizers.c
@@ -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)))