[Groonga-commit] groonga/groonga at 06ef963 [master] Add GRN_DB_EACH_BEGIN_*/END

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Sep 23 14:05:04 JST 2016


Kouhei Sutou	2016-09-23 14:05:04 +0900 (Fri, 23 Sep 2016)

  New Revision: 06ef9630c9093da11a99f2947a951057173d9972
  https://github.com/groonga/groonga/commit/06ef9630c9093da11a99f2947a951057173d9972

  Message:
    Add GRN_DB_EACH_BEGIN_*/END
    
    They're just shortcuts.

  Modified files:
    include/groonga/db.h
    lib/proc/proc_dump.c

  Modified: include/groonga/db.h (+22 -0)
===================================================================
--- include/groonga/db.h    2016-09-23 12:02:41 +0900 (f4fcdb9)
+++ include/groonga/db.h    2016-09-23 14:05:04 +0900 (cbfbfec)
@@ -41,6 +41,28 @@ GRN_API grn_rc grn_db_unmap(grn_ctx *ctx, grn_obj *db);
 GRN_API uint32_t grn_db_get_last_modified(grn_ctx *ctx, grn_obj *db);
 GRN_API grn_bool grn_db_is_dirty(grn_ctx *ctx, grn_obj *db);
 
+#define GRN_DB_EACH_BEGIN_FLAGS(ctx, cursor, id, flags)                 \
+  GRN_TABLE_EACH_BEGIN_FLAGS(ctx,                                       \
+                             grn_ctx_db((ctx)),                         \
+                             cursor,                                    \
+                             id,                                        \
+                             flags)
+
+#define GRN_DB_EACH_BEGIN_BY_ID(ctx, cursor, id)                        \
+  GRN_DB_EACH_BEGIN_FLAGS(ctx,                                          \
+                          cursor,                                       \
+                          id,                                           \
+                          GRN_CURSOR_BY_ID | GRN_CURSOR_ASCENDING)
+
+#define GRN_DB_EACH_BEGIN_BY_KEY(ctx, cursor, id)                       \
+  GRN_DB_EACH_BEGIN_FLAGS(ctx,                                          \
+                          cursor,                                       \
+                          id,                                           \
+                          GRN_CURSOR_BY_KEY | GRN_CURSOR_ASCENDING)
+
+#define GRN_DB_EACH_END(ctx, cursor)            \
+  GRN_TABLE_EACH_END(ctx, cursor)
+
 #ifdef __cplusplus
 }
 #endif

  Modified: lib/proc/proc_dump.c (+10 -15)
