Kouhei Sutou
null+****@clear*****
Thu Apr 6 16:27:13 JST 2017
Kouhei Sutou 2017-04-06 16:27:13 +0900 (Thu, 06 Apr 2017) New Revision: 16eeeb6b64b223fab84fa4d38e92687f7b9a0058 https://github.com/groonga/groonga/commit/16eeeb6b64b223fab84fa4d38e92687f7b9a0058 Message: object_inspect: show index column info only for index column 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 (+27 -15) =================================================================== --- lib/proc/proc_object_inspect.c 2017-04-06 16:21:28 +0900 (f3a6a77) +++ lib/proc/proc_object_inspect.c 2017-04-06 16:27:13 +0900 (b79d38a) @@ -261,13 +261,35 @@ command_object_inspect_column_compress(grn_ctx *ctx, grn_obj *column) static void command_object_inspect_column_value(grn_ctx *ctx, grn_obj *column) { - grn_ctx_output_map_open(ctx, "value", 2); + int n_elements = 1; + grn_bool is_index = (column->header.type == GRN_COLUMN_INDEX); + + if (is_index) { + n_elements += 3; + } else { + n_elements += 1; + } + grn_ctx_output_map_open(ctx, "value", n_elements); { - grn_id range_id = grn_obj_get_range(ctx, column); + grn_id range_id; + grn_column_flags column_flags; + + range_id = grn_obj_get_range(ctx, column); + column_flags = grn_column_get_flags(ctx, column); + grn_ctx_output_cstr(ctx, "type"); command_object_inspect_type(ctx, grn_ctx_at(ctx, range_id)); - grn_ctx_output_cstr(ctx, "compress"); - command_object_inspect_column_compress(ctx, column); + if (is_index) { + grn_ctx_output_cstr(ctx, "section"); + grn_ctx_output_bool(ctx, (column_flags & GRN_OBJ_WITH_SECTION) != 0); + grn_ctx_output_cstr(ctx, "weight"); + grn_ctx_output_bool(ctx, (column_flags & GRN_OBJ_WITH_WEIGHT) != 0); + grn_ctx_output_cstr(ctx, "position"); + grn_ctx_output_bool(ctx, (column_flags & GRN_OBJ_WITH_POSITION) != 0); + } else { + grn_ctx_output_cstr(ctx, "compress"); + command_object_inspect_column_compress(ctx, column); + } } grn_ctx_output_map_close(ctx); } @@ -275,12 +297,8 @@ command_object_inspect_column_value(grn_ctx *ctx, grn_obj *column) static void command_object_inspect_column(grn_ctx *ctx, grn_obj *column) { - grn_ctx_output_map_open(ctx, "column", 9); + grn_ctx_output_map_open(ctx, "column", 6); { - grn_column_flags column_flags; - - column_flags = grn_column_get_flags(ctx, column); - grn_ctx_output_cstr(ctx, "id"); grn_ctx_output_uint64(ctx, grn_obj_id(ctx, column)); grn_ctx_output_cstr(ctx, "name"); @@ -293,12 +311,6 @@ command_object_inspect_column(grn_ctx *ctx, grn_obj *column) command_object_inspect_column_type(ctx, column); grn_ctx_output_cstr(ctx, "value"); command_object_inspect_column_value(ctx, column); - grn_ctx_output_cstr(ctx, "section"); - grn_ctx_output_bool(ctx, (column_flags & GRN_OBJ_WITH_SECTION) != 0); - grn_ctx_output_cstr(ctx, "weight"); - grn_ctx_output_bool(ctx, (column_flags & GRN_OBJ_WITH_WEIGHT) != 0); - grn_ctx_output_cstr(ctx, "position"); - grn_ctx_output_bool(ctx, (column_flags & GRN_OBJ_WITH_POSITION) != 0); } grn_ctx_output_map_close(ctx); } Modified: test/command/suite/object_inspect/column/index.expected (+4 -5) =================================================================== --- test/command/suite/object_inspect/column/index.expected 2017-04-06 16:21:28 +0900 (6cc7cd2) +++ test/command/suite/object_inspect/column/index.expected 2017-04-06 16:27:13 +0900 (2c2eddd) @@ -61,10 +61,9 @@ object_inspect Terms.memos_title_content }, "size": 4 }, - "compress": null - }, - "section": true, - "weight": false, - "position": true + "section": true, + "weight": false, + "position": true + } } ] Modified: test/command/suite/object_inspect/column/scalar_fix.expected (+1 -4) =================================================================== --- test/command/suite/object_inspect/column/scalar_fix.expected 2017-04-06 16:21:28 +0900 (6548a07) +++ test/command/suite/object_inspect/column/scalar_fix.expected 2017-04-06 16:27:13 +0900 (9e3fd37) @@ -56,9 +56,6 @@ object_inspect Users.age "size": 1 }, "compress": null - }, - "section": false, - "weight": false, - "position": false + } } ] Modified: test/command/suite/object_inspect/column/scalar_var.expected (+1 -4) =================================================================== --- test/command/suite/object_inspect/column/scalar_var.expected 2017-04-06 16:21:28 +0900 (8549c3d) +++ test/command/suite/object_inspect/column/scalar_var.expected 2017-04-06 16:27:13 +0900 (d8c6206) @@ -44,9 +44,6 @@ object_inspect Memos.title "size": 4096 }, "compress": "zstd" - }, - "section": false, - "weight": false, - "position": false + } } ] Modified: test/command/suite/object_inspect/column/vector.expected (+1 -4) =================================================================== --- test/command/suite/object_inspect/column/vector.expected 2017-04-06 16:21:28 +0900 (0768c76) +++ test/command/suite/object_inspect/column/vector.expected 2017-04-06 16:27:13 +0900 (81f42da) @@ -44,9 +44,6 @@ object_inspect Memos.tags "size": 4096 }, "compress": null - }, - "section": false, - "weight": false, - "position": false + } } ] -------------- next part -------------- HTML����������������������������...Download