[Groonga-commit] groonga/groonga at ae673a7 [master] Add subrec information to table inspection

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Jun 19 14:53:19 JST 2013


Kouhei Sutou	2013-06-19 14:53:19 +0900 (Wed, 19 Jun 2013)

  New Revision: ae673a7261696da33a1a3b5106a762a1dc34bf07
  https://github.com/groonga/groonga/commit/ae673a7261696da33a1a3b5106a762a1dc34bf07

  Message:
    Add subrec information to table inspection

  Modified files:
    lib/util.c
    test/unit/core/test-inspect.c

  Modified: lib/util.c (+35 -0)
===================================================================
--- lib/util.c    2013-06-19 14:50:12 +0900 (0ebbaff)
+++ lib/util.c    2013-06-19 14:53:19 +0900 (472e726)
@@ -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);

  Modified: test/unit/core/test-inspect.c (+11 -5)
===================================================================
--- test/unit/core/test-inspect.c    2013-06-19 14:50:12 +0900 (38e13ac)
+++ test/unit/core/test-inspect.c    2013-06-19 14:53:19 +0900 (7c3f461)
@@ -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
@@ -386,7 +386,8 @@ test_array_empty(void)
                           "value:(nil) "
                           "size:0 "
                           "columns:[] "
-                          "ids:[]"
+                          "ids:[] "
+                          "subrec:none"
                           ">",
                           inspected_string());
 }
@@ -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());
 }
@@ -423,7 +425,8 @@ test_hash_empty(void)
                           "columns:[] "
                           "default_tokenizer:(nil) "
                           "normalizer:(nil) "
-                          "keys:[]"
+                          "keys:[] "
+                          "subrec:none"
                           ">",
                           inspected_string());
 }
@@ -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());
 }
@@ -468,6 +472,7 @@ test_patricia_trie_empty(void)
                           "default_tokenizer:(nil) "
                           "normalizer:(nil) "
                           "keys:[] "
+                          "subrec:none "
                           "nodes:{}"
                           ">",
                           inspected_string());
@@ -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"
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index