Navigation Menu

Skip to content

Commit

Permalink
object_inspect: show index column info only for index column
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Apr 6, 2017
1 parent 4442358 commit 16eeeb6
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 32 deletions.
42 changes: 27 additions & 15 deletions lib/proc/proc_object_inspect.c
Expand Up @@ -261,26 +261,44 @@ 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);
}

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");
Expand All @@ -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);
}
Expand Down
9 changes: 4 additions & 5 deletions test/command/suite/object_inspect/column/index.expected
Expand Up @@ -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
}
}
]
5 changes: 1 addition & 4 deletions test/command/suite/object_inspect/column/scalar_fix.expected
Expand Up @@ -56,9 +56,6 @@ object_inspect Users.age
"size": 1
},
"compress": null
},
"section": false,
"weight": false,
"position": false
}
}
]
5 changes: 1 addition & 4 deletions test/command/suite/object_inspect/column/scalar_var.expected
Expand Up @@ -44,9 +44,6 @@ object_inspect Memos.title
"size": 4096
},
"compress": "zstd"
},
"section": false,
"weight": false,
"position": false
}
}
]
5 changes: 1 addition & 4 deletions test/command/suite/object_inspect/column/vector.expected
Expand Up @@ -44,9 +44,6 @@ object_inspect Memos.tags
"size": 4096
},
"compress": null
},
"section": false,
"weight": false,
"position": false
}
}
]

0 comments on commit 16eeeb6

Please sign in to comment.