Navigation Menu

Skip to content

Commit

Permalink
object_inspect: show column type
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Apr 6, 2017
1 parent 645fdd8 commit 8f6a5e9
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 9 deletions.
46 changes: 45 additions & 1 deletion lib/proc/proc_object_inspect.c
Expand Up @@ -184,6 +184,50 @@ command_object_inspect_column_name(grn_ctx *ctx, grn_obj *column)
grn_ctx_output_str(ctx, name, name_size);
}

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)
{
Expand All @@ -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);
}
Expand Down
7 changes: 5 additions & 2 deletions test/command/suite/object_inspect/column/index.expected
Expand Up @@ -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": {
Expand Down
7 changes: 5 additions & 2 deletions test/command/suite/object_inspect/column/scalar_fix.expected
Expand Up @@ -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": {
Expand Down
7 changes: 5 additions & 2 deletions test/command/suite/object_inspect/column/scalar_var.expected
Expand Up @@ -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": {
Expand Down
7 changes: 5 additions & 2 deletions test/command/suite/object_inspect/column/vector.expected
Expand Up @@ -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": {
Expand Down

0 comments on commit 8f6a5e9

Please sign in to comment.