Kouhei Sutou
null+****@clear*****
Wed Apr 25 15:36:54 JST 2018
Kouhei Sutou 2018-04-25 15:36:54 +0900 (Wed, 25 Apr 2018) New Revision: ac159fa84b70fe75ae6a692b1b588681ab68ebbe https://github.com/groonga/groonga/commit/ac159fa84b70fe75ae6a692b1b588681ab68ebbe Message: ii: really support offline index construction with tokenizer options Modified files: lib/db.c lib/pat.c lib/table.c Modified: lib/db.c (+8 -3) =================================================================== --- lib/db.c 2018-04-25 15:07:54 +0900 (e0a1515ee) +++ lib/db.c 2018-04-25 15:36:54 +0900 (e84a3da53) @@ -2340,7 +2340,7 @@ grn_table_truncate(grn_ctx *ctx, grn_obj *table) if (table) { grn_hook *hooks; grn_hash *cols; - grn_obj *tokenizer; + grn_obj tokenizer; grn_obj *normalizer; grn_obj token_filters; if ((cols = grn_hash_create(ctx, NULL, sizeof(grn_id), 0, @@ -2355,7 +2355,9 @@ grn_table_truncate(grn_ctx *ctx, grn_obj *table) grn_hash_close(ctx, cols); } if (table->header.type != GRN_TABLE_NO_KEY) { - grn_table_get_info(ctx, table, NULL, NULL, &tokenizer, &normalizer, NULL); + GRN_TEXT_INIT(&tokenizer, 0); + grn_table_get_default_tokenizer_string(ctx, table, &tokenizer); + grn_table_get_info(ctx, table, NULL, NULL, NULL, &normalizer, NULL); GRN_PTR_INIT(&token_filters, GRN_OBJ_VECTOR, GRN_ID_NIL); grn_obj_get_info(ctx, table, GRN_INFO_TOKEN_FILTERS, &token_filters); } @@ -2392,7 +2394,10 @@ grn_table_truncate(grn_ctx *ctx, grn_obj *table) break; } if (table->header.type != GRN_TABLE_NO_KEY) { - grn_obj_set_info(ctx, table, GRN_INFO_DEFAULT_TOKENIZER, tokenizer); + if (GRN_TEXT_LEN(&tokenizer) > 0) { + grn_obj_set_info(ctx, table, GRN_INFO_DEFAULT_TOKENIZER, &tokenizer); + } + GRN_OBJ_FIN(ctx, &tokenizer); grn_obj_set_info(ctx, table, GRN_INFO_NORMALIZER, normalizer); grn_obj_set_info(ctx, table, GRN_INFO_TOKEN_FILTERS, &token_filters); GRN_OBJ_FIN(ctx, &token_filters); Modified: lib/pat.c (+2 -0) =================================================================== --- lib/pat.c 2018-04-25 15:07:54 +0900 (cfa4b647b) +++ lib/pat.c 2018-04-25 15:36:54 +0900 (41d2138af) @@ -721,6 +721,8 @@ grn_pat_truncate(grn_ctx *ctx, grn_pat *pat) pat->header->truncated = GRN_TRUE; } if ((rc = grn_io_close(ctx, pat->io))) { goto exit; } + grn_table_module_fin(ctx, &(pat->tokenizer)); + grn_table_module_fin(ctx, &(pat->normalizer)); grn_pvector_fin(ctx, &pat->token_filters); pat->io = NULL; if (path && (rc = grn_io_remove(ctx, path))) { goto exit; } Modified: lib/table.c (+1 -3) =================================================================== --- lib/table.c 2018-04-25 15:07:54 +0900 (bae4e3926) +++ lib/table.c 2018-04-25 15:36:54 +0900 (776fdf81e) @@ -187,9 +187,7 @@ grn_table_module_set_options(grn_ctx *ctx, module->options = options; module->options_revision = revision; - if (options) { - module->options_close_func = close_func; - } + module->options_close_func = close_func; CRITICAL_SECTION_LEAVE(module->lock); } -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180425/b9000929/attachment-0001.htm