Kouhei Sutou
null+****@clear*****
Tue May 15 16:06:23 JST 2018
Kouhei Sutou 2018-05-15 16:06:23 +0900 (Tue, 15 May 2018) New Revision: 391b6cadd5b7a0c322f6142bdaa36db9437eb43f https://github.com/groonga/groonga/commit/391b6cadd5b7a0c322f6142bdaa36db9437eb43f Message: sub_filter: support pre filter optimization with index column scope Copied files: test/command/suite/select/function/sub_filter/column/index/filtered.expected (from test/command/suite/select/function/sub_filter/column/index.expected) test/command/suite/select/function/sub_filter/column/index/filtered.test (from test/command/suite/select/function/sub_filter/column/index.test) Modified files: lib/proc.c Renamed files: test/command/suite/select/function/sub_filter/column/index/only.expected (from test/command/suite/select/function/sub_filter/column/index.expected) test/command/suite/select/function/sub_filter/column/index/only.test (from test/command/suite/select/function/sub_filter/column/index.test) Modified: lib/proc.c (+18 -2) =================================================================== --- lib/proc.c 2018-05-15 16:01:55 +0900 (231e5374e) +++ lib/proc.c 2018-05-15 16:06:23 +0900 (38ffd6be4) @@ -2111,13 +2111,12 @@ sub_filter_pre_filter(grn_ctx *ctx, grn_obj *scope, grn_obj *base_res) { - grn_posting posting; - if (grn_table_size(ctx, res) > grn_sub_filter_pre_filter_threshold) { return GRN_FALSE; } if (grn_obj_is_scalar_column(ctx, scope)) { + grn_posting posting; grn_obj value; memset(&posting, 0, sizeof(grn_posting)); @@ -2141,6 +2140,7 @@ sub_filter_pre_filter(grn_ctx *ctx, scope); return GRN_TRUE; } else if (grn_obj_is_vector_column(ctx, scope)) { + grn_posting posting; grn_obj values; memset(&posting, 0, sizeof(grn_posting)); @@ -2168,6 +2168,22 @@ sub_filter_pre_filter(grn_ctx *ctx, "[vector]", scope); return GRN_TRUE; + } else if (grn_obj_is_index_column(ctx, scope)) { + GRN_TABLE_EACH_BEGIN(ctx, res, cursor, id) { + grn_id *matched_id; + grn_table_cursor_get_key(ctx, cursor, (void **)&matched_id); + grn_ii_at(ctx, + (grn_ii *)scope, + *matched_id, + (grn_hash *)base_res, + GRN_OP_OR); + } GRN_TABLE_EACH_END(ctx, cursor); + + grn_report_column(ctx, + "[sub_filter][pre-filter]", + "[index]", + scope); + return GRN_TRUE; } else { return GRN_FALSE; } Copied: test/command/suite/select/function/sub_filter/column/index/filtered.expected (+14 -6) 73% =================================================================== --- test/command/suite/select/function/sub_filter/column/index.expected 2018-05-15 16:01:55 +0900 (028be0ebf) +++ test/command/suite/select/function/sub_filter/column/index/filtered.expected 2018-05-15 16:06:23 +0900 (d5021bad8) @@ -31,7 +31,9 @@ load --table Comments {"_key": "comment6", "article": "article1", "content": "Mroonga is also fast!"} ] [[0,0.0,0.0],6] -select Articles --filter 'sub_filter(comment_index, "content @ \\"Mroonga\\"")' --output_columns "_key, content" +log_level --level info +[[0,0.0,0.0],true] +select Articles --filter '_key == "article1" && sub_filter(comment_index, "content @ \\"Mroonga\\"")' --output_columns "_key, content" [ [ 0, @@ -41,7 +43,7 @@ select Articles --filter 'sub_filter(comment_index, "content @ \\"Mroonga\\"") [ [ [ - 2 + 1 ], [ [ @@ -54,13 +56,19 @@ select Articles --filter 'sub_filter(comment_index, "content @ \\"Mroonga\\"") ] ], [ - "article3", - "Mroonga is fast!" - ], - [ "article1", "Groonga is fast!" ] ] ] ] +#|i| [table][select][index][equal][accessor][key] <Articles> +#|i| [table][select][index][selector][no-index][sub_filter] <Articles> +#|i| [sub_filter][pre-filter][column][index] <Articles.comment_index> -> <Comments> +#|i| [object][search][index][key][exact] <Lexicon.comments_content> +#|i| grn_ii_sel > (Mroonga) +#|i| n=1 (Mroonga) +#|i| exact: 3 +#|i| hits=3 +log_level --level notice +[[0,0.0,0.0],true] Copied: test/command/suite/select/function/sub_filter/column/index/filtered.test (+6 -1) 85% =================================================================== --- test/command/suite/select/function/sub_filter/column/index.test 2018-05-15 16:01:55 +0900 (53de754eb) +++ test/command/suite/select/function/sub_filter/column/index/filtered.test 2018-05-15 16:06:23 +0900 (f9f8250eb) @@ -30,6 +30,11 @@ load --table Comments {"_key": "comment6", "article": "article1", "content": "Mroonga is also fast!"} ] +#@add-important-log-levels info +log_level --level info select Articles \ - --filter 'sub_filter(comment_index, "content @ \\"Mroonga\\"")' \ + --filter '_key == "article1" && \ + sub_filter(comment_index, "content @ \\"Mroonga\\"")' \ --output_columns "_key, content" +log_level --level notice +#@remove-important-log-levels info Renamed: test/command/suite/select/function/sub_filter/column/index/only.expected (+0 -0) 100% =================================================================== Renamed: test/command/suite/select/function/sub_filter/column/index/only.test (+0 -0) 100% =================================================================== -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180515/5ab294db/attachment-0001.htm