Navigation Menu

Skip to content

Commit

Permalink
object_inspect: show column compress type
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Apr 6, 2017
1 parent c87621f commit 4442358
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 7 deletions.
34 changes: 33 additions & 1 deletion lib/proc/proc_object_inspect.c
Expand Up @@ -228,14 +228,46 @@ command_object_inspect_column_type(grn_ctx *ctx, grn_obj *column)
grn_ctx_output_map_close(ctx);
}

static void
command_object_inspect_column_compress(grn_ctx *ctx, grn_obj *column)
{
const char *compress = NULL;

if (column->header.type != GRN_COLUMN_INDEX) {
grn_column_flags column_flags;
column_flags = grn_column_get_flags(ctx, column);
switch (column_flags & GRN_OBJ_COMPRESS_MASK) {
case GRN_OBJ_COMPRESS_ZLIB :
compress = "zlib";
break;
case GRN_OBJ_COMPRESS_LZ4 :
compress = "lz4";
break;
case GRN_OBJ_COMPRESS_ZSTD :
compress = "zstd";
break;
default :
break;
}
}

if (compress) {
grn_ctx_output_cstr(ctx, compress);
} else {
grn_ctx_output_null(ctx);
}
}

static void
command_object_inspect_column_value(grn_ctx *ctx, grn_obj *column)
{
grn_ctx_output_map_open(ctx, "value", 1);
grn_ctx_output_map_open(ctx, "value", 2);
{
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_cstr(ctx, "compress");
command_object_inspect_column_compress(ctx, column);
}
grn_ctx_output_map_close(ctx);
}
Expand Down
3 changes: 2 additions & 1 deletion test/command/suite/object_inspect/column/index.expected
Expand Up @@ -60,7 +60,8 @@ object_inspect Terms.memos_title_content
"name": "table:no_key"
},
"size": 4
}
},
"compress": null
},
"section": true,
"weight": false,
Expand Down
3 changes: 2 additions & 1 deletion test/command/suite/object_inspect/column/scalar_fix.expected
Expand Up @@ -54,7 +54,8 @@ object_inspect Users.age
"name": "type"
},
"size": 1
}
},
"compress": null
},
"section": false,
"weight": false,
Expand Down
5 changes: 3 additions & 2 deletions test/command/suite/object_inspect/column/scalar_var.expected
@@ -1,6 +1,6 @@
table_create Memos TABLE_NO_KEY
[[0,0.0,0.0],true]
column_create Memos title COLUMN_SCALAR ShortText
column_create Memos title COLUMN_SCALAR|COMPRESS_ZSTD ShortText
[[0,0.0,0.0],true]
object_inspect Memos.title
[
Expand Down Expand Up @@ -42,7 +42,8 @@ object_inspect Memos.title
"name": "type"
},
"size": 4096
}
},
"compress": "zstd"
},
"section": false,
"weight": false,
Expand Down
2 changes: 1 addition & 1 deletion test/command/suite/object_inspect/column/scalar_var.test
@@ -1,4 +1,4 @@
table_create Memos TABLE_NO_KEY
column_create Memos title COLUMN_SCALAR ShortText
column_create Memos title COLUMN_SCALAR|COMPRESS_ZSTD ShortText

object_inspect Memos.title
3 changes: 2 additions & 1 deletion test/command/suite/object_inspect/column/vector.expected
Expand Up @@ -42,7 +42,8 @@ object_inspect Memos.tags
"name": "type"
},
"size": 4096
}
},
"compress": null
},
"section": false,
"weight": false,
Expand Down

0 comments on commit 4442358

Please sign in to comment.