Masafumi Yokoyama
null+****@clear*****
Tue Dec 6 16:33:47 JST 2016
Masafumi Yokoyama 2016-12-06 16:33:47 +0900 (Tue, 06 Dec 2016) New Revision: 88006ba3a5784512878960307d99e7ab0716e690 https://github.com/ranguba/groonga-client/commit/88006ba3a5784512878960307d99e7ab0716e690 Message: Support slices for command version 3 Modified files: lib/groonga/client/response/select.rb test/response/test-select-command-version3.rb Modified: lib/groonga/client/response/select.rb (+3 -1) =================================================================== --- lib/groonga/client/response/select.rb 2016-12-02 19:25:01 +0900 (6c26d7a) +++ lib/groonga/client/response/select.rb 2016-12-06 16:33:47 +0900 (5ffb40f) @@ -1,5 +1,6 @@ # Copyright (C) 2013-2016 Kouhei Sutou <kou �� clear-code.com> # Copyright (C) 2013 Kosuke Asami +# Copyright (C) 2016 Masafumi Yokoyama <yokoyama �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -67,7 +68,8 @@ module Groonga @slices = {} if body["slices"] body["slices"].each do |key, records| - @slices[key] = parse_match_records_v3(records) + n_hits, body = parse_match_records_v3(records) + @slices[key] = body end end end Modified: test/response/test-select-command-version3.rb (+62 -0) =================================================================== --- test/response/test-select-command-version3.rb 2016-12-02 19:25:01 +0900 (911b709) +++ test/response/test-select-command-version3.rb 2016-12-06 16:33:47 +0900 (952cc5d) @@ -1,5 +1,6 @@ # Copyright (C) 2013-2016 Kouhei Sutou <kou �� clear-code.com> # Copyright (C) 2013 Kosuke Asami +# Copyright (C) 2016 Masafumi Yokoyama <yokoyama �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -278,5 +279,66 @@ class TestResponseSelectCommandVersion3 < Test::Unit::TestCase values end end + + class TestSlices < self + def setup + pair_arguments = { + "slices[groonga].filter" => 'tag @ "groonga"', + } + @command = Groonga::Command::Select.new("select", pair_arguments) + @body = { + "n_hits" => 3, + "columns" => [ + { + "name" => "_id", + "type" => "UInt32" + }, + { + "name" => "tag", + "type" => "ShortText" + } + ], + "records" => [ + [1, "groonga"], + [2, "rroonga"], + [3, "groonga"], + ], + "slices" => { + "groonga" => { + "n_hits" => 2, + "columns" => [ + { + "name" => "_id", + "type" => "UInt32" + }, + { + "name" => "tag", + "type" => "ShortText" + } + ], + "records" => [ + [1, "groonga"], + [3, "groonga"], + ] + } + } + } + end + + def test_slices + assert_equal({ + "groonga" => [ + {"_id" => 1, "tag" => "groonga"}, + {"_id" => 3, "tag" => "groonga"}, + ] + }, + slices(@body)) + end + + private + def slices(body) + create_response(body).slices + end + end end end -------------- next part -------------- HTML����������������������������... 下載