[groonga-dev,04358] [ANN] Rroonga 7.0.2

Back to archive index

Kouhei Sutou kou****@clear*****
2017年 4月 29日 (土) 12:05:30 JST


須藤です。

Rroonga 7.0.2をリリースしました!
  http://ranguba.org/rroonga/ja/file.news.html#version-7-0-2

Groonga 7.0.2までに入った新機能をすべてサポートしています。

たとえば、カラムのデータすべてを(Rubyレベルではなく)
Groongaレベルで高速に更新する
Groonga::DataColumn#apply_expression機能というものが入ってい
ます。

  http://ranguba.org/rroonga/ja/Groonga/DataColumn.html#apply_expression-instance_method

これを使うとRやPandasにあるデータフレームみたいなこともしや
すくなる。。。気がしています。特定のカラムの値を高速に更新で
きます。

使い方はこんな感じです。

まず、こんなスキーマがあったとします。

   Groonga::Schema.define do |schema|
     # コメントテーブル
     schema.create_table("Comments") do |table|
       # ↓のplus1カラムの値を計算するために使うカラム
       table.uint32("base")
       # ↑のbaseカラムの値を使って計算した値を保存するカラム
       table.uint32("plus1")
     end
   end
   comments = Groonga["Comments"]
   plus1 = Groonga["Comments.plus1"]

3つレコードを入れます。

   3.times do |i|
     comments.add(:base => i)
   end

この時点でCommentsテーブルはこうなっています。

_id | base | plus1
1   | 0    | 0
2   | 1    | 0
3   | 2    | 0

plus1カラムにbase + 1の値をいれます。条件をRubyで書いていま
すが、実際の処理はGroongaレベルで実行されます。Rubyレベルで
レコード毎に処理するわけではないので高速です。

   plus1.apply_expression do |record|
     record.base + 1
   end

この時点でCommentsテーブルはこうなります。

_id | base | plus1
1   | 0    | 1 (= 0 + 1)
2   | 1    | 2 (= 1 + 1)
3   | 2    | 3 (= 2 + 1)

   comments.each do |comment|
     p [comment.base, comment.plus1]
       # -> [0, 1]
       # -> [1, 2]
       # -> [2, 3]
   end

他にも、ウィンドウ関数を適用する
DataColumn#apply_window_functionにグループキーを指定できるよ
うになったり、

  http://ranguba.org/rroonga/ja/Groonga/DataColumn.html#apply_window_function-instance_method

特定のトークンのポスティングリストを取り出すことができるよう
になっています。

  http://ranguba.org/rroonga/ja/Groonga/IndexColumn.html#open_cursor-instance_method

あ、ドキュメントを更新していないや。table_cursorだけじゃなく
termも渡せるようになりました。


他の変更点はこんな感じです。

## 7.0.2: 2017-04-29 {#version-7-0-2}

### Improvements

  * Supported Groonga 7.0.2. Groonga 7.0.1 or older aren't supported.

  * {Groonga::IndexColumn#open_cursor}: Supported opening a cursor by
    token.

  * {Groonga::IndexColumn#[]}: Supported a token.

  * {Groonga::InvertedIndexCursor#closed?}: Added.

  * {Groonga::Table::KeySupport#key?}: Added.

  * {Groonga::Table::KeySupport#has_key?}: Deprecated. Use
    {Groonga::Table::KeySupport#key?} instead.

  * {Groonga::DataColumn#apply_window_function}: Supported `:group_keys`.

  * {Groonga::Column#weight_vector?}: Added.

  * {Groonga::DataColumn#apply_expression}: Added.

  * {Groonga::Column#data?}: Added.

  * {Groonga::DefaultCache}: Added.


-- 
須藤 功平 <kou****@clear*****>
株式会社クリアコード <http://www.clear-code.com/>

Groongaベースの全文検索システムを総合サポート:
  http://groonga.org/ja/support/
パッチ採用 - プログラミングが楽しい人向けの採用プロセス:
  http://www.clear-code.com/recruitment/
OSS開発支援サービス:
  http://www.clear-code.com/blog/2016/6/27.html




groonga-dev メーリングリストの案内
Back to archive index