Kouhei Sutou
null+****@clear*****
Tue Apr 25 15:47:19 JST 2017
Kouhei Sutou 2017-04-25 15:47:19 +0900 (Tue, 25 Apr 2017) New Revision: 2e9786d9c04bb451491dd6448c53e3bfcb64eb46 https://github.com/ranguba/rroonga/commit/2e9786d9c04bb451491dd6448c53e3bfcb64eb46 Message: Add Column#weight_vector? Modified files: ext/groonga/rb-grn-column.c test/test-fix-size-column.rb test/test-index-column.rb test/test-variable-size-column.rb Modified: ext/groonga/rb-grn-column.c (+22 -0) =================================================================== --- ext/groonga/rb-grn-column.c 2017-04-25 15:42:52 +0900 (777764d) +++ ext/groonga/rb-grn-column.c 2017-04-25 15:47:19 +0900 (c3009b9) @@ -655,6 +655,26 @@ rb_grn_column_vector_p (VALUE self) } /* + * @overload weight_vector? + * @return [Bool] `true` if the column is a weight vector column, + * `false` otherwise. + * + * @since 7.0.2 + */ +static VALUE +rb_grn_column_weight_vector_p (VALUE self) +{ + grn_ctx *context; + grn_obj *column; + + rb_grn_column_deconstruct(SELF(self), &column, &context, + NULL, NULL, + NULL, NULL, NULL); + + return CBOOL2RVAL(grn_obj_is_weight_vector_column(context, column)); +} + +/* * _column_ がスカラーカラムの場合は +true+ を返し、 * そうでない場合は +false+ を返す。 * @@ -834,6 +854,8 @@ rb_grn_init_column (VALUE mGrn) /* deprecated: backward compatibility */ rb_define_alias(rb_cGrnColumn, "index_column?", "index?"); rb_define_method(rb_cGrnColumn, "vector?", rb_grn_column_vector_p, 0); + rb_define_method(rb_cGrnColumn, "weight_vector?", + rb_grn_column_weight_vector_p, 0); rb_define_method(rb_cGrnColumn, "scalar?", rb_grn_column_scalar_p, 0); rb_define_method(rb_cGrnColumn, "with_weight?", Modified: test/test-fix-size-column.rb (+6 -0) =================================================================== --- test/test-fix-size-column.rb 2017-04-25 15:42:52 +0900 (976f07b) +++ test/test-fix-size-column.rb 2017-04-25 15:47:19 +0900 (ef5d09e) @@ -128,6 +128,12 @@ class FixSizeColumnTest < Test::Unit::TestCase assert_not_predicate(@n_viewed, :vector?) end + def test_weight_vector? + assert do + not @n_viewed.weight_vector? + end + end + def test_scalar? assert_predicate(@n_viewed, :scalar?) end Modified: test/test-index-column.rb (+6 -0) =================================================================== --- test/test-index-column.rb 2017-04-25 15:42:52 +0900 (d80a701) +++ test/test-index-column.rb 2017-04-25 15:47:19 +0900 (5bff624) @@ -48,6 +48,12 @@ class IndexColumnTest < Test::Unit::TestCase assert_not_predicate(@index, :vector?) end + def test_weight_vector? + assert do + not****@index*****_vector? + end + end + def test_scalar? assert_not_predicate(@index, :scalar?) end Modified: test/test-variable-size-column.rb (+13 -0) =================================================================== --- test/test-variable-size-column.rb 2017-04-25 15:42:52 +0900 (a5ba88f) +++ test/test-variable-size-column.rb 2017-04-25 15:47:19 +0900 (21b5ac2) @@ -46,6 +46,13 @@ class VariableSizeColumnTest < Test::Unit::TestCase @users.define_column("nick_names", "ShortText", :type => :vector, :path => @users_nick_names_column_path.to_s) + + @users_tags_column_path = @columns_dir + "tags" + @tags = + @users.define_column("tags", "ShortText", + :type => :vector, + :with_weight => true, + :path => @users_tags_column_path.to_s) end def setup_users @@ -62,6 +69,12 @@ class VariableSizeColumnTest < Test::Unit::TestCase assert_predicate(@nick_names, :vector?) end + def test_weigth_vector? + assert do + @tags.weight_vector? + end + end + def test_scalar? assert_not_predicate(@nick_names, :scalar?) end -------------- next part -------------- HTML����������������������������... Descargar