[Groonga-commit] groonga/groonga at 46bcd02 [master] Extract table keys inspection code

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Jun 19 15:09:17 JST 2013


Kouhei Sutou	2013-06-19 15:09:17 +0900 (Wed, 19 Jun 2013)

  New Revision: 46bcd02346f49cea1b028fb8dadd6a180c37e42d
  https://github.com/groonga/groonga/commit/46bcd02346f49cea1b028fb8dadd6a180c37e42d

  Message:
    Extract table keys inspection code

  Modified files:
    lib/util.c

  Modified: lib/util.c (+25 -18)
===================================================================
--- lib/util.c    2013-06-19 15:05:31 +0900 (e970f51)
+++ lib/util.c    2013-06-19 15:09:17 +0900 (f5c3457)
@@ -604,6 +604,29 @@ grn_table_normalizer_inspect(grn_ctx *ctx, grn_obj *buf, grn_obj *obj)
   return GRN_SUCCESS;
 }
 
+static grn_rc
+grn_table_keys_inspect(grn_ctx *ctx, grn_obj *buf, grn_obj *obj)
+{
+
+    GRN_TEXT_PUTS(ctx, buf, "keys:[");
+    tc = grn_table_cursor_open(ctx, obj, NULL, 0, NULL, 0,
+                               0, -1, GRN_CURSOR_ASCENDING);
+    if (tc) {
+      int i = 0;
+      grn_id id;
+      grn_obj key;
+      GRN_OBJ_INIT(&key, GRN_BULK, 0, obj->header.domain);
+      while ((id = grn_table_cursor_next(ctx, tc))) {
+        if (i++ > 0) { GRN_TEXT_PUTS(ctx, buf, ", "); }
+        grn_table_get_key2(ctx, obj, id, &key);
+        grn_inspect(ctx, buf, &key);
+        GRN_BULK_REWIND(&key);
+      }
+      GRN_OBJ_FIN(ctx, &key);
+      grn_table_cursor_close(ctx, tc);
+    }
+    GRN_TEXT_PUTS(ctx, buf, "]");
+}
 
 static grn_rc
 grn_table_inspect(grn_ctx *ctx, grn_obj *buf, grn_obj *obj)
@@ -651,24 +674,8 @@ grn_table_inspect(grn_ctx *ctx, grn_obj *buf, grn_obj *obj)
     GRN_TEXT_PUTS(ctx, buf, " ");
     grn_table_normalizer_inspect(ctx, buf, obj);
 
-    GRN_TEXT_PUTS(ctx, buf, " keys:[");
-    tc = grn_table_cursor_open(ctx, obj, NULL, 0, NULL, 0,
-                               0, -1, GRN_CURSOR_ASCENDING);
-    if (tc) {
-      int i = 0;
-      grn_id id;
-      grn_obj key;
-      GRN_OBJ_INIT(&key, GRN_BULK, 0, obj->header.domain);
-      while ((id = grn_table_cursor_next(ctx, tc))) {
-        if (i++ > 0) { GRN_TEXT_PUTS(ctx, buf, ", "); }
-        grn_table_get_key2(ctx, obj, id, &key);
-        grn_inspect(ctx, buf, &key);
-        GRN_BULK_REWIND(&key);
-      }
-      GRN_OBJ_FIN(ctx, &key);
-      grn_table_cursor_close(ctx, tc);
-    }
-    GRN_TEXT_PUTS(ctx, buf, "]");
+    GRN_TEXT_PUTS(ctx, buf, " ");
+    grn_table_keys_inspect(ctx, buf, obj);
   }
 
   GRN_TEXT_PUTS(ctx, buf, " subrec:");
-------------- next part --------------
HTML����������������������������...
Download 



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