===================================================================
--- lib/proc/proc_dump.c    2016-09-23 12:02:41 +0900 (2cd19cb)
+++ lib/proc/proc_dump.c    2016-09-23 14:05:04 +0900 (3d532d8)
@@ -35,8 +35,7 @@ typedef struct {
 static void
 dumper_collect_statistics(grn_ctx *ctx, grn_dumper *dumper)
 {
-  GRN_TABLE_EACH_BEGIN_FLAGS(ctx, grn_ctx_db(ctx), cursor, id,
-                             GRN_CURSOR_BY_ID | GRN_CURSOR_ASCENDING) {
+  GRN_DB_EACH_BEGIN_BY_ID(ctx, cursor, id) {
     void *name;
     int name_size;
     grn_bool is_opened = GRN_TRUE;
@@ -116,7 +115,7 @@ next_loop :
     if (dumper->is_close_opened_object_mode && !is_opened) {
       grn_obj_close(ctx, object);
     }
-  } GRN_TABLE_EACH_END(ctx, cursor);
+  } GRN_DB_EACH_END(ctx, cursor);
 }
 
 static void
@@ -740,8 +739,7 @@ dump_table(grn_ctx *ctx, grn_dumper *dumper, grn_obj *table)
 static void
 dump_schema(grn_ctx *ctx, grn_dumper *dumper)
 {
-  GRN_TABLE_EACH_BEGIN_FLAGS(ctx, grn_ctx_db(ctx), cursor, id,
-                             GRN_CURSOR_BY_KEY | GRN_CURSOR_ASCENDING) {
+  GRN_DB_EACH_BEGIN_BY_KEY(ctx, cursor, id) {
     void *name;
     int name_size;
     grn_bool is_opened = GRN_TRUE;
@@ -781,7 +779,7 @@ dump_schema(grn_ctx *ctx, grn_dumper *dumper)
          but it's too difficult for this architecture. :< */
       GRN_PLUGIN_CLEAR_ERROR(ctx);
     }
-  } GRN_TABLE_EACH_END(ctx, cursor);
+  } GRN_DB_EACH_END(ctx, cursor);
 
   if (!dumper->have_reference_column) {
     return;
@@ -790,8 +788,7 @@ dump_schema(grn_ctx *ctx, grn_dumper *dumper)
   GRN_TEXT_PUTC(ctx, dumper->output, '\n');
   grn_ctx_output_flush(ctx, 0);
 
-  GRN_TABLE_EACH_BEGIN_FLAGS(ctx, grn_ctx_db(ctx), cursor, id,
-                             GRN_CURSOR_BY_KEY | GRN_CURSOR_ASCENDING) {
+  GRN_DB_EACH_BEGIN_BY_KEY(ctx, cursor, id) {
     void *name;
     int name_size;
     grn_bool is_opened = GRN_TRUE;
@@ -831,7 +828,7 @@ dump_schema(grn_ctx *ctx, grn_dumper *dumper)
          but it's too difficult for this architecture. :< */
       GRN_PLUGIN_CLEAR_ERROR(ctx);
     }
-  } GRN_TABLE_EACH_END(ctx, cursor);
+  } GRN_DB_EACH_END(ctx, cursor);
 }
 
 static void
@@ -896,8 +893,7 @@ dump_selected_tables_records(grn_ctx *ctx, grn_dumper *dumper, grn_obj *tables)
 static void
 dump_all_records(grn_ctx *ctx, grn_dumper *dumper)
 {
-  GRN_TABLE_EACH_BEGIN_FLAGS(ctx, grn_ctx_db(ctx), cursor, id,
-                             GRN_CURSOR_BY_ID | GRN_CURSOR_ASCENDING) {
+  GRN_DB_EACH_BEGIN_BY_ID(ctx, cursor, id) {
     void *name;
     int name_size;
     grn_bool is_opened = GRN_TRUE;
@@ -932,7 +928,7 @@ dump_all_records(grn_ctx *ctx, grn_dumper *dumper)
     if (dumper->is_close_opened_object_mode && !is_opened) {
       grn_obj_close(ctx, table);
     }
-  } GRN_TABLE_EACH_END(ctx, cursor);
+  } GRN_DB_EACH_END(ctx, cursor);
 }
 
 static void
@@ -946,8 +942,7 @@ dump_indexes(grn_ctx *ctx, grn_dumper *dumper)
     GRN_TEXT_PUTC(ctx, dumper->output, '\n');
   }
 
-  GRN_TABLE_EACH_BEGIN_FLAGS(ctx, grn_ctx_db(ctx), cursor, id,
-                             GRN_CURSOR_BY_KEY | GRN_CURSOR_ASCENDING) {
+  GRN_DB_EACH_BEGIN_BY_KEY(ctx, cursor, id) {
     void *name;
     int name_size;
     grn_bool is_opened = GRN_TRUE;
@@ -982,7 +977,7 @@ dump_indexes(grn_ctx *ctx, grn_dumper *dumper)
     if (dumper->is_close_opened_object_mode && !is_opened) {
       grn_obj_close(ctx, object);
     }
-  } GRN_TABLE_EACH_END(ctx, cursor);
+  } GRN_DB_EACH_END(ctx, cursor);
 }
 
 static grn_obj *
-------------- next part --------------
HTML����������������������������...
Download 



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