Kouhei Sutou
null+****@clear*****
Fri Feb 10 23:45:16 JST 2017
Kouhei Sutou 2017-02-10 23:45:16 +0900 (Fri, 10 Feb 2017) New Revision: ff0877f376fc2e17dcbd0bb82a29157bb77d03ca https://github.com/ranguba/rroonga/commit/ff0877f376fc2e17dcbd0bb82a29157bb77d03ca Message: Add TableKeySupport#key? TableKeySupport#has_key? is deprecated. Because Ruby's Hash does so. Modified files: ext/groonga/rb-grn-table-key-support.c test/test-double-array-trie.rb test/test-hash.rb test/test-patricia-trie.rb Modified: ext/groonga/rb-grn-table-key-support.c (+6 -0) =================================================================== --- ext/groonga/rb-grn-table-key-support.c 2017-02-10 16:07:24 +0900 (e8569b3) +++ ext/groonga/rb-grn-table-key-support.c 2017-02-10 23:45:16 +0900 (ec13e59) @@ -356,7 +356,11 @@ rb_grn_table_key_support_get_key (VALUE self, VALUE rb_id) /* * テーブルに主キーが _key_ のレコードがあるならtrueを返す。 * + * @overload key?(key) + * @since 7.0.0 + * * @overload has_key?(key) + * @deprecated Use {key?} instead. */ static VALUE rb_grn_table_key_support_has_key (VALUE self, VALUE rb_key) @@ -1123,6 +1127,8 @@ rb_grn_init_table_key_support (VALUE mGrn) rb_grn_table_key_support_get_id, -1); rb_define_method(rb_mGrnTableKeySupport, "key", rb_grn_table_key_support_get_key, 1); + rb_define_method(rb_mGrnTableKeySupport, "key?", + rb_grn_table_key_support_has_key, 1); rb_define_method(rb_mGrnTableKeySupport, "has_key?", rb_grn_table_key_support_has_key, 1); Modified: test/test-double-array-trie.rb (+7 -0) =================================================================== --- test/test-double-array-trie.rb 2017-02-10 16:07:24 +0900 (5918b68) +++ test/test-double-array-trie.rb 2017-02-10 23:45:16 +0900 (c195a85) @@ -123,6 +123,13 @@ class DoubleArrayTrieTest < Test::Unit::TestCase assert_true(users.has_key?("morita")) end + def test_key? + users = Groonga::DoubleArrayTrie.create(:name => "Users") + assert_false(users.key?("morita")) + users.add("morita") + assert_true(users.key?("morita")) + end + def test_prefix_cursor paths = Groonga::DoubleArrayTrie.create(:name => "Paths", :key_type => 'ShortText') Modified: test/test-hash.rb (+7 -0) =================================================================== --- test/test-hash.rb 2017-02-10 16:07:24 +0900 (ab532bf) +++ test/test-hash.rb 2017-02-10 23:45:16 +0900 (8b2067c) @@ -280,6 +280,13 @@ class HashTest < Test::Unit::TestCase index.search("engine").collect {|record| record.key.key}) end + def test_key? + users = Groonga::Hash.create(:name => "Users") + assert_false(users.key?("morita")) + users.add("morita") + assert_true(users.key?("morita")) + end + def test_has_key? users = Groonga::Hash.create(:name => "Users") assert_false(users.has_key?("morita")) Modified: test/test-patricia-trie.rb (+7 -0) =================================================================== --- test/test-patricia-trie.rb 2017-02-10 16:07:24 +0900 (066cd16) +++ test/test-patricia-trie.rb 2017-02-10 23:45:16 +0900 (57e49ec) @@ -124,6 +124,13 @@ class PatriciaTrieTest < Test::Unit::TestCase end end + def test_key? + users = Groonga::PatriciaTrie.create(:name => "Users") + assert_false(users.key?("morita")) + users.add("morita") + assert_true(users.key?("morita")) + end + def test_has_key? users = Groonga::PatriciaTrie.create(:name => "Users") assert_false(users.has_key?("morita")) -------------- next part -------------- HTML����������������������������...Download