Navigation Menu

Skip to content

Commit

Permalink
schema: extract column type output code as a function
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Oct 20, 2015
1 parent e365548 commit f30ec2c
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions lib/proc.c
Expand Up @@ -7834,6 +7834,27 @@ proc_schema_table_output_command(grn_ctx *ctx, grn_obj *table)
GRN_OBJ_FIN(ctx, &arguments);
}

static void
proc_schema_column_output_type(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_OUTPUT_CSTR("scalar");
break;
case GRN_OBJ_COLUMN_VECTOR :
GRN_OUTPUT_CSTR("vector");
break;
}
break;
case GRN_COLUMN_INDEX :
GRN_OUTPUT_CSTR("index");
break;
}
}

static void
proc_schema_column_output(grn_ctx *ctx, grn_obj *table, grn_obj *column)
{
Expand All @@ -7843,7 +7864,7 @@ proc_schema_column_output(grn_ctx *ctx, grn_obj *table, grn_obj *column)

proc_schema_output_column_name(ctx, column);

GRN_OUTPUT_MAP_OPEN("column", 4);
GRN_OUTPUT_MAP_OPEN("column", 5);

GRN_OUTPUT_CSTR("name");
proc_schema_output_column_name(ctx, column);
Expand All @@ -7855,22 +7876,7 @@ proc_schema_column_output(grn_ctx *ctx, grn_obj *table, grn_obj *column)
proc_schema_output_name(ctx, column);

GRN_OUTPUT_CSTR("type");
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_OUTPUT_CSTR("scalar");
break;
case GRN_OBJ_COLUMN_VECTOR :
GRN_OUTPUT_CSTR("vector");
break;
}
break;
case GRN_COLUMN_INDEX :
GRN_OUTPUT_CSTR("index");
break;
}
proc_schema_column_output_type(ctx, column);

GRN_OUTPUT_MAP_CLOSE();
}
Expand Down

0 comments on commit f30ec2c

Please sign in to comment.