[Groonga-commit] ranguba/rroonga at f3730d3 [master] Add Column#data?

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Apr 25 16:21:34 JST 2017


Kouhei Sutou	2017-04-25 16:21:34 +0900 (Tue, 25 Apr 2017)

  New Revision: f3730d3564b635b7c5bdcaf69f0b45b4bbeee286
  https://github.com/ranguba/rroonga/commit/f3730d3564b635b7c5bdcaf69f0b45b4bbeee286

  Message:
    Add Column#data?

  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 (+21 -0)
===================================================================
--- ext/groonga/rb-grn-column.c    2017-04-25 16:17:08 +0900 (c3009b9)
+++ ext/groonga/rb-grn-column.c    2017-04-25 16:21:34 +0900 (e9f7a87)
@@ -707,6 +707,26 @@ rb_grn_column_scalar_p (VALUE self)
 }
 
 /*
+ * @overload data?
+ *   @return [Bool] `true` if the column is a data column (a scalar
+ *   column or a vector column), `false` otherwise.
+ *
+ * @since 7.0.2
+ */
+static VALUE
+rb_grn_column_data_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_data_column(context, column));
+}
+
+/*
  * @overload with_weight?
  * @return [Boolean] @true@ if the column is vector and created with
  *   @:with_weight => true@ flag, @false@ otherwise.
@@ -857,6 +877,7 @@ rb_grn_init_column (VALUE mGrn)
     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, "data?", rb_grn_column_data_p, 0);
 
     rb_define_method(rb_cGrnColumn, "with_weight?",
                      rb_grn_column_with_weight_p, 0);

  Modified: test/test-fix-size-column.rb (+6 -0)
===================================================================
--- test/test-fix-size-column.rb    2017-04-25 16:17:08 +0900 (ef5d09e)
+++ test/test-fix-size-column.rb    2017-04-25 16:21:34 +0900 (bae7887)
@@ -138,6 +138,12 @@ class FixSizeColumnTest < Test::Unit::TestCase
       assert_predicate(@n_viewed, :scalar?)
     end
 
+    def test_data?
+      assert do
+        @n_viewed.data?
+      end
+    end
+
     def test_inspect
       assert_equal("#<Groonga::FixSizeColumn " +
                    "id: <#{@n_viewed.id}>, " +

  Modified: test/test-index-column.rb (+6 -0)
===================================================================
--- test/test-index-column.rb    2017-04-25 16:17:08 +0900 (5bff624)
+++ test/test-index-column.rb    2017-04-25 16:21:34 +0900 (ffa4fb2)
@@ -57,6 +57,12 @@ class IndexColumnTest < Test::Unit::TestCase
     def test_scalar?
       assert_not_predicate(@index, :scalar?)
     end
+
+    def test_data?
+      assert do
+        not****@index*****?
+      end
+    end
   end
 
   class CRUDTest < self

  Modified: test/test-variable-size-column.rb (+6 -0)
===================================================================
--- test/test-variable-size-column.rb    2017-04-25 16:17:08 +0900 (21b5ac2)
+++ test/test-variable-size-column.rb    2017-04-25 16:21:34 +0900 (f1c6b6d)
@@ -79,6 +79,12 @@ class VariableSizeColumnTest < Test::Unit::TestCase
     assert_not_predicate(@nick_names, :scalar?)
   end
 
+  def test_data?
+    assert do
+      @nick_names.data?
+    end
+  end
+
   def test_compressed?
     description =****@users*****_column("description", "ShortText",
                                        :compress => :zlib)
-------------- next part --------------
HTML����������������������������...
下載 



More information about the Groonga-commit mailing list
Back to archive index