Kouhei Sutou
null+****@clear*****
Thu Apr 5 15:31:39 JST 2018
Kouhei Sutou 2018-04-05 15:31:39 +0900 (Thu, 05 Apr 2018) New Revision: 91e0aa003f9a3ffe6c8648eba97b6890ace0e67d https://github.com/groonga/groonga/commit/91e0aa003f9a3ffe6c8648eba97b6890ace0e67d Message: table_create: accept default_tokenizer with options It uses "tokenizer(option, ...)" format. Modified files: lib/proc/proc_table.c Modified: lib/proc/proc_table.c (+13 -17) =================================================================== --- lib/proc/proc_table.c 2018-04-05 15:30:28 +0900 (e9878ff01) +++ lib/proc/proc_table.c 2018-04-05 15:31:39 +0900 (d8d8642c2) @@ -197,7 +197,7 @@ command_table_create(grn_ctx *ctx, grn_raw_string flags_raw; grn_raw_string key_type_raw; grn_raw_string value_type_raw; - grn_raw_string default_tokenizer_raw; + grn_obj *default_tokenizer_raw; grn_raw_string normalizer_raw; grn_raw_string token_filters_raw; grn_obj *table; @@ -216,7 +216,8 @@ command_table_create(grn_ctx *ctx, GET_VALUE(flags); GET_VALUE(key_type); GET_VALUE(value_type); - GET_VALUE(default_tokenizer); + default_tokenizer_raw = grn_plugin_proc_get_var(ctx, user_data, + "default_tokenizer", -1); GET_VALUE(normalizer); GET_VALUE(token_filters); @@ -288,27 +289,22 @@ command_table_create(grn_ctx *ctx, goto exit; } - if (default_tokenizer_raw.length > 0) { - grn_obj *default_tokenizer; - - default_tokenizer = - grn_ctx_get(ctx, - default_tokenizer_raw.value, - default_tokenizer_raw.length); - if (!default_tokenizer) { + if (GRN_TEXT_LEN(default_tokenizer_raw) > 0) { + grn_obj_set_info(ctx, table, + GRN_INFO_DEFAULT_TOKENIZER, + default_tokenizer_raw); + if (ctx->rc != GRN_SUCCESS) { GRN_PLUGIN_ERROR(ctx, GRN_INVALID_ARGUMENT, - "[table][create][%.*s] unknown tokenizer: <%.*s>", + "[table][create][%.*s] " + "failed to set default tokenizer: <%.*s>: %s", (int)name_raw.length, name_raw.value, - (int)default_tokenizer_raw.length, - default_tokenizer_raw.value); + (int)GRN_TEXT_LEN(default_tokenizer_raw), + GRN_TEXT_VALUE(default_tokenizer_raw), + ctx->errbuf); goto exit; } - grn_obj_set_info(ctx, table, - GRN_INFO_DEFAULT_TOKENIZER, - default_tokenizer); - grn_obj_unlink(ctx, default_tokenizer); } if (normalizer_raw.length > 0) { -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180405/2fb35289/attachment-0001.htm