null+****@clear*****
null+****@clear*****
2010年 7月 8日 (木) 13:13:14 JST
Kouhei Sutou 2010-07-08 04:13:14 +0000 (Thu, 08 Jul 2010) New Revision: 12ca4a159a90b12670ed98b1bde56df0fd34a52f Log: add inspector for fix size column. Modified files: lib/util.c test/unit/core/test-inspect.c Modified: lib/util.c (+20 -2) =================================================================== --- lib/util.c 2010-07-08 04:10:34 +0000 (953b4f8) +++ lib/util.c 2010-07-08 04:13:14 +0000 (788b422) @@ -69,12 +69,11 @@ grn_accessor_inspect(grn_ctx *ctx, grn_obj *buf, grn_obj *obj) } static grn_rc -grn_ja_inspect(grn_ctx *ctx, grn_obj *buf, grn_obj *obj) +grn_store_inspect_body(grn_ctx *ctx, grn_obj *buf, grn_obj *obj) { int name_size; grn_id range_id; - GRN_TEXT_PUTS(ctx, buf, "#<column:var_size "); name_size = grn_obj_name(ctx, obj, NULL, 0); if (name_size) { grn_bulk_space(ctx, buf, name_size); @@ -122,8 +121,24 @@ grn_ja_inspect(grn_ctx *ctx, grn_obj *buf, grn_obj *obj) break; } + return GRN_SUCCESS; +} + +static grn_rc +grn_ra_inspect(grn_ctx *ctx, grn_obj *buf, grn_obj *obj) +{ + GRN_TEXT_PUTS(ctx, buf, "#<column:fix_size "); + grn_store_inspect_body(ctx, buf, obj); GRN_TEXT_PUTS(ctx, buf, ">"); + return GRN_SUCCESS; +} +static grn_rc +grn_ja_inspect(grn_ctx *ctx, grn_obj *buf, grn_obj *obj) +{ + GRN_TEXT_PUTS(ctx, buf, "#<column:var_size "); + grn_store_inspect_body(ctx, buf, obj); + GRN_TEXT_PUTS(ctx, buf, ">"); return GRN_SUCCESS; } @@ -223,6 +238,9 @@ grn_inspect(grn_ctx *ctx, grn_obj *buffer, grn_obj *obj) case GRN_ACCESSOR_VIEW : grn_accessor_inspect(ctx, buffer, obj); return buffer; + case GRN_COLUMN_FIX_SIZE : + grn_ra_inspect(ctx, buffer, obj); + break; case GRN_COLUMN_VAR_SIZE : grn_ja_inspect(ctx, buffer, obj); break; Modified: test/unit/core/test-inspect.c (+20 -0) =================================================================== --- test/unit/core/test-inspect.c 2010-07-08 04:10:34 +0000 (7afc77f) +++ test/unit/core/test-inspect.c 2010-07-08 04:13:14 +0000 (683ca72) @@ -59,6 +59,7 @@ void data_accessor_column_name(void); void test_accessor_column_name(gconstpointer data); void data_accessor_dynamic_pseudo_column_name(void); void test_accessor_dynamic_pseudo_column_name(gconstpointer data); +void test_column_fix_size(void); void test_column_var_size(void); void test_column_index(void); @@ -581,6 +582,25 @@ test_accessor_dynamic_pseudo_column_name(gconstpointer data) } void +test_column_fix_size(void) +{ + grn_obj *column; + + assert_send_command("table_create Sites TABLE_PAT_KEY ShortText"); + assert_send_command("column_create Sites score COLUMN_SCALAR Int32"); + + column = get_object("Sites.score"); + inspected = grn_inspect(context, NULL, column); + cut_assert_equal_string("#<column:fix_size " + "Sites.score " + "range:Int32 " + "type:scalar " + "compress:none" + ">", + inspected_string()); +} + +void test_column_var_size(void) { grn_obj *column;