arrow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject arrow git commit: ARROW-880: [GLib] Support getting raw data of primitive arrays
Date Mon, 24 Apr 2017 02:15:52 GMT
Repository: arrow
Updated Branches:
  refs/heads/master 33ac8a291 -> 95f489c4c


ARROW-880: [GLib] Support getting raw data of primitive arrays

Author: Kouhei Sutou <kou@clear-code.com>

Closes #586 from kou/glib-primitive-array-buffer and squashes the following commits:

970b109 [Kouhei Sutou] [GLib] Support getting raw data of primitive arrays


Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/95f489c4
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/95f489c4
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/95f489c4

Branch: refs/heads/master
Commit: 95f489c4c62f964cc32374686e4917774aa8aef2
Parents: 33ac8a2
Author: Kouhei Sutou <kou@clear-code.com>
Authored: Sun Apr 23 22:15:46 2017 -0400
Committer: Wes McKinney <wes.mckinney@twosigma.com>
Committed: Sun Apr 23 22:15:46 2017 -0400

----------------------------------------------------------------------
 c_glib/arrow-glib/array.cpp       | 53 +++++++++++++++-----
 c_glib/arrow-glib/array.h         | 89 +++++++++++++++++++++++++---------
 c_glib/test/test-boolean-array.rb |  9 ++++
 c_glib/test/test-double-array.rb  |  9 ++++
 c_glib/test/test-float-array.rb   |  9 ++++
 c_glib/test/test-int16-array.rb   |  9 ++++
 c_glib/test/test-int32-array.rb   |  9 ++++
 c_glib/test/test-int64-array.rb   |  9 ++++
 c_glib/test/test-int8-array.rb    |  9 ++++
 c_glib/test/test-uint16-array.rb  |  9 ++++
 c_glib/test/test-uint32-array.rb  |  9 ++++
 c_glib/test/test-uint64-array.rb  |  9 ++++
 c_glib/test/test-uint8-array.rb   |  9 ++++
 13 files changed, 208 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/95f489c4/c_glib/arrow-glib/array.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/array.cpp b/c_glib/arrow-glib/array.cpp
index 2fd0901..3ca860d 100644
--- a/c_glib/arrow-glib/array.cpp
+++ b/c_glib/arrow-glib/array.cpp
@@ -344,9 +344,40 @@ garrow_null_array_new(gint64 length)
 }
 
 
+G_DEFINE_TYPE(GArrowPrimitiveArray,             \
+              garrow_primitive_array,           \
+              GARROW_TYPE_ARRAY)
+
+static void
+garrow_primitive_array_init(GArrowPrimitiveArray *object)
+{
+}
+
+static void
+garrow_primitive_array_class_init(GArrowPrimitiveArrayClass *klass)
+{
+}
+
+/**
+ * garrow_primitive_array_get_buffer:
+ * @array: A #GArrowPrimitiveArray.
+ *
+ * Returns: (transfer full): The data of the array as #GArrowBuffer.
+ */
+GArrowBuffer *
+garrow_primitive_array_get_buffer(GArrowPrimitiveArray *array)
+{
+  auto arrow_array = garrow_array_get_raw(GARROW_ARRAY(array));
+  auto arrow_primitive_array =
+    static_cast<arrow::PrimitiveArray *>(arrow_array.get());
+  auto arrow_data = arrow_primitive_array->data();
+  return garrow_buffer_new_raw(&arrow_data);
+}
+
+
 G_DEFINE_TYPE(GArrowBooleanArray,               \
               garrow_boolean_array,             \
-              GARROW_TYPE_ARRAY)
+              GARROW_TYPE_PRIMITIVE_ARRAY)
 
 static void
 garrow_boolean_array_init(GArrowBooleanArray *object)
@@ -376,7 +407,7 @@ garrow_boolean_array_get_value(GArrowBooleanArray *array,
 
 G_DEFINE_TYPE(GArrowInt8Array,               \
               garrow_int8_array,             \
-              GARROW_TYPE_ARRAY)
+              GARROW_TYPE_PRIMITIVE_ARRAY)
 
 static void
 garrow_int8_array_init(GArrowInt8Array *object)
