Navigation Menu

Skip to content

Commit

Permalink
Extract table ids inspection code
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jun 19, 2013
1 parent c081f89 commit 0ac4d5c
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions lib/util.c
Expand Up @@ -547,6 +547,27 @@ grn_table_columns_inspect(grn_ctx *ctx, grn_obj *buf, grn_obj *obj)
return GRN_SUCCESS;
}

static grn_rc
grn_table_ids_inspect(grn_ctx *ctx, grn_obj *buf, grn_obj *obj)
{
grn_table_cursor *tc;
GRN_TEXT_PUTS(ctx, buf, "ids:[");
tc = grn_table_cursor_open(ctx, obj, NULL, 0, NULL, 0,
0, -1, GRN_CURSOR_ASCENDING);
if (tc) {
int i = 0;
grn_id id;
while ((id = grn_table_cursor_next(ctx, tc))) {
if (i++ > 0) { GRN_TEXT_PUTS(ctx, buf, ", "); }
grn_text_lltoa(ctx, buf, id);
}
grn_table_cursor_close(ctx, tc);
}
GRN_TEXT_PUTS(ctx, buf, "]");

return GRN_SUCCESS;
}

static grn_rc
grn_table_inspect(grn_ctx *ctx, grn_obj *buf, grn_obj *obj)
{
Expand Down Expand Up @@ -582,20 +603,8 @@ grn_table_inspect(grn_ctx *ctx, grn_obj *buf, grn_obj *obj)
grn_table_columns_inspect(ctx, buf, obj);

if (obj->header.type == GRN_TABLE_NO_KEY) {
grn_table_cursor *tc;
GRN_TEXT_PUTS(ctx, buf, " ids:[");
tc = grn_table_cursor_open(ctx, obj, NULL, 0, NULL, 0,
0, -1, GRN_CURSOR_ASCENDING);
if (tc) {
int i = 0;
grn_id id;
while ((id = grn_table_cursor_next(ctx, tc))) {
if (i++ > 0) { GRN_TEXT_PUTS(ctx, buf, ", "); }
grn_text_lltoa(ctx, buf, id);
}
grn_table_cursor_close(ctx, tc);
}
GRN_TEXT_PUTS(ctx, buf, "]");
GRN_TEXT_PUTS(ctx, buf, " ");
grn_table_ids_inspect(ctx, buf, obj);
} else {
grn_table_cursor *tc;
grn_obj *default_tokenizer;
Expand Down

0 comments on commit 0ac4d5c

Please sign in to comment.