Kouhei Sutou
null+****@clear*****
Tue Sep 8 10:59:50 JST 2015
Kouhei Sutou 2015-09-08 10:59:50 +0900 (Tue, 08 Sep 2015) New Revision: 9a45631693c4c2e12c83a59b266679b70946c6ee https://github.com/groonga/groonga/commit/9a45631693c4c2e12c83a59b266679b70946c6ee Message: regexp: use normalizer for referenced table Added files: test/command/suite/select/filter/no_index/regexp/normalized_reference.expected test/command/suite/select/filter/no_index/regexp/normalized_reference.test Modified files: lib/operator.c Modified: lib/operator.c (+20 -11) =================================================================== --- lib/operator.c 2015-09-08 10:25:17 +0900 (c82708b) +++ lib/operator.c 2015-09-08 10:59:50 +0900 (30076f2) @@ -897,26 +897,35 @@ exec_text_operator_record_text(grn_ctx *ctx, record_key_len = grn_table_get_key(ctx, table, GRN_RECORD_VALUE(record), record_key, GRN_TABLE_MAX_KEY_SIZE); grn_table_get_info(ctx, table, NULL, NULL, NULL, &normalizer, NULL); - if (normalizer && (op != GRN_OP_REGEXP)) { + if (normalizer) { grn_obj *norm_query; const char *norm_query_raw; unsigned int norm_query_raw_length_in_bytes; - norm_query = grn_string_open(ctx, - GRN_TEXT_VALUE(query), - GRN_TEXT_LEN(query), - normalizer, - 0); - grn_string_get_normalized(ctx, norm_query, - &norm_query_raw, - &norm_query_raw_length_in_bytes, - NULL); + + if (op == GRN_OP_REGEXP) { + norm_query = NULL; + norm_query_raw = GRN_TEXT_VALUE(query); + norm_query_raw_length_in_bytes = GRN_TEXT_LEN(query); + } else { + norm_query = grn_string_open(ctx, + GRN_TEXT_VALUE(query), + GRN_TEXT_LEN(query), + normalizer, + 0); + grn_string_get_normalized(ctx, norm_query, + &norm_query_raw, + &norm_query_raw_length_in_bytes, + NULL); + } matched = exec_text_operator(ctx, op, record_key, record_key_len, norm_query_raw, norm_query_raw_length_in_bytes); - grn_obj_close(ctx, norm_query); + if (norm_query) { + grn_obj_close(ctx, norm_query); + } } else { matched = exec_text_operator_raw_text_raw_text(ctx, op, Added: test/command/suite/select/filter/no_index/regexp/normalized_reference.expected (+14 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/filter/no_index/regexp/normalized_reference.expected 2015-09-08 10:59:50 +0900 (b7144e0) @@ -0,0 +1,14 @@ +table_create Products TABLE_PAT_KEY ShortText --normalizer NormalizerAuto +[[0,0.0,0.0],true] +table_create Memos TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Memos product COLUMN_SCALAR Products +[[0,0.0,0.0],true] +load --table Memos +[ +{"product": "Groonga"}, +{"product": "Mroonga"} +] +[[0,0.0,0.0],2] +select Memos --filter 'product @~ "\\\\Agr"' +[[0,0.0,0.0],[[[1],[["_id","UInt32"],["product","Products"]],[1,"groonga"]]]] Added: test/command/suite/select/filter/no_index/regexp/normalized_reference.test (+12 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/filter/no_index/regexp/normalized_reference.test 2015-09-08 10:59:50 +0900 (ea8f3b7) @@ -0,0 +1,12 @@ +table_create Products TABLE_PAT_KEY ShortText --normalizer NormalizerAuto + +table_create Memos TABLE_NO_KEY +column_create Memos product COLUMN_SCALAR Products + +load --table Memos +[ +{"product": "Groonga"}, +{"product": "Mroonga"} +] + +select Memos --filter 'product @~ "\\\\Agr"' -------------- next part -------------- HTML����������������������������...Descargar