@@ -406,7 +437,7 @@ garrow_int8_array_get_value(GArrowInt8Array *array,
 
 G_DEFINE_TYPE(GArrowUInt8Array,               \
               garrow_uint8_array,             \
-              GARROW_TYPE_ARRAY)
+              GARROW_TYPE_PRIMITIVE_ARRAY)
 
 static void
 garrow_uint8_array_init(GArrowUInt8Array *object)
@@ -436,7 +467,7 @@ garrow_uint8_array_get_value(GArrowUInt8Array *array,
 
 G_DEFINE_TYPE(GArrowInt16Array,               \
               garrow_int16_array,             \
-              GARROW_TYPE_ARRAY)
+              GARROW_TYPE_PRIMITIVE_ARRAY)
 
 static void
 garrow_int16_array_init(GArrowInt16Array *object)
@@ -466,7 +497,7 @@ garrow_int16_array_get_value(GArrowInt16Array *array,
 
 G_DEFINE_TYPE(GArrowUInt16Array,               \
               garrow_uint16_array,             \
-              GARROW_TYPE_ARRAY)
+              GARROW_TYPE_PRIMITIVE_ARRAY)
 
 static void
 garrow_uint16_array_init(GArrowUInt16Array *object)
@@ -496,7 +527,7 @@ garrow_uint16_array_get_value(GArrowUInt16Array *array,
 
 G_DEFINE_TYPE(GArrowInt32Array,               \
               garrow_int32_array,             \
-              GARROW_TYPE_ARRAY)
+              GARROW_TYPE_PRIMITIVE_ARRAY)
 
 static void
 garrow_int32_array_init(GArrowInt32Array *object)
@@ -526,7 +557,7 @@ garrow_int32_array_get_value(GArrowInt32Array *array,
 
 G_DEFINE_TYPE(GArrowUInt32Array,               \
               garrow_uint32_array,             \
-              GARROW_TYPE_ARRAY)
+              GARROW_TYPE_PRIMITIVE_ARRAY)
 
 static void
 garrow_uint32_array_init(GArrowUInt32Array *object)
@@ -556,7 +587,7 @@ garrow_uint32_array_get_value(GArrowUInt32Array *array,
 
 G_DEFINE_TYPE(GArrowInt64Array,               \
               garrow_int64_array,             \
-              GARROW_TYPE_ARRAY)
+              GARROW_TYPE_PRIMITIVE_ARRAY)
 
 static void
 garrow_int64_array_init(GArrowInt64Array *object)
@@ -586,7 +617,7 @@ garrow_int64_array_get_value(GArrowInt64Array *array,
 
 G_DEFINE_TYPE(GArrowUInt64Array,               \
               garrow_uint64_array,             \
-              GARROW_TYPE_ARRAY)
+              GARROW_TYPE_PRIMITIVE_ARRAY)
 
 static void
 garrow_uint64_array_init(GArrowUInt64Array *object)
@@ -615,7 +646,7 @@ garrow_uint64_array_get_value(GArrowUInt64Array *array,
 
 G_DEFINE_TYPE(GArrowFloatArray,               \
               garrow_float_array,             \
-              GARROW_TYPE_ARRAY)
+              GARROW_TYPE_PRIMITIVE_ARRAY)
 
 static void
 garrow_float_array_init(GArrowFloatArray *object)
@@ -645,7 +676,7 @@ garrow_float_array_get_value(GArrowFloatArray *array,
 
 G_DEFINE_TYPE(GArrowDoubleArray,               \
               garrow_double_array,             \
-              GARROW_TYPE_ARRAY)
+              GARROW_TYPE_PRIMITIVE_ARRAY)
 
 static void
 garrow_double_array_init(GArrowDoubleArray *object)

http://git-wip-us.apache.org/repos/asf/arrow/blob/95f489c4/c_glib/arrow-glib/array.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/array.h b/c_glib/arrow-glib/array.h
index f8c6734..9bb502e 100644
--- a/c_glib/arrow-glib/array.h
+++ b/c_glib/arrow-glib/array.h
@@ -115,6 +115,51 @@ GType garrow_null_array_get_type(void) G_GNUC_CONST;
 GArrowNullArray *garrow_null_array_new(gint64 length);
 
 
