Kouhei Sutou
null+****@clear*****
Fri Jan 10 19:07:21 JST 2014
Kouhei Sutou 2014-01-10 19:07:21 +0900 (Fri, 10 Jan 2014) New Revision: 203846b86a5195fe460a3e6f369509e03bf5f1c6 https://github.com/ranguba/rroonga/commit/203846b86a5195fe460a3e6f369509e03bf5f1c6 Message: Add Table#support_value? Modified files: ext/groonga/rb-grn-table.c test/test-array.rb test/test-double-array-trie.rb test/test-hash.rb test/test-patricia-trie.rb Modified: ext/groonga/rb-grn-table.c (+20 -0) =================================================================== --- ext/groonga/rb-grn-table.c 2014-01-10 18:48:08 +0900 (271a2a9) +++ ext/groonga/rb-grn-table.c 2014-01-10 19:07:21 +0900 (486f6ed) @@ -2283,6 +2283,24 @@ rb_grn_table_support_key_p (VALUE self) } /* + * @overload support_value? + * + * @return @true@ if the table is created with value type, @false@ + * otherwise. + */ +static VALUE +rb_grn_table_support_value_p (VALUE self) +{ + grn_id range_id; + + rb_grn_table_deconstruct(SELF(self), NULL, NULL, + NULL, NULL, + NULL, &range_id, NULL, + NULL); + return CBOOL2RVAL(range_id != GRN_ID_NIL); +} + +/* * グループ化したとき、テーブルにグループに含まれるレコード * 数を格納できる場合は +true+ 、格納できない場合は +false+ を返 * す。 @@ -2503,6 +2521,8 @@ rb_grn_init_table (VALUE mGrn) rb_define_method(rb_cGrnTable, "support_key?", rb_grn_table_support_key_p, 0); + rb_define_method(rb_cGrnTable, "support_value?", + rb_grn_table_support_value_p, 0); rb_define_method(rb_cGrnTable, "support_sub_records?", rb_grn_table_support_sub_records_p, 0); rb_define_method(rb_cGrnTable, "have_n_sub_records_space?", Modified: test/test-array.rb (+13 -0) =================================================================== --- test/test-array.rb 2014-01-10 18:48:08 +0900 (b0622b2) +++ test/test-array.rb 2014-01-10 19:07:21 +0900 (bc801a1) @@ -22,6 +22,19 @@ class ArrayTest < Test::Unit::TestCase assert_not_predicate(Groonga::Array.create(:name => "Users"), :support_key?) end + class SupportValueTest < self + def test_have_value_type + assert_predicate(Groonga::Array.create(:name => "Users", + :value_type => "Int32"), + :support_value?) + end + + def test_no_value_type + assert_not_predicate(Groonga::Array.create(:name => "Users"), + :support_value?) + end + end + def test_inspect_size path = @tables_dir + "named.groonga" contain_table = Groonga::Array.create(:name => "name", :path => path.to_s) Modified: test/test-double-array-trie.rb (+15 -0) =================================================================== --- test/test-double-array-trie.rb 2014-01-10 18:48:08 +0900 (36b276d) +++ test/test-double-array-trie.rb 2014-01-10 19:07:21 +0900 (c689ebf) @@ -27,6 +27,21 @@ class DoubleArrayTrieTest < Test::Unit::TestCase :support_key?) end + class SupportValueTest < self + def test_have_value_type + assert_predicate(Groonga::DoubleArrayTrie.create(:name => "Users", + :key_type => "ShortText", + :value_type => "Int32"), + :support_value?) + end + + def test_no_value_type + assert_not_predicate(Groonga::DoubleArrayTrie.create(:name => "Users", + :key_type => "ShortText"), + :support_value?) + end + end + def test_encoding assert_equal(Groonga::Encoding.default, Groonga::DoubleArrayTrie.create.encoding) Modified: test/test-hash.rb (+15 -0) =================================================================== --- test/test-hash.rb 2014-01-10 18:48:08 +0900 (1744cf4) +++ test/test-hash.rb 2014-01-10 19:07:21 +0900 (0ed307e) @@ -26,6 +26,21 @@ class HashTest < Test::Unit::TestCase :support_key?) end + class SupportValueTest < self + def test_have_value_type + assert_predicate(Groonga::Hash.create(:name => "Users", + :key_type => "ShortText", + :value_type => "Int32"), + :support_value?) + end + + def test_no_value_type + assert_not_predicate(Groonga::Hash.create(:name => "Users", + :key_type => "ShortText"), + :support_value?) + end + end + class DeleteTest < self setup def setup_data Modified: test/test-patricia-trie.rb (+15 -0) =================================================================== --- test/test-patricia-trie.rb 2014-01-10 18:48:08 +0900 (c1ea8f3) +++ test/test-patricia-trie.rb 2014-01-10 19:07:21 +0900 (d167bd2) @@ -27,6 +27,21 @@ class PatriciaTrieTest < Test::Unit::TestCase :support_key?) end + class SupportValueTest < self + def test_have_value_type + assert_predicate(Groonga::PatriciaTrie.create(:name => "Users", + :key_type => "ShortText", + :value_type => "Int32"), + :support_value?) + end + + def test_no_value_type + assert_not_predicate(Groonga::PatriciaTrie.create(:name => "Users", + :key_type => "ShortText"), + :support_value?) + end + end + def test_encoding assert_equal(Groonga::Encoding.default, Groonga::PatriciaTrie.create.encoding) -------------- next part -------------- HTML����������������������������... Download