Kouhei Sutou
null+****@clear*****
Mon Nov 24 21:19:41 JST 2014
Kouhei Sutou 2014-11-24 21:19:41 +0900 (Mon, 24 Nov 2014) New Revision: 2b272a6185037bf47671fa802a27b4226e071e00 https://github.com/groonga/groonga/commit/2b272a6185037bf47671fa802a27b4226e071e00 Message: select drilldown: support vector Added files: test/command/suite/select/drilldown/plain/vector.expected test/command/suite/select/drilldown/plain/vector.test Modified files: lib/db.c Modified: lib/db.c (+17 -2) =================================================================== --- lib/db.c 2014-11-24 18:34:50 +0900 (d30656d) +++ lib/db.c 2014-11-24 21:19:41 +0900 (fc1d74f) @@ -3491,8 +3491,23 @@ grn_table_group(grn_ctx *ctx, grn_obj *table, } break; case GRN_VECTOR : - ERR(GRN_OPERATION_NOT_SUPPORTED, "sorry.. not implemented yet"); - /* todo */ + { + unsigned int i, n_elements; + n_elements = grn_vector_size(ctx, &bulk); + for (i = 0; i < n_elements; i++) { + const char *content; + unsigned int content_length; + content_length = grn_vector_get_element(ctx, &bulk, i, + &content, NULL, NULL); + if (grn_table_add_v_inline(ctx, results->table, + content, content_length, + &value, NULL)) { + grn_table_add_subrec_inline(results->table, value, + ri ? ri->score : 0, + (grn_rset_posinfo *)&id, 0); + } + } + } break; case GRN_BULK : { Added: test/command/suite/select/drilldown/plain/vector.expected (+61 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/drilldown/plain/vector.expected 2014-11-24 21:19:41 +0900 (4619ec2) @@ -0,0 +1,61 @@ +table_create Memos TABLE_HASH_KEY ShortText +[[0,0.0,0.0],true] +column_create Memos tags COLUMN_VECTOR ShortText +[[0,0.0,0.0],true] +load --table Memos +[ +{"_key": "Groonga is fast!", "tags": ["Groonga"]}, +{"_key": "Mroonga is fast!", "tags": ["Mroonga", "Groonga"]}, +{"_key": "Groonga sticker!", "tags": ["Groonga"]}, +{"_key": "Rroonga is fast!", "tags": ["Rroonga", "Groonga"]}, +{"_key": "Groonga is good!", "tags": ["Groonga"]} +] +[[0,0.0,0.0],5] +select Memos --limit 0 --output_columns _id --drilldown tags --drilldown_output_columns _key,_nsubrecs --drilldown_sortby -_nsubrecs,_id +[ + [ + 0, + 0.0, + 0.0 + ], + [ + [ + [ + 5 + ], + [ + [ + "_id", + "UInt32" + ] + ] + ], + [ + [ + 3 + ], + [ + [ + "_key", + "ShortText" + ], + [ + "_nsubrecs", + "Int32" + ] + ], + [ + "Groonga", + 5 + ], + [ + "Mroonga", + 1 + ], + [ + "Rroonga", + 1 + ] + ] + ] +] Added: test/command/suite/select/drilldown/plain/vector.test (+18 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/drilldown/plain/vector.test 2014-11-24 21:19:41 +0900 (b760120) @@ -0,0 +1,18 @@ +table_create Memos TABLE_HASH_KEY ShortText +column_create Memos tags COLUMN_VECTOR ShortText + +load --table Memos +[ +{"_key": "Groonga is fast!", "tags": ["Groonga"]}, +{"_key": "Mroonga is fast!", "tags": ["Mroonga", "Groonga"]}, +{"_key": "Groonga sticker!", "tags": ["Groonga"]}, +{"_key": "Rroonga is fast!", "tags": ["Rroonga", "Groonga"]}, +{"_key": "Groonga is good!", "tags": ["Groonga"]} +] + +select Memos \ + --limit 0 \ + --output_columns _id \ + --drilldown tags \ + --drilldown_output_columns _key,_nsubrecs \ + --drilldown_sortby -_nsubrecs,_id -------------- next part -------------- HTML����������������������������...Download