+#define GARROW_TYPE_PRIMITIVE_ARRAY             \
+  (garrow_primitive_array_get_type())
+#define GARROW_PRIMITIVE_ARRAY(obj)                             \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj),                            \
+                              GARROW_TYPE_PRIMITIVE_ARRAY,      \
+                              GArrowPrimitiveArray))
+#define GARROW_PRIMITIVE_ARRAY_CLASS(klass)             \
+  (G_TYPE_CHECK_CLASS_CAST((klass),                     \
+                           GARROW_TYPE_PRIMITIVE_ARRAY, \
+                           GArrowPrimitiveArrayClass))
+#define GARROW_IS_PRIMITIVE_ARRAY(obj)                          \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),                            \
+                              GARROW_TYPE_PRIMITIVE_ARRAY))
+#define GARROW_IS_PRIMITIVE_ARRAY_CLASS(klass)                  \
+  (G_TYPE_CHECK_CLASS_TYPE((klass),                             \
+                           GARROW_TYPE_PRIMITIVE_ARRAY))
+#define GARROW_PRIMITIVE_ARRAY_GET_CLASS(obj)                   \
+  (G_TYPE_INSTANCE_GET_CLASS((obj),                             \
+                             GARROW_TYPE_PRIMITIVE_ARRAY,       \
+                             GArrowPrimitiveArrayClass))
+
+typedef struct _GArrowPrimitiveArray         GArrowPrimitiveArray;
+typedef struct _GArrowPrimitiveArrayClass    GArrowPrimitiveArrayClass;
+
+/**
+ * GArrowPrimitiveArray:
+ *
+ * It wraps `arrow::PrimitiveArray`.
+ */
+struct _GArrowPrimitiveArray
+{
+  /*< private >*/
+  GArrowArray parent_instance;
+};
+
+struct _GArrowPrimitiveArrayClass
+{
+  GArrowArrayClass parent_class;
+};
+
+GType garrow_primitive_array_get_type(void) G_GNUC_CONST;
+
+GArrowBuffer *garrow_primitive_array_get_buffer(GArrowPrimitiveArray *array);
+
+
 #define GARROW_TYPE_BOOLEAN_ARRAY               \
   (garrow_boolean_array_get_type())
 #define GARROW_BOOLEAN_ARRAY(obj)                               \
@@ -147,12 +192,12 @@ typedef struct _GArrowBooleanArrayClass    GArrowBooleanArrayClass;
 struct _GArrowBooleanArray
 {
   /*< private >*/
-  GArrowArray parent_instance;
+  GArrowPrimitiveArray parent_instance;
 };
 
 struct _GArrowBooleanArrayClass
 {
-  GArrowArrayClass parent_class;
+  GArrowPrimitiveArrayClass parent_class;
 };
 
 GType          garrow_boolean_array_get_type  (void) G_GNUC_CONST;
@@ -192,12 +237,12 @@ typedef struct _GArrowInt8ArrayClass    GArrowInt8ArrayClass;
 struct _GArrowInt8Array
 {
   /*< private >*/
-  GArrowArray parent_instance;
+  GArrowPrimitiveArray parent_instance;
 };
 
 struct _GArrowInt8ArrayClass
 {
-  GArrowArrayClass parent_class;
+  GArrowPrimitiveArrayClass parent_class;
 };
 
 GType garrow_int8_array_get_type(void) G_GNUC_CONST;
@@ -238,12 +283,12 @@ typedef struct _GArrowUInt8ArrayClass    GArrowUInt8ArrayClass;
 struct _GArrowUInt8Array
 {
   /*< private >*/
-  GArrowArray parent_instance;
+  GArrowPrimitiveArray parent_instance;
 };
 
 struct _GArrowUInt8ArrayClass
 {
-  GArrowArrayClass parent_class;
+  GArrowPrimitiveArrayClass parent_class;
 };
 
 GType garrow_uint8_array_get_type(void) G_GNUC_CONST;
@@ -284,12 +329,12 @@ typedef struct _GArrowInt16ArrayClass    GArrowInt16ArrayClass;
 struct _GArrowInt16Array
 {
   /*< private >*/
-  GArrowArray parent_instance;
+  GArrowPrimitiveArray parent_instance;
 };
 
 struct _GArrowInt16ArrayClass
 {
-  GArrowArrayClass parent_class;
+  GArrowPrimitiveArrayClass parent_class;
 };
 
 GType garrow_int16_array_get_type(void) G_GNUC_CONST;
