Navigation Menu

Skip to content

Commit

Permalink
Add subrec information to table inspection
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jun 19, 2013
1 parent dc52bd7 commit ae673a7
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
35 changes: 35 additions & 0 deletions lib/util.c
Expand Up @@ -620,6 +620,41 @@ grn_table_inspect(grn_ctx *ctx, grn_obj *buf, grn_obj *obj)
GRN_TEXT_PUTS(ctx, buf, "]");
}

GRN_TEXT_PUTS(ctx, buf, " subrec:");
if (obj->header.flags & GRN_OBJ_WITH_SUBREC) {
switch (obj->header.flags & GRN_OBJ_UNIT_MASK) {
case GRN_OBJ_UNIT_DOCUMENT_NONE :
GRN_TEXT_PUTS(ctx, buf, "document:none");
break;
case GRN_OBJ_UNIT_DOCUMENT_SECTION :
GRN_TEXT_PUTS(ctx, buf, "document:section");
break;
case GRN_OBJ_UNIT_DOCUMENT_POSITION :
GRN_TEXT_PUTS(ctx, buf, "document:position");
break;
case GRN_OBJ_UNIT_SECTION_NONE :
GRN_TEXT_PUTS(ctx, buf, "section:none");
break;
case GRN_OBJ_UNIT_SECTION_POSITION :
GRN_TEXT_PUTS(ctx, buf, "section:popsition");
break;
case GRN_OBJ_UNIT_POSITION_NONE :
GRN_TEXT_PUTS(ctx, buf, "section:none");
break;
case GRN_OBJ_UNIT_USERDEF_DOCUMENT :
GRN_TEXT_PUTS(ctx, buf, "userdef:document");
break;
case GRN_OBJ_UNIT_USERDEF_SECTION :
GRN_TEXT_PUTS(ctx, buf, "userdef:section");
break;
case GRN_OBJ_UNIT_USERDEF_POSITION :
GRN_TEXT_PUTS(ctx, buf, "userdef:position");
break;
}
} else {
GRN_TEXT_PUTS(ctx, buf, "none");
}

if (obj->header.type == GRN_TABLE_PAT_KEY) {
GRN_TEXT_PUTS(ctx, buf, " nodes:");
grn_pat_inspect_nodes(ctx, (grn_pat *)obj, buf);
Expand Down
16 changes: 11 additions & 5 deletions test/unit/core/test-inspect.c
@@ -1,6 +1,6 @@
/* -*- c-basic-offset: 2; coding: utf-8 -*- */
/*
Copyright (C) 2010-2012 Kouhei Sutou <kou@clear-code.com>
Copyright (C) 2010-2013 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -386,7 +386,8 @@ test_array_empty(void)
"value:(nil) "
"size:0 "
"columns:[] "
"ids:[]"
"ids:[] "
"subrec:none"
">",
inspected_string());
}
Expand All @@ -405,7 +406,8 @@ test_array_with_records(void)
"value:(nil) "
"size:2 "
"columns:[name] "
"ids:[1, 2]"
"ids:[1, 2] "
"subrec:none"
">",
inspected_string());
}
Expand All @@ -423,7 +425,8 @@ test_hash_empty(void)
"columns:[] "
"default_tokenizer:(nil) "
"normalizer:(nil) "
"keys:[]"
"keys:[] "
"subrec:none"
">",
inspected_string());
}
Expand All @@ -449,7 +452,8 @@ test_hash_with_records(void)
"columns:[name] "
"default_tokenizer:(nil) "
"normalizer:(nil) "
"keys:[\"groonga.org\", \"razil.jp\"]"
"keys:[\"groonga.org\", \"razil.jp\"] "
"subrec:none"
">",
inspected_string());
}
Expand All @@ -468,6 +472,7 @@ test_patricia_trie_empty(void)
"default_tokenizer:(nil) "
"normalizer:(nil) "
"keys:[] "
"subrec:none "
"nodes:{}"
">",
inspected_string());
Expand Down Expand Up @@ -496,6 +501,7 @@ test_patricia_trie_with_records(void)
"default_tokenizer:(nil) "
"normalizer:(nil) "
"keys:[\"groonga.org\", \"razil.jp\"] "
"subrec:none "
"nodes:{\n"
"2(\"razil.jp\"){0,3,0}[01110010 01100001 01111010 01101001 "
"01101100 00101110 01101010 01110000]\n"
Expand Down

0 comments on commit ae673a7

Please sign in to comment.