Kouhei Sutou
null+****@clear*****
Thu May 7 22:45:48 JST 2015
Kouhei Sutou 2015-05-07 22:45:48 +0900 (Thu, 07 May 2015) New Revision: 6d43f595844da0d1efedad3ae4a64c2f1c7093f9 https://github.com/groonga/groonga/commit/6d43f595844da0d1efedad3ae4a64c2f1c7093f9 Message: sub_filter: support index column as scope Added files: test/command/suite/select/function/sub_filter/column/index.expected test/command/suite/select/function/sub_filter/column/index.test Modified files: lib/db.c lib/proc.c Modified: lib/db.c (+7 -3) =================================================================== --- lib/db.c 2015-05-07 22:40:18 +0900 (357df82) +++ lib/db.c 2015-05-07 22:45:48 +0900 (37227c2) @@ -2784,9 +2784,13 @@ grn_accessor_resolve(grn_ctx *ctx, grn_obj *accessor, int deep, grn_operator index_op = GRN_OP_MATCH; a = (grn_accessor *)GRN_PTR_VALUE_AT(&accessor_stack, i - 1); - if (grn_column_index(ctx, a->obj, index_op, &index, 1, NULL) == 0) { - rc = GRN_INVALID_ARGUMENT; - break; + if (a->obj->header.type == GRN_COLUMN_INDEX) { + index = a->obj; + } else { + if (grn_column_index(ctx, a->obj, index_op, &index, 1, NULL) == 0) { + rc = GRN_INVALID_ARGUMENT; + break; + } } { Modified: lib/proc.c (+1 -0) =================================================================== --- lib/proc.c 2015-05-07 22:40:18 +0900 (64a2e78) +++ lib/proc.c 2015-05-07 22:45:48 +0900 (ee1224e) @@ -5134,6 +5134,7 @@ run_sub_filter(grn_ctx *ctx, grn_obj *table, case GRN_ACCESSOR : case GRN_COLUMN_FIX_SIZE : case GRN_COLUMN_VAR_SIZE : + case GRN_COLUMN_INDEX : break; default : /* TODO: put inspected the 1st argument to message */ Added: test/command/suite/select/function/sub_filter/column/index.expected (+59 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/function/sub_filter/column/index.expected 2015-05-07 22:45:48 +0900 (e1f3469) @@ -0,0 +1,59 @@ +table_create Articles TABLE_HASH_KEY ShortText +[[0,0.0,0.0],true] +column_create Articles content COLUMN_SCALAR Text +[[0,0.0,0.0],true] +table_create Comments TABLE_HASH_KEY ShortText +[[0,0.0,0.0],true] +column_create Comments content COLUMN_SCALAR ShortText +[[0,0.0,0.0],true] +column_create Comments article COLUMN_SCALAR Articles +[[0,0.0,0.0],true] +column_create Articles comment_index COLUMN_INDEX Comments article +[[0,0.0,0.0],true] +table_create Lexicon TABLE_PAT_KEY|KEY_NORMALIZE ShortText --default_tokenizer TokenBigram +[[0,0.0,0.0],true] +column_create Lexicon comments_content COLUMN_INDEX|WITH_POSITION Comments content +[[0,0.0,0.0],true] +load --table Comments +[ +{"_key": "comment1", "article": "article1", "content": "I'm using Groonga too!"}, +{"_key": "comment2", "article": "article3", "content": "I'm using Groonga and Mroonga!"}, +{"_key": "comment3", "article": "article1", "content": "I'm using Groonga too!"} +] +[[0,0.0,0.0],3] +load --table Articles +[ +{"_key": "article1", "content": "Groonga is fast!"}, +{"_key": "article2", "content": "Groonga is useful!"}, +{"_key": "article3", "content": "Mroonga is fast!"} +] +[[0,0.0,0.0],3] +select Articles --filter 'sub_filter(comment_index, "content @ \\"Mroonga\\"")' --output_columns "_key, content" +[ + [ + 0, + 0.0, + 0.0 + ], + [ + [ + [ + 1 + ], + [ + [ + "_key", + "ShortText" + ], + [ + "content", + "Text" + ] + ], + [ + "article3", + "Mroonga is fast!" + ] + ] + ] +] Added: test/command/suite/select/function/sub_filter/column/index.test (+32 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/function/sub_filter/column/index.test 2015-05-07 22:45:48 +0900 (75c2ee9) @@ -0,0 +1,32 @@ +table_create Articles TABLE_HASH_KEY ShortText +column_create Articles content COLUMN_SCALAR Text + +table_create Comments TABLE_HASH_KEY ShortText +column_create Comments content COLUMN_SCALAR ShortText +column_create Comments article COLUMN_SCALAR Articles + +column_create Articles comment_index COLUMN_INDEX Comments article + +table_create Lexicon TABLE_PAT_KEY|KEY_NORMALIZE ShortText \ + --default_tokenizer TokenBigram +column_create Lexicon comments_content COLUMN_INDEX|WITH_POSITION \ + Comments content + + +load --table Comments +[ +{"_key": "comment1", "article": "article1", "content": "I'm using Groonga too!"}, +{"_key": "comment2", "article": "article3", "content": "I'm using Groonga and Mroonga!"}, +{"_key": "comment3", "article": "article1", "content": "I'm using Groonga too!"} +] + +load --table Articles +[ +{"_key": "article1", "content": "Groonga is fast!"}, +{"_key": "article2", "content": "Groonga is useful!"}, +{"_key": "article3", "content": "Mroonga is fast!"} +] + +select Articles \ + --filter 'sub_filter(comment_index, "content @ \\"Mroonga\\"")' \ + --output_columns "_key, content" -------------- next part -------------- HTML����������������������������... ダウンロード