Kouhei Sutou
null+****@clear*****
Thu Apr 6 16:12:17 JST 2017
Kouhei Sutou 2017-04-06 16:12:17 +0900 (Thu, 06 Apr 2017) New Revision: 8f6a5e9d71ea6a94a8dbf85ef26afc57ef8963bc https://github.com/groonga/groonga/commit/8f6a5e9d71ea6a94a8dbf85ef26afc57ef8963bc Message: object_inspect: show column type Modified files: lib/proc/proc_object_inspect.c test/command/suite/object_inspect/column/index.expected test/command/suite/object_inspect/column/scalar_fix.expected test/command/suite/object_inspect/column/scalar_var.expected test/command/suite/object_inspect/column/vector.expected Modified: lib/proc/proc_object_inspect.c (+45 -1) =================================================================== --- lib/proc/proc_object_inspect.c 2017-04-06 15:55:55 +0900 (17a0d0d) +++ lib/proc/proc_object_inspect.c 2017-04-06 16:12:17 +0900 (7c51997) @@ -185,6 +185,50 @@ command_object_inspect_column_name(grn_ctx *ctx, grn_obj *column) } static void +command_object_inspect_column_type_name(grn_ctx *ctx, grn_obj *column) +{ + switch (column->header.type) { + case GRN_COLUMN_FIX_SIZE : + case GRN_COLUMN_VAR_SIZE : + switch (column->header.flags & GRN_OBJ_COLUMN_TYPE_MASK) { + case GRN_OBJ_COLUMN_SCALAR : + grn_ctx_output_cstr(ctx, "scalar"); + break; + case GRN_OBJ_COLUMN_VECTOR : + grn_ctx_output_cstr(ctx, "vector"); + break; + } + break; + case GRN_COLUMN_INDEX : + grn_ctx_output_cstr(ctx, "index"); + break; + default: + break; + } +} + +static void +command_object_inspect_column_type(grn_ctx *ctx, grn_obj *column) +{ + grn_ctx_output_map_open(ctx, "type", 2); + { + grn_ctx_output_cstr(ctx, "name"); + command_object_inspect_column_type_name(ctx, column); + + grn_ctx_output_cstr(ctx, "raw"); + grn_ctx_output_map_open(ctx, "raw", 2); + { + grn_ctx_output_cstr(ctx, "id"); + grn_ctx_output_uint64(ctx, column->header.type); + grn_ctx_output_cstr(ctx, "name"); + grn_ctx_output_cstr(ctx, grn_obj_type_to_string(column->header.type)); + } + grn_ctx_output_map_close(ctx); + } + grn_ctx_output_map_close(ctx); +} + +static void command_object_inspect_column_value(grn_ctx *ctx, grn_obj *column) { grn_ctx_output_map_open(ctx, "value", 1); @@ -210,7 +254,7 @@ command_object_inspect_column(grn_ctx *ctx, grn_obj *obj) 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); + command_object_inspect_column_type(ctx, obj); grn_ctx_output_cstr(ctx, "value"); command_object_inspect_column_value(ctx, obj); } Modified: test/command/suite/object_inspect/column/index.expected (+5 -2) =================================================================== --- test/command/suite/object_inspect/column/index.expected 2017-04-06 15:55:55 +0900 (1272850) +++ test/command/suite/object_inspect/column/index.expected 2017-04-06 16:12:17 +0900 (fc790f5) @@ -45,8 +45,11 @@ object_inspect Terms.memos_title_content }, "full_name": "Terms.memos_title_content", "type": { - "id": 72, - "name": "column:index" + "name": "index", + "raw": { + "id": 72, + "name": "column:index" + } }, "value": { "type": { Modified: test/command/suite/object_inspect/column/scalar_fix.expected (+5 -2) =================================================================== --- test/command/suite/object_inspect/column/scalar_fix.expected 2017-04-06 15:55:55 +0900 (a16a775) +++ test/command/suite/object_inspect/column/scalar_fix.expected 2017-04-06 16:12:17 +0900 (c619d0e) @@ -39,8 +39,11 @@ object_inspect Users.age }, "full_name": "Users.age", "type": { - "id": 64, - "name": "column:fix_size" + "name": "scalar", + "raw": { + "id": 64, + "name": "column:fix_size" + } }, "value": { "type": { Modified: test/command/suite/object_inspect/column/scalar_var.expected (+5 -2) =================================================================== --- test/command/suite/object_inspect/column/scalar_var.expected 2017-04-06 15:55:55 +0900 (d5813ce) +++ test/command/suite/object_inspect/column/scalar_var.expected 2017-04-06 16:12:17 +0900 (efaf861) @@ -27,8 +27,11 @@ object_inspect Memos.title }, "full_name": "Memos.title", "type": { - "id": 65, - "name": "column:var_size" + "name": "scalar", + "raw": { + "id": 65, + "name": "column:var_size" + } }, "value": { "type": { Modified: test/command/suite/object_inspect/column/vector.expected (+5 -2) =================================================================== --- test/command/suite/object_inspect/column/vector.expected 2017-04-06 15:55:55 +0900 (183213c) +++ test/command/suite/object_inspect/column/vector.expected 2017-04-06 16:12:17 +0900 (2486074) @@ -27,8 +27,11 @@ object_inspect Memos.tags }, "full_name": "Memos.tags", "type": { - "id": 65, - "name": "column:var_size" + "name": "vector", + "raw": { + "id": 65, + "name": "column:var_size" + } }, "value": { "type": { -------------- next part -------------- HTML����������������������������...Download