@@ -330,12 +375,12 @@ typedef struct _GArrowUInt16ArrayClass    GArrowUInt16ArrayClass;
 struct _GArrowUInt16Array
 {
   /*< private >*/
-  GArrowArray parent_instance;
+  GArrowPrimitiveArray parent_instance;
 };
 
 struct _GArrowUInt16ArrayClass
 {
-  GArrowArrayClass parent_class;
+  GArrowPrimitiveArrayClass parent_class;
 };
 
 GType garrow_uint16_array_get_type(void) G_GNUC_CONST;
@@ -376,12 +421,12 @@ typedef struct _GArrowInt32ArrayClass    GArrowInt32ArrayClass;
 struct _GArrowInt32Array
 {
   /*< private >*/
-  GArrowArray parent_instance;
+  GArrowPrimitiveArray parent_instance;
 };
 
 struct _GArrowInt32ArrayClass
 {
-  GArrowArrayClass parent_class;
+  GArrowPrimitiveArrayClass parent_class;
 };
 
 GType garrow_int32_array_get_type(void) G_GNUC_CONST;
@@ -422,12 +467,12 @@ typedef struct _GArrowUInt32ArrayClass    GArrowUInt32ArrayClass;
 struct _GArrowUInt32Array
 {
   /*< private >*/
-  GArrowArray parent_instance;
+  GArrowPrimitiveArray parent_instance;
 };
 
 struct _GArrowUInt32ArrayClass
 {
-  GArrowArrayClass parent_class;
+  GArrowPrimitiveArrayClass parent_class;
 };
 
 GType garrow_uint32_array_get_type(void) G_GNUC_CONST;
@@ -468,12 +513,12 @@ typedef struct _GArrowInt64ArrayClass    GArrowInt64ArrayClass;
 struct _GArrowInt64Array
 {
   /*< private >*/
-  GArrowArray parent_instance;
+  GArrowPrimitiveArray parent_instance;
 };
 
 struct _GArrowInt64ArrayClass
 {
-  GArrowArrayClass parent_class;
+  GArrowPrimitiveArrayClass parent_class;
 };
 
 GType garrow_int64_array_get_type(void) G_GNUC_CONST;
@@ -514,12 +559,12 @@ typedef struct _GArrowUInt64ArrayClass    GArrowUInt64ArrayClass;
 struct _GArrowUInt64Array
 {
   /*< private >*/
-  GArrowArray parent_instance;
+  GArrowPrimitiveArray parent_instance;
 };
 
 struct _GArrowUInt64ArrayClass
 {
-  GArrowArrayClass parent_class;
+  GArrowPrimitiveArrayClass parent_class;
 };
 
 GType garrow_uint64_array_get_type(void) G_GNUC_CONST;
@@ -560,12 +605,12 @@ typedef struct _GArrowFloatArrayClass    GArrowFloatArrayClass;
 struct _GArrowFloatArray
 {
   /*< private >*/
-  GArrowArray parent_instance;
+  GArrowPrimitiveArray parent_instance;
 };
 
 struct _GArrowFloatArrayClass
 {
-  GArrowArrayClass parent_class;
+  GArrowPrimitiveArrayClass parent_class;
 };
 
 GType garrow_float_array_get_type(void) G_GNUC_CONST;
@@ -606,12 +651,12 @@ typedef struct _GArrowDoubleArrayClass    GArrowDoubleArrayClass;
 struct _GArrowDoubleArray
 {
   /*< private >*/
-  GArrowArray parent_instance;
+  GArrowPrimitiveArray parent_instance;
 };
 
 struct _GArrowDoubleArrayClass
 {
-  GArrowArrayClass parent_class;
+  GArrowPrimitiveArrayClass parent_class;
 };
 
 GType garrow_double_array_get_type(void) G_GNUC_CONST;

http://git-wip-us.apache.org/repos/asf/arrow/blob/95f489c4/c_glib/test/test-boolean-array.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-boolean-array.rb b/c_glib/test/test-boolean-array.rb
index 9cc3c94..15df1ed 100644
--- a/c_glib/test/test-boolean-array.rb
+++ b/c_glib/test/test-boolean-array.rb
@@ -16,6 +16,15 @@
 # under the License.
 
 class TestBooleanArray < Test::Unit::TestCase
+  def test_buffer
+    builder = Arrow::BooleanArrayBuilder.new
+    builder.append(true)
+    builder.append(false)
+    builder.append(true)
+    array = builder.finish
+    assert_equal([0b101].pack("C*"), array.buffer.data.to_s)
+  end
+
   def test_value
     builder = Arrow::BooleanArrayBuilder.new
     builder.append(true)

