[Groonga-commit] groonga/groonga at 5e4bb75 [master] mrb: add Database#each_table

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Feb 3 13:06:21 JST 2015


Kouhei Sutou	2015-02-03 13:06:21 +0900 (Tue, 03 Feb 2015)

  New Revision: 5e4bb759948f7b80774ffc22824f0f0d837e7d69
  https://github.com/groonga/groonga/commit/5e4bb759948f7b80774ffc22824f0f0d837e7d69

  Message:
    mrb: add Database#each_table

  Modified files:
    lib/mrb/scripts/database.rb

  Modified: lib/mrb/scripts/database.rb (+18 -0)
===================================================================
--- lib/mrb/scripts/database.rb    2015-02-03 13:05:51 +0900 (549085c)
+++ lib/mrb/scripts/database.rb    2015-02-03 13:06:21 +0900 (e69159e)
@@ -15,5 +15,23 @@ module Groonga
         cursor.close
       end
     end
+
+    def each_table(options={})
+      context = Context.instance
+      min = options[:prefix]
+      flags =
+        TableCursorFlags::ASCENDING |
+        TableCursorFlags::BY_KEY
+      flags |= TableCursorFlags::PREFIX if min
+      cursor = TableCursor.open(self, :min => min, :flags => flags)
+      begin
+        cursor.each do |id|
+          object = context[id]
+          yield(object) if object.is_a?(Table)
+        end
+      ensure
+        cursor.close
+      end
+    end
   end
 end
-------------- next part --------------
HTML����������������������������...
Download 



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