[Groonga-commit] groonga/groonga at a330af9 [master] grn_db_unmap(): add

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Aug 7 16:47:51 JST 2015


Kouhei Sutou	2015-08-07 16:47:51 +0900 (Fri, 07 Aug 2015)

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

  Message:
    grn_db_unmap(): add
    
    It just closes all opened table and columns.
    
    This is a thread unsafe operation. You can't touch the database from
    other thread while grn_db_unmap() is running.

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

  Modified: include/groonga/groonga.h (+1 -0)
===================================================================
--- include/groonga/groonga.h    2015-08-07 16:19:50 +0900 (ebae344)
+++ include/groonga/groonga.h    2015-08-07 16:47:51 +0900 (96a2916)
@@ -434,6 +434,7 @@ GRN_API grn_obj *grn_db_create(grn_ctx *ctx, const char *path, grn_db_create_opt
 GRN_API grn_obj *grn_db_open(grn_ctx *ctx, const char *path);
 GRN_API void grn_db_touch(grn_ctx *ctx, grn_obj *db);
 GRN_API grn_rc grn_db_recover(grn_ctx *ctx, grn_obj *db);
+GRN_API grn_rc grn_db_unmap(grn_ctx *ctx, grn_obj *db);
 
 GRN_API grn_rc grn_ctx_use(grn_ctx *ctx, grn_obj *db);
 GRN_API grn_obj *grn_ctx_db(grn_ctx *ctx);

  Modified: lib/db.c (+36 -0)
===================================================================
--- lib/db.c    2015-08-07 16:19:50 +0900 (b1f9867)
+++ lib/db.c    2015-08-07 16:47:51 +0900 (c602a12)
@@ -12850,6 +12850,42 @@ grn_db_recover(grn_ctx *ctx, grn_obj *db)
 }
 
 grn_rc
+grn_db_unmap(grn_ctx *ctx, grn_obj *db)
+{
+  grn_id id;
+  db_value *vp;
+  grn_db *s = (grn_db *)db;
+
+  GRN_API_ENTER;
+
+  GRN_TINY_ARRAY_EACH(&s->values, 1, grn_db_curr_id(ctx, db), id, vp, {
+    grn_obj *obj = vp->ptr;
+
+    if (!obj) {
+      continue;
+    }
+
+    switch (obj->header.type) {
+    case GRN_TABLE_HASH_KEY :
+    case GRN_TABLE_PAT_KEY :
+    case GRN_TABLE_DAT_KEY :
+    case GRN_TABLE_NO_KEY :
+    case GRN_COLUMN_FIX_SIZE :
+    case GRN_COLUMN_VAR_SIZE :
+    case GRN_COLUMN_INDEX :
+      grn_obj_close(ctx, obj);
+      break;
+    }
+
+    if (ctx->rc != GRN_SUCCESS) {
+      break;
+    }
+  });
+
+  GRN_API_RETURN(ctx->rc);
+}
+
+grn_rc
 grn_ctx_get_all_tables(grn_ctx *ctx, grn_obj *tables_buffer)
 {
   grn_obj *db;
-------------- next part --------------
HTML����������������������������...
Download 



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