From: Kouhei S. <ko...@cl...> - 2013-07-05 05:28:32
|
Hi, Rroonga 3.0.4 has been released! Rroonga is the Ruby bindings for groonga. Web: http://ranguba.org/ja/#about-rroonga About rroonga ------------- Here are two important things by rroonga. 1. Providing *Ruby-ish* API to use groonga. 2. Providing *fast* operations like groonga. They means that rroonga provides easy to use API without decreasing groonga's speed. About this release ------------------ In this release, rroonga supports the sub record feature that is introduced since groonga 3.0.5. The sub record feature is getting grouped records (= sub records) after group operation is performed. For example, you can display concrete items around drilldown by genre: * Book (1238) * Ruby (29件) <- A genre * Programming Ruby <- A sub record! * Metaprogramming Ruby <- A sub record! * ... * Python (13) <- A genre * ... * PHP (23) <- A genre * ... Here is an example. See comments for details. ---- require "fileutils" require "groonga" db_dir = "/tmp/db" FileUtils.rm_rf(db_dir) FileUtils.mkdir_p(db_dir) Groonga::Database.create(:path => "#{db_dir}/db") # The schema for a user can bookmark one or more sites. Groonga::Schema.define do |schema| schema.create_table("Users", :type => :hash, :key_type => :short_text) do |table| table.short_text("name") end schema.create_table("Bookmarks") do |table| table.short_text("url") table.reference("user") end end # Register three users. users = Groonga["Users"] users.add("mori", :name => "Daijiro MORI") users.add("kou", :name => "Kouhei Sutou") users.add("s-yata", :name => "Susumu Yata") bookmarks = Groonga["Bookmarks"] # Bookmarks groonga.org. bookmarks.add(:url => "http://groonga.org/", :user => "mori") bookmarks.add(:url => "http://groonga.org/", :user => "kou") bookmarks.add(:url => "http://groonga.org/", :user => "s-yata") # Bookmarks mroonga.org. bookmarks.add(:url => "http://mroonga.org/", :user => "kou") # Bookmarks ranguba.org. bookmarks.add(:url => "http://ranguba.org/", :user => "kou") bookmarks.add(:url => "http://ranguba.org/", :user => "mori") # Groups bookmarks by user. # The max number of sub records to be got is 2. bookmarks.group("user", :max_n_sub_records => 2).each do |group| # Gets the actual value (= a user) from grouped result record. user = group.key # Displays user id (= key) and the number of sub records. # The number of sub records isn't effected by :max_n_sub_records => 2. puts "#{user.key} (#{group.n_sub_records})" # Displays information about each record (= a sub record). # A sub record is bookmark record because bookmarks table # is grouped. # The max number of sub records is 2 # because、:max_n_sub_records => 2 restricts it. group.sub_records.each do |bookmark| puts " #{bookmark.url}" end end # Result: # mori (2) # http://groonga.org/ # http://ranguba.org/ # kou (3) # http://groonga.org/ # http://mroonga.org/ # s-yata (1) # http://groonga.org/ # # kou user has 3 sub records but 2 sub records are only # displayed because :max_n_sub_records => 2 restricts it. ---- Install ------- % gem install rroonga Tutorial -------- There are a tutorial that uses irb: http://ranguba.org/rroonga/en/file.tutorial.html If you are are beginner, please try it. Here are changes since 3.0.2: http://ranguba.org/rroonga/ja/file.news.html#3-0-4 3.0.4: 2013-07-04 ----------------- Fixes ^^^^^ * Fixed a rroogna 3.0.3 gem package for Windows. 3.0.3: 2013-07-04 ----------------- Improvements ^^^^^^^^^^^^ * Required groonga >= 3.0.5. * Added an error check for creating a result table of {Groonga::Table#select}. * Added {Groonga::Operator::AND_NOT}. * Deprecated {Groonga::Operator::BUT} because groonga deprecated it. Use {Groonga::Operator::AND_NOT} instead. * Added {Groonga::Array#unblock}. * Added @:max_n_sub_records@ option to {Groonga::Table#group}. * Added {Groonga::Table#each_sub_record}. * Supported groonga to Ruby conversion for vector value. * Added @:reference => true@ option to {Groonga::Expression#define_variable} that defines reference type variable. * Added {Groonga::Record#sub_records} that returns sub records for the record. Sub records is a {Groonga::SubRecords} instance. Fixes ^^^^^ * Fixed {Groonga::Expression#[]} return type. It returns {Groonga::Variable} instead of value itself. CAUTION: It is a backward incompatible change. Thanks, -- kou |