[Groonga-commit] groonga/groonga at 0ac4d5c [master] Extract table ids inspection code

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Jun 19 15:00:51 JST 2013


Kouhei Sutou	2013-06-19 15:00:51 +0900 (Wed, 19 Jun 2013)

  New Revision: 0ac4d5c7dae360339ff77db3cc86e334e381372f
  https://github.com/groonga/groonga/commit/0ac4d5c7dae360339ff77db3cc86e334e381372f

  Message:
    Extract table ids inspection code

  Modified files:
    lib/util.c

  Modified: lib/util.c (+23 -14)
===================================================================
--- lib/util.c    2013-06-19 14:59:10 +0900 (7f2ea7e)
+++ lib/util.c    2013-06-19 15:00:51 +0900 (5c9fa96)
@@ -548,6 +548,27 @@ grn_table_columns_inspect(grn_ctx *ctx, grn_obj *buf, grn_obj *obj)
 }
 
 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)
 {
   grn_id range_id;
@@ -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;
-------------- next part --------------
HTML����������������������������...
Download 



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