Kouhei Sutou
null+****@clear*****
Thu Apr 6 15:54:11 JST 2017
Kouhei Sutou 2017-04-06 15:54:11 +0900 (Thu, 06 Apr 2017) New Revision: dac6d10b880625c2a8f6a00ce7f71f4eb84d68c6 https://github.com/groonga/groonga/commit/dac6d10b880625c2a8f6a00ce7f71f4eb84d68c6 Message: object_inspect: start supporting column Added files: test/command/suite/object_inspect/column/index.expected test/command/suite/object_inspect/column/index.test test/command/suite/object_inspect/column/scalar_fix.expected test/command/suite/object_inspect/column/scalar_fix.test test/command/suite/object_inspect/column/scalar_var.expected test/command/suite/object_inspect/column/scalar_var.test test/command/suite/object_inspect/column/vector.expected test/command/suite/object_inspect/column/vector.test Modified files: lib/proc/proc_object_inspect.c Modified: lib/proc/proc_object_inspect.c (+50 -1) =================================================================== --- lib/proc/proc_object_inspect.c 2017-04-06 15:20:18 +0900 (6d54442) +++ lib/proc/proc_object_inspect.c 2017-04-06 15:54:11 +0900 (17a0d0d) @@ -1,6 +1,6 @@ /* -*- c-basic-offset: 2 -*- */ /* - Copyright(C) 2016 Brazil + Copyright(C) 2016-2017 Brazil This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -174,6 +174,50 @@ command_object_inspect_table(grn_ctx *ctx, grn_obj *obj) } static void +command_object_inspect_column_name(grn_ctx *ctx, grn_obj *column) +{ + char name[GRN_TABLE_MAX_KEY_SIZE]; + int name_size; + + name_size = grn_column_name(ctx, column, name, GRN_TABLE_MAX_KEY_SIZE); + name[name_size] = '\0'; + grn_ctx_output_str(ctx, name, name_size); +} + +static void +command_object_inspect_column_value(grn_ctx *ctx, grn_obj *column) +{ + grn_ctx_output_map_open(ctx, "value", 1); + { + grn_id range_id = grn_obj_get_range(ctx, column); + grn_ctx_output_cstr(ctx, "type"); + command_object_inspect_type(ctx, grn_ctx_at(ctx, range_id)); + } + grn_ctx_output_map_close(ctx); +} + +static void +command_object_inspect_column(grn_ctx *ctx, grn_obj *obj) +{ + grn_ctx_output_map_open(ctx, "column", 5); + { + grn_ctx_output_cstr(ctx, "id"); + grn_ctx_output_uint64(ctx, grn_obj_id(ctx, obj)); + grn_ctx_output_cstr(ctx, "name"); + command_object_inspect_column_name(ctx, obj); + grn_ctx_output_cstr(ctx, "table"); + command_object_inspect_table(ctx, grn_ctx_at(ctx, obj->header.domain)); + grn_ctx_output_cstr(ctx, "full_name"); + command_object_inspect_obj_name(ctx, obj); + grn_ctx_output_cstr(ctx, "type"); + command_object_inspect_obj_type(ctx, obj->header.type); + grn_ctx_output_cstr(ctx, "value"); + command_object_inspect_column_value(ctx, obj); + } + grn_ctx_output_map_close(ctx); +} + +static void command_object_inspect_db(grn_ctx *ctx, grn_obj *obj) { grn_db *db = (grn_db *)obj; @@ -201,6 +245,11 @@ command_object_inspect_dispatch(grn_ctx *ctx, grn_obj *obj) case GRN_TABLE_NO_KEY : command_object_inspect_table(ctx, obj); break; + case GRN_COLUMN_FIX_SIZE : + case GRN_COLUMN_VAR_SIZE : + case GRN_COLUMN_INDEX : + command_object_inspect_column(ctx, obj); + break; case GRN_DB : command_object_inspect_db(ctx, obj); break; Added: test/command/suite/object_inspect/column/index.expected (+63 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/object_inspect/column/index.expected 2017-04-06 15:54:11 +0900 (1272850) @@ -0,0 +1,63 @@ +table_create Memos TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Memos title COLUMN_SCALAR ShortText +[[0,0.0,0.0],true] +column_create Memos content COLUMN_SCALAR Text +[[0,0.0,0.0],true] +table_create Terms TABLE_PAT_KEY ShortText --normalizer NormalizerAuto --default_tokenizer TokenBigram +[[0,0.0,0.0],true] +column_create Terms memos_title_content COLUMN_INDEX|WITH_POSITION|WITH_SECTION Memos title,content +[[0,0.0,0.0],true] +object_inspect Terms.memos_title_content +[ + [ + 0, + 0.0, + 0.0 + ], + { + "id": 260, + "name": "memos_title_content", + "table": { + "id": 259, + "name": "Terms", + "type": { + "id": 49, + "name": "table:pat_key" + }, + "key": { + "type": { + "id": 14, + "name": "ShortText", + "type": { + "id": 32, + "name": "type" + }, + "size": 4096 + }, + "total_size": 0, + "max_total_size": 4294967294 + }, + "value": { + "type": null + }, + "n_records": 0 + }, + "full_name": "Terms.memos_title_content", + "type": { + "id": 72, + "name": "column:index" + }, + "value": { + "type": { + "id": 256, + "name": "Memos", + "type": { + "id": 51, + "name": "table:no_key" + }, + "size": 4 + } + } + } +] Added: test/command/suite/object_inspect/column/index.test (+12 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/object_inspect/column/index.test 2017-04-06 15:54:11 +0900 (2631166) @@ -0,0 +1,12 @@ +table_create Memos TABLE_NO_KEY +column_create Memos title COLUMN_SCALAR ShortText +column_create Memos content COLUMN_SCALAR Text + +table_create Terms TABLE_PAT_KEY ShortText \ + --normalizer NormalizerAuto \ + --default_tokenizer TokenBigram +column_create Terms memos_title_content \ + COLUMN_INDEX|WITH_POSITION|WITH_SECTION \ + Memos title,content + +object_inspect Terms.memos_title_content Added: test/command/suite/object_inspect/column/scalar_fix.expected (+57 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/object_inspect/column/scalar_fix.expected 2017-04-06 15:54:11 +0900 (a16a775) @@ -0,0 +1,57 @@ +table_create Users TABLE_HASH_KEY ShortText +[[0,0.0,0.0],true] +column_create Users age COLUMN_SCALAR UInt8 +[[0,0.0,0.0],true] +object_inspect Users.age +[ + [ + 0, + 0.0, + 0.0 + ], + { + "id": 257, + "name": "age", + "table": { + "id": 256, + "name": "Users", + "type": { + "id": 48, + "name": "table:hash_key" + }, + "key": { + "type": { + "id": 14, + "name": "ShortText", + "type": { + "id": 32, + "name": "type" + }, + "size": 4096 + }, + "total_size": 0, + "max_total_size": 4294967295 + }, + "value": { + "type": null + }, + "n_records": 0 + }, + "full_name": "Users.age", + "type": { + "id": 64, + "name": "column:fix_size" + }, + "value": { + "type": { + "id": 5, + "name": "UInt8", + "type": { + "id": 32, + "name": "type" + }, + "size": 1 + } + } + } +] Added: test/command/suite/object_inspect/column/scalar_fix.test (+4 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/object_inspect/column/scalar_fix.test 2017-04-06 15:54:11 +0900 (78f3f86) @@ -0,0 +1,4 @@ +table_create Users TABLE_HASH_KEY ShortText +column_create Users age COLUMN_SCALAR UInt8 + +object_inspect Users.age Added: test/command/suite/object_inspect/column/scalar_var.expected (+45 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/object_inspect/column/scalar_var.expected 2017-04-06 15:54:11 +0900 (d5813ce) @@ -0,0 +1,45 @@ +table_create Memos TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Memos title COLUMN_SCALAR ShortText +[[0,0.0,0.0],true] +object_inspect Memos.title +[ + [ + 0, + 0.0, + 0.0 + ], + { + "id": 257, + "name": "title", + "table": { + "id": 256, + "name": "Memos", + "type": { + "id": 51, + "name": "table:no_key" + }, + "key": null, + "value": { + "type": null + }, + "n_records": 0 + }, + "full_name": "Memos.title", + "type": { + "id": 65, + "name": "column:var_size" + }, + "value": { + "type": { + "id": 14, + "name": "ShortText", + "type": { + "id": 32, + "name": "type" + }, + "size": 4096 + } + } + } +] Added: test/command/suite/object_inspect/column/scalar_var.test (+4 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/object_inspect/column/scalar_var.test 2017-04-06 15:54:11 +0900 (6503595) @@ -0,0 +1,4 @@ +table_create Memos TABLE_NO_KEY +column_create Memos title COLUMN_SCALAR ShortText + +object_inspect Memos.title Added: test/command/suite/object_inspect/column/vector.expected (+45 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/object_inspect/column/vector.expected 2017-04-06 15:54:11 +0900 (183213c) @@ -0,0 +1,45 @@ +table_create Memos TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Memos tags COLUMN_VECTOR ShortText +[[0,0.0,0.0],true] +object_inspect Memos.tags +[ + [ + 0, + 0.0, + 0.0 + ], + { + "id": 257, + "name": "tags", + "table": { + "id": 256, + "name": "Memos", + "type": { + "id": 51, + "name": "table:no_key" + }, + "key": null, + "value": { + "type": null + }, + "n_records": 0 + }, + "full_name": "Memos.tags", + "type": { + "id": 65, + "name": "column:var_size" + }, + "value": { + "type": { + "id": 14, + "name": "ShortText", + "type": { + "id": 32, + "name": "type" + }, + "size": 4096 + } + } + } +] Added: test/command/suite/object_inspect/column/vector.test (+4 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/object_inspect/column/vector.test 2017-04-06 15:54:11 +0900 (719c61b) @@ -0,0 +1,4 @@ +table_create Memos TABLE_NO_KEY +column_create Memos tags COLUMN_VECTOR ShortText + +object_inspect Memos.tags -------------- next part -------------- HTML����������������������������...Télécharger