Kouhei Sutou
null+****@clear*****
Thu Jun 16 22:40:55 JST 2016
Kouhei Sutou 2016-06-16 22:40:55 +0900 (Thu, 16 Jun 2016) New Revision: 444b8e14573cde11bd88fb287e6e6d38b6618e2a https://github.com/groonga/groonga/commit/444b8e14573cde11bd88fb287e6e6d38b6618e2a Message: select: support --drilldown with command_version=3 [groonga-dev,04055] Reported by Naoya Murakami. Thanks!!! Added files: test/command/suite/select/drilldown/plain/command_version/3.expected test/command/suite/select/drilldown/plain/command_version/3.test Modified files: lib/proc/proc_select.c Modified: lib/proc/proc_select.c (+14 -7) =================================================================== --- lib/proc/proc_select.c 2016-06-15 15:37:31 +0900 (0ef74d1) +++ lib/proc/proc_select.c 2016-06-16 22:40:55 +0900 (b649c95) @@ -2323,9 +2323,8 @@ grn_select_output_drilldowns(grn_ctx *ctx, } GRN_HASH_EACH_END(ctx, cursor); is_labeled = (data->drilldown.keys.length == 0); - if (is_labeled) { - data->output.formatter->drilldowns_open(ctx, data, n_available_results); - } + + data->output.formatter->drilldowns_open(ctx, data, n_available_results); GRN_HASH_EACH_BEGIN(ctx, data->drilldowns, cursor, id) { grn_drilldown_data *drilldown; @@ -2589,13 +2588,21 @@ grn_select_output_drilldown_label_v3(grn_ctx *ctx, if (data->drilldown.keys.length == 0) { GRN_OUTPUT_STR(drilldown->label.value, drilldown->label.length); } else { + grn_obj *key; char name[GRN_TABLE_MAX_KEY_SIZE]; int name_len; - name_len = grn_obj_name(ctx, - drilldown->parsed_keys[0].key, - name, - GRN_TABLE_MAX_KEY_SIZE); + key = drilldown->parsed_keys[0].key; + switch (key->header.type) { + case GRN_COLUMN_FIX_SIZE : + case GRN_COLUMN_VAR_SIZE : + case GRN_COLUMN_INDEX : + name_len = grn_column_name(ctx, key, name, GRN_TABLE_MAX_KEY_SIZE); + break; + default : + name_len = grn_obj_name(ctx, key, name, GRN_TABLE_MAX_KEY_SIZE); + break; + } GRN_OUTPUT_STR(name, name_len); } } Added: test/command/suite/select/drilldown/plain/command_version/3.expected (+90 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/drilldown/plain/command_version/3.expected 2016-06-16 22:40:55 +0900 (a85ef46) @@ -0,0 +1,90 @@ +table_create Tags TABLE_PAT_KEY ShortText +[[0,0.0,0.0],true] +table_create Memos TABLE_HASH_KEY ShortText +[[0,0.0,0.0],true] +column_create Memos tag COLUMN_SCALAR Tags +[[0,0.0,0.0],true] +load --table Memos +[ +{"_key": "groonga is fast!", "tag": "groonga"}, +{"_key": "mroonga is fast!", "tag": "mroonga"}, +{"_key": "groonga sticker!", "tag": "groonga"}, +{"_key": "rroonga is fast!", "tag": "rroonga"} +] +[[0,0.0,0.0],4] +select Memos --drilldown tag --command_version 3 +{ + "header": { + "return_code": 0, + "start_time": 0.0, + "elapsed_time": 0.0 + }, + "body": { + "n_hits": 4, + "columns": [ + { + "name": "_id", + "type": "UInt32" + }, + { + "name": "_key", + "type": "ShortText" + }, + { + "name": "tag", + "type": "Tags" + } + ], + "records": [ + [ + 1, + "groonga is fast!", + "groonga" + ], + [ + 2, + "mroonga is fast!", + "mroonga" + ], + [ + 3, + "groonga sticker!", + "groonga" + ], + [ + 4, + "rroonga is fast!", + "rroonga" + ] + ], + "drilldowns": { + "tag": { + "n_hits": 3, + "columns": [ + { + "name": "_key", + "type": "ShortText" + }, + { + "name": "_nsubrecs", + "type": "Int32" + } + ], + "records": [ + [ + "groonga", + 2 + ], + [ + "mroonga", + 1 + ], + [ + "rroonga", + 1 + ] + ] + } + } + } +} Added: test/command/suite/select/drilldown/plain/command_version/3.test (+14 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/drilldown/plain/command_version/3.test 2016-06-16 22:40:55 +0900 (1a2a19c) @@ -0,0 +1,14 @@ +table_create Tags TABLE_PAT_KEY ShortText + +table_create Memos TABLE_HASH_KEY ShortText +column_create Memos tag COLUMN_SCALAR Tags + +load --table Memos +[ +{"_key": "groonga is fast!", "tag": "groonga"}, +{"_key": "mroonga is fast!", "tag": "mroonga"}, +{"_key": "groonga sticker!", "tag": "groonga"}, +{"_key": "rroonga is fast!", "tag": "rroonga"} +] + +select Memos --drilldown tag --command_version 3 -------------- next part -------------- HTML����������������������������...Download