http://git-wip-us.apache.org/repos/asf/arrow/blob/95f489c4/c_glib/test/test-double-array.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-double-array.rb b/c_glib/test/test-double-array.rb
index f9c000d..c644ac6 100644
--- a/c_glib/test/test-double-array.rb
+++ b/c_glib/test/test-double-array.rb
@@ -16,6 +16,15 @@
 # under the License.
 
 class TestDoubleArray < Test::Unit::TestCase
+  def test_buffer
+    builder = Arrow::DoubleArrayBuilder.new
+    builder.append(-1.1)
+    builder.append(2.2)
+    builder.append(-4.4)
+    array = builder.finish
+    assert_equal([-1.1, 2.2, -4.4].pack("d*"), array.buffer.data.to_s)
+  end
+
   def test_value
     builder = Arrow::DoubleArrayBuilder.new
     builder.append(1.5)

http://git-wip-us.apache.org/repos/asf/arrow/blob/95f489c4/c_glib/test/test-float-array.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-float-array.rb b/c_glib/test/test-float-array.rb
index 020c705..84876f9 100644
--- a/c_glib/test/test-float-array.rb
+++ b/c_glib/test/test-float-array.rb
@@ -16,6 +16,15 @@
 # under the License.
 
 class TestFloatArray < Test::Unit::TestCase
+  def test_buffer
+    builder = Arrow::FloatArrayBuilder.new
+    builder.append(-1.1)
+    builder.append(2.2)
+    builder.append(-4.4)
+    array = builder.finish
+    assert_equal([-1.1, 2.2, -4.4].pack("f*"), array.buffer.data.to_s)
+  end
+
   def test_value
     builder = Arrow::FloatArrayBuilder.new
     builder.append(1.5)

http://git-wip-us.apache.org/repos/asf/arrow/blob/95f489c4/c_glib/test/test-int16-array.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-int16-array.rb b/c_glib/test/test-int16-array.rb
index 2aa5b0c..4b30ddd 100644
--- a/c_glib/test/test-int16-array.rb
+++ b/c_glib/test/test-int16-array.rb
@@ -16,6 +16,15 @@
 # under the License.
 
 class TestInt16Array < Test::Unit::TestCase
+  def test_buffer
+    builder = Arrow::Int16ArrayBuilder.new
+    builder.append(-1)
+    builder.append(2)
+    builder.append(-4)
+    array = builder.finish
+    assert_equal([-1, 2, -4].pack("s*"), array.buffer.data.to_s)
+  end
+
   def test_value
     builder = Arrow::Int16ArrayBuilder.new
     builder.append(-1)

http://git-wip-us.apache.org/repos/asf/arrow/blob/95f489c4/c_glib/test/test-int32-array.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-int32-array.rb b/c_glib/test/test-int32-array.rb
index 9dd6b3a..90cf022 100644
--- a/c_glib/test/test-int32-array.rb
+++ b/c_glib/test/test-int32-array.rb
@@ -16,6 +16,15 @@
 # under the License.
 
 class TestInt32Array < Test::Unit::TestCase
+  def test_buffer
+    builder = Arrow::Int32ArrayBuilder.new
+    builder.append(-1)
+    builder.append(2)
+    builder.append(-4)
+    array = builder.finish
+    assert_equal([-1, 2, -4].pack("l*"), array.buffer.data.to_s)
+  end
+
   def test_value
     builder = Arrow::Int32ArrayBuilder.new
     builder.append(-1)

http://git-wip-us.apache.org/repos/asf/arrow/blob/95f489c4/c_glib/test/test-int64-array.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-int64-array.rb b/c_glib/test/test-int64-array.rb
index 612a8b4..d302201 100644
--- a/c_glib/test/test-int64-array.rb
+++ b/c_glib/test/test-int64-array.rb
@@ -16,6 +16,15 @@
 # under the License.
 
 class TestInt64Array < Test::Unit::TestCase
+  def test_buffer
+    builder = Arrow::Int64ArrayBuilder.new
+    builder.append(-1)
+    builder.append(2)
+    builder.append(-4)
+    array = builder.finish
+    assert_equal([-1, 2, -4].pack("q*"), array.buffer.data.to_s)
+  end
+
   def test_value
     builder = Arrow::Int64ArrayBuilder.new
     builder.append(-1)

http://git-wip-us.apache.org/repos/asf/arrow/blob/95f489c4/c_glib/test/test-int8-array.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-int8-array.rb b/c_glib/test/test-int8-array.rb
index ab00996..9f28fa7 100644
--- a/c_glib/test/test-int8-array.rb
+++ b/c_glib/test/test-int8-array.rb
@@ -16,6 +16,15 @@
 # under the License.
 
 class TestInt8Array < Test::Unit::TestCase
+  def test_buffer
+    builder = Arrow::Int8ArrayBuilder.new
+    builder.append(-1)
+    builder.append(2)
+    builder.append(-4)
+    array = builder.finish
+    assert_equal([-1, 2, -4].pack("c*"), array.buffer.data.to_s)
+  end
+
   def test_value
     builder = Arrow::Int8ArrayBuilder.new
     builder.append(-1)

http://git-wip-us.apache.org/repos/asf/arrow/blob/95f489c4/c_glib/test/test-uint16-array.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-uint16-array.rb b/c_glib/test/test-uint16-array.rb
index ad85f09..82e898e 100644
--- a/c_glib/test/test-uint16-array.rb
+++ b/c_glib/test/test-uint16-array.rb
@@ -16,6 +16,15 @@
 # under the License.
 
 class TestUInt16Array < Test::Unit::TestCase
+  def test_buffer
+    builder = Arrow::UInt16ArrayBuilder.new
+    builder.append(1)
+    builder.append(2)
+    builder.append(4)
+    array = builder.finish
+    assert_equal([1, 2, 4].pack("S*"), array.buffer.data.to_s)
+  end
+
   def test_value
     builder = Arrow::UInt16ArrayBuilder.new
     builder.append(1)

http://git-wip-us.apache.org/repos/asf/arrow/blob/95f489c4/c_glib/test/test-uint32-array.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-uint32-array.rb b/c_glib/test/test-uint32-array.rb
index 59e19f3..c8be06f 100644
--- a/c_glib/test/test-uint32-array.rb
+++ b/c_glib/test/test-uint32-array.rb
@@ -16,6 +16,15 @@
 # under the License.
 
 class TestUInt32Array < Test::Unit::TestCase
+  def test_buffer
+    builder = Arrow::UInt32ArrayBuilder.new
+    builder.append(1)
+    builder.append(2)
+    builder.append(4)
+    array = builder.finish
+    assert_equal([1, 2, 4].pack("L*"), array.buffer.data.to_s)
+  end
+
   def test_value
     builder = Arrow::UInt32ArrayBuilder.new
     builder.append(1)

http://git-wip-us.apache.org/repos/asf/arrow/blob/95f489c4/c_glib/test/test-uint64-array.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-uint64-array.rb b/c_glib/test/test-uint64-array.rb
index e0195c1..03082f3 100644
--- a/c_glib/test/test-uint64-array.rb
+++ b/c_glib/test/test-uint64-array.rb
@@ -16,6 +16,15 @@
 # under the License.
 
 class TestUInt64Array < Test::Unit::TestCase
+  def test_buffer
+    builder = Arrow::UInt64ArrayBuilder.new
+    builder.append(1)
+    builder.append(2)
+    builder.append(4)
+    array = builder.finish
+    assert_equal([1, 2, 4].pack("Q*"), array.buffer.data.to_s)
+  end
+
   def test_value
     builder = Arrow::UInt64ArrayBuilder.new
     builder.append(1)

http://git-wip-us.apache.org/repos/asf/arrow/blob/95f489c4/c_glib/test/test-uint8-array.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-uint8-array.rb b/c_glib/test/test-uint8-array.rb
index 02f3470..d7464e3 100644
--- a/c_glib/test/test-uint8-array.rb
+++ b/c_glib/test/test-uint8-array.rb
@@ -16,6 +16,15 @@
 # under the License.
 
 class TestUInt8Array < Test::Unit::TestCase
+  def test_buffer
+    builder = Arrow::UInt8ArrayBuilder.new
+    builder.append(1)
+    builder.append(2)
+    builder.append(4)
+    array = builder.finish
+    assert_equal([1, 2, 4].pack("C*"), array.buffer.data.to_s)
+  end
+
   def test_value
     builder = Arrow::UInt8ArrayBuilder.new
     builder.append(1)


Mime
View raw message