Kouhei Sutou
null+****@clear*****
Mon Nov 18 11:52:19 JST 2013
Kouhei Sutou 2013-11-18 11:52:19 +0900 (Mon, 18 Nov 2013) New Revision: 80632299d44a66a7f5c0886f81821f7cd8240d08 https://github.com/groonga/groonga/commit/80632299d44a66a7f5c0886f81821f7cd8240d08 Message: suggest: remove needless normalization in complete Normalization is done in grn_table_cursor_open(). Added files: test/command/suite/suggest/complete/normalization.expected test/command/suite/suggest/complete/normalization.test Modified files: plugins/suggest/suggest.c Modified: plugins/suggest/suggest.c (+5 -15) =================================================================== --- plugins/suggest/suggest.c 2013-11-15 18:02:47 +0900 (4d24878) +++ plugins/suggest/suggest.c 2013-11-18 11:52:19 +0900 (05fe09b) @@ -308,24 +308,15 @@ complete(grn_ctx *ctx, grn_obj *items, grn_obj *items_boost, grn_obj *col, if ((res = grn_table_create(ctx, NULL, 0, NULL, GRN_TABLE_HASH_KEY|GRN_OBJ_WITH_SUBREC, items, NULL))) { grn_id tid = grn_table_get(ctx, items, TEXT_VALUE_LEN(query)); - grn_obj *string; - if (GRN_TEXT_LEN(query) && - (string = grn_string_open(ctx, TEXT_VALUE_LEN(query), - GRN_NORMALIZER_AUTO, 0))) { + if (GRN_TEXT_LEN(query)) { grn_table_cursor *cur; /* RK search + prefix search */ grn_obj *index; - const char *normalized; - unsigned int normalized_length_in_bytes; - grn_string_get_normalized(ctx, string, - &normalized, - &normalized_length_in_bytes, - NULL); /* FIXME: support index selection */ if (grn_column_index(ctx, col, GRN_OP_PREFIX, &index, 1, NULL)) { if ((cur = grn_table_cursor_open(ctx, grn_ctx_at(ctx, index->header.domain), - normalized, - normalized_length_in_bytes, + GRN_TEXT_VALUE(query), + GRN_TEXT_LEN(query), NULL, 0, 0, -1, GRN_CURSOR_PREFIX|GRN_CURSOR_RK))) { grn_id id; @@ -356,8 +347,8 @@ complete(grn_ctx *ctx, grn_obj *items, grn_obj *items_boost, grn_obj *col, (prefix_search_mode == GRN_SUGGEST_SEARCH_AUTO && !grn_table_size(ctx, res))) && (cur = grn_table_cursor_open(ctx, items, - normalized, - normalized_length_in_bytes, + GRN_TEXT_VALUE(query), + GRN_TEXT_LEN(query), NULL, 0, 0, -1, GRN_CURSOR_PREFIX))) { grn_id id; while ((id = grn_table_cursor_next(ctx, cur))) { @@ -366,7 +357,6 @@ complete(grn_ctx *ctx, grn_obj *items, grn_obj *items_boost, grn_obj *col, } grn_table_cursor_close(ctx, cur); } - grn_obj_close(ctx, string); } output(ctx, items, res, tid, sortby, output_columns, offset, limit); grn_obj_close(ctx, res); Added: test/command/suite/suggest/complete/normalization.expected (+29 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/suggest/complete/normalization.expected 2013-11-18 11:52:19 +0900 (7a3d2d2) @@ -0,0 +1,29 @@ +suggest --table item_rurema --column kana --types complete --frequency_threshold 1 --query 'sSh' +[ + [ + 0, + 0.0, + 0.0 + ], + { + "complete": [ + [ + 1 + ], + [ + [ + "_key", + "ShortText" + ], + [ + "_score", + "Int32" + ] + ], + [ + "ssh", + 101 + ] + ] + } +] Added: test/command/suite/suggest/complete/normalization.test (+8 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/suggest/complete/normalization.test 2013-11-18 11:52:19 +0900 (d82c64c) @@ -0,0 +1,8 @@ +#@include fixture/suggest/rurema/init.grn + +suggest \ + --table item_rurema \ + --column kana \ + --types complete \ + --frequency_threshold 1 \ + --query 'sSh' -------------- next part -------------- HTML����������������������������...Download