[Groonga-commit] ranguba/rroonga at 09c2de2 [master] Bind Database#unmap

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Sep 8 16:54:38 JST 2015


Kouhei Sutou	2015-09-08 16:54:38 +0900 (Tue, 08 Sep 2015)

  New Revision: 09c2de26f224c58aad8e278e951500a62d4d4710
  https://github.com/ranguba/rroonga/commit/09c2de26f224c58aad8e278e951500a62d4d4710

  Message:
    Bind Database#unmap

  Modified files:
    ext/groonga/rb-grn-database.c
    test/test-database.rb

  Modified: ext/groonga/rb-grn-database.c (+33 -0)
===================================================================
--- ext/groonga/rb-grn-database.c    2015-09-02 18:39:23 +0900 (0800b55)
+++ ext/groonga/rb-grn-database.c    2015-09-08 16:54:38 +0900 (b8deac9)
@@ -593,6 +593,38 @@ rb_grn_database_recover (VALUE self)
     return Qnil;
 }
 
+/*
+ * Unmaps all mapped tables and columns in database.
+ *
+ * @overload unmap()
+ *
+ *   Unmaps all mapped tables and columns in database.
+ *
+ *   It frees resources for them.
+ *
+ *   Normally, you don't need to unmap explicitly. Because OS manages
+ *   resourced for mapped tables and columns cleverly.
+ *
+ *   @return [void]
+ *
+ * @since 5.0.5
+ */
+static VALUE
+rb_grn_database_unmap (VALUE self)
+{
+    grn_rc rc;
+    grn_ctx *context;
+    grn_obj *database;
+
+    rb_grn_database_deconstruct(SELF(self), &database, &context,
+                                NULL, NULL, NULL, NULL);
+    rc = grn_db_unmap(context, database);
+    rb_grn_context_check(context, self);
+    rb_grn_rc_check(rc, self);
+
+    return Qnil;
+}
+
 void
 rb_grn_init_database (VALUE mGrn)
 {
@@ -626,4 +658,5 @@ rb_grn_init_database (VALUE mGrn)
     rb_define_method(rb_cGrnDatabase, "touch", rb_grn_database_touch, 0);
     rb_define_method(rb_cGrnDatabase, "defrag", rb_grn_database_defrag, -1);
     rb_define_method(rb_cGrnDatabase, "recover", rb_grn_database_recover, 0);
+    rb_define_method(rb_cGrnDatabase, "unmap", rb_grn_database_unmap, 0);
 }

  Modified: test/test-database.rb (+11 -0)
===================================================================
--- test/test-database.rb    2015-09-02 18:39:23 +0900 (57680f0)
+++ test/test-database.rb    2015-09-08 16:54:38 +0900 (22209bf)
@@ -200,6 +200,17 @@ class DatabaseTest < Test::Unit::TestCase
     end
   end
 
+  def test_unmap
+    setup_database
+    Groonga::Schema.define do |schema|
+      schema.create_table("Users") do |table|
+        table.short_text("name")
+      end
+    end
+
+    @database.unmap
+  end
+
   def test_tables
     setup_database
     Groonga::Schema.define do |schema|
-------------- next part --------------
HTML����������������������������...
다운로드 



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