Kouhei Sutou
null+****@clear*****
Tue May 15 17:04:43 JST 2018
Kouhei Sutou 2018-05-15 17:04:43 +0900 (Tue, 15 May 2018) New Revision: 5d6b48947ff1f51fe995f6506e8c93dc2e2fe9fb https://github.com/groonga/groonga/commit/5d6b48947ff1f51fe995f6506e8c93dc2e2fe9fb Message: sub_filter: support pre filter optimization with index accessor Copied files: test/command/suite/select/function/sub_filter/accessor/index/filtered.expected (from test/command/suite/select/function/sub_filter/accessor/index.expected) test/command/suite/select/function/sub_filter/accessor/index/filtered.test (from test/command/suite/select/function/sub_filter/accessor/index.test) Modified files: lib/proc.c Renamed files: test/command/suite/select/function/sub_filter/accessor/index/only.expected (from test/command/suite/select/function/sub_filter/accessor/index.expected) test/command/suite/select/function/sub_filter/accessor/index/only.test (from test/command/suite/select/function/sub_filter/accessor/index.test) Modified: lib/proc.c (+12 -7) =================================================================== --- lib/proc.c 2018-05-15 16:45:56 +0900 (ffacf7989) +++ lib/proc.c 2018-05-15 17:04:43 +0900 (1b20ac3bc) @@ -2122,19 +2122,17 @@ sub_filter_pre_filter_accessor(grn_ctx *ctx, GRN_RECORD_VALUE(&value), base_res); } else { - grn_posting posting; - memset(&posting, 0, sizeof(grn_posting)); + grn_posting posting = {0}; posting.rid = GRN_RECORD_VALUE(&value); grn_ii_posting_add(ctx, &posting, (grn_hash *)base_res, GRN_OP_OR); } } GRN_OBJ_FIN(ctx, &value); } else if (grn_obj_is_vector_column(ctx, accessor->obj)) { - grn_posting posting; + grn_posting posting = {0}; grn_obj values; unsigned int i, n; - memset(&posting, 0, sizeof(grn_posting)); GRN_RECORD_INIT(&values, GRN_OBJ_VECTOR, DB_OBJ(accessor->obj)->range); grn_obj_get_value(ctx, accessor->obj, id, &values); n = grn_vector_size(ctx, &values); @@ -2143,12 +2141,19 @@ sub_filter_pre_filter_accessor(grn_ctx *ctx, &values, i, &(posting.weight)); - grn_ii_posting_add(ctx, &posting, (grn_hash *)base_res, GRN_OP_OR); + if (accessor->next) { + sub_filter_pre_filter_accessor(ctx, + accessor->next, + posting.rid, + base_res); + } else { + grn_ii_posting_add(ctx, &posting, (grn_hash *)base_res, GRN_OP_OR); + } } GRN_OBJ_FIN(ctx, &values); } else if (grn_obj_is_index_column(ctx, accessor->obj)) { if (accessor->next) { - /* TODO */ + /* TODO: Report not supported. */ } else { grn_ii_at(ctx, (grn_ii *)(accessor->obj), @@ -2244,7 +2249,7 @@ sub_filter_pre_filter(grn_ctx *ctx, grn_table_cursor_get_key(ctx, cursor, (void **)&matched_id); sub_filter_pre_filter_accessor(ctx, (grn_accessor *)scope, - id, + *matched_id, base_res); } GRN_TABLE_EACH_END(ctx, cursor); grn_report_accessor(ctx, Copied: test/command/suite/select/function/sub_filter/accessor/index/filtered.expected (+11 -8) 72% =================================================================== --- test/command/suite/select/function/sub_filter/accessor/index.expected 2018-05-15 16:45:56 +0900 (bf62e4400) +++ test/command/suite/select/function/sub_filter/accessor/index/filtered.expected 2018-05-15 17:04:43 +0900 (5d7c3ec5e) @@ -38,7 +38,9 @@ load --table Groups {"_key": "group3", "users": ["Alice", "Carlos"]} ] [[0,0.0,0.0],3] -select Groups --filter 'sub_filter(users.files_author_index, "_key @^ \\"ha_\\"")' --output_columns '_key, users' +log_level --level info +[[0,0.0,0.0],true] +select Groups --filter '_key == "group3" && sub_filter(users.files_author_index, "_key @^ \\"ha_\\"")' --output_columns '_key, users' [ [ 0, @@ -48,7 +50,7 @@ select Groups --filter 'sub_filter(users.files_author_index, "_key @^ \\"ha_\\ [ [ [ - 2 + 1 ], [ [ @@ -66,13 +68,14 @@ select Groups --filter 'sub_filter(users.files_author_index, "_key @^ \\"ha_\\ "Alice", "Carlos" ] - ], - [ - "group2", - [ - "Bob" - ] ] ] ] ] +#|i| [table][select][index][equal][accessor][key] <Groups> +#|i| [table][select][index][selector][no-index][sub_filter] <Groups> +#|i| [sub_filter][pre-filter][accessor] users(Groups).files_author_index(Users) -> <Files> +#|i| [table][select][index][prefix][accessor][key] <Files> +#|i| [accessor][resolve][data-column][index] <Users.groups_index> +log_level --level notice +[[0,0.0,0.0],true] Copied: test/command/suite/select/function/sub_filter/accessor/index/filtered.test (+6 -1) 84% =================================================================== --- test/command/suite/select/function/sub_filter/accessor/index.test 2018-05-15 16:45:56 +0900 (ca1ad3505) +++ test/command/suite/select/function/sub_filter/accessor/index/filtered.test 2018-05-15 17:04:43 +0900 (b65d30adc) @@ -37,6 +37,11 @@ load --table Groups {"_key": "group3", "users": ["Alice", "Carlos"]} ] +#@add-important-log-levels info +log_level --level info select Groups \ - --filter 'sub_filter(users.files_author_index, "_key @^ \\"ha_\\"")' \ + --filter '_key == "group3" && \ + sub_filter(users.files_author_index, "_key @^ \\"ha_\\"")' \ --output_columns '_key, users' +log_level --level notice +#@remove-important-log-levels info Renamed: test/command/suite/select/function/sub_filter/accessor/index/only.expected (+0 -0) 100% =================================================================== Renamed: test/command/suite/select/function/sub_filter/accessor/index/only.test (+0 -0) 100% =================================================================== -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180515/44ed708d/attachment-0001.htm