[Groonga-commit] groonga/groonga at a587685 [master] Flush database on open only when any new object is added

アーカイブの一覧に戻る

Kouhei Sutou null+****@clear*****
Wed May 11 17:14:55 JST 2016


Kouhei Sutou	2016-05-11 17:14:55 +0900 (Wed, 11 May 2016)

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

  Message:
    Flush database on open only when any new object is added

  Modified files:
    lib/db.c

  Modified: lib/db.c (+16 -8)
===================================================================
--- lib/db.c    2016-05-11 17:10:37 +0900 (ad9d8e6)
+++ lib/db.c    2016-05-11 17:14:55 +0900 (690bc19)
@@ -408,16 +408,24 @@ grn_db_open(grn_ctx *ctx, const char *path)
   s->obj.header.domain = GRN_ID_NIL;
   DB_OBJ(&s->obj)->range = GRN_ID_NIL;
   grn_ctx_use(ctx, (grn_obj *)s);
+  {
+    unsigned int n_records;
+
+    n_records = grn_table_size(ctx, (grn_obj *)s);
 #ifdef GRN_WITH_MECAB
-  if (grn_db_init_mecab_tokenizer(ctx)) {
-    ERRCLR(ctx);
-  }
+    if (grn_db_init_mecab_tokenizer(ctx)) {
+      ERRCLR(ctx);
+    }
 #endif
-  grn_db_init_builtin_tokenizers(ctx);
-  grn_db_init_builtin_normalizers(ctx);
-  grn_db_init_builtin_scorers(ctx);
-  grn_db_init_builtin_commands(ctx);
-  grn_obj_flush(ctx, (grn_obj *)s);
+    grn_db_init_builtin_tokenizers(ctx);
+    grn_db_init_builtin_normalizers(ctx);
+    grn_db_init_builtin_scorers(ctx);
+    grn_db_init_builtin_commands(ctx);
+
+    if (grn_table_size(ctx, (grn_obj *)s) > n_records) {
+      grn_obj_flush(ctx, (grn_obj *)s);
+    }
+  }
   GRN_API_RETURN((grn_obj *)s);
 
 exit:
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る