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-1510: [GLib] Support cast
Date Sun, 10 Sep 2017 15:29:42 GMT
Repository: arrow
Updated Branches:
  refs/heads/master ce623a979 -> c1492bf4a


ARROW-1510: [GLib] Support cast

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

Closes #1075 from kou/glib-add-array-cast and squashes the following commits:

dead23ee [Kouhei Sutou] [GLib] Omit tests with old GObject Introspection
29a9fd81 [Kouhei Sutou] [GLib] Use GLib 2.44 or later on Travis CI
cd6a6436 [Kouhei Sutou] [GLib] Support cast


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

Branch: refs/heads/master
Commit: c1492bf4a01600c838c59ebef7dd88694cca41c3
Parents: ce623a9
Author: Kouhei Sutou <kou@clear-code.com>
Authored: Sun Sep 10 11:29:37 2017 -0400
Committer: Wes McKinney <wes.mckinney@twosigma.com>
Committed: Sun Sep 10 11:29:37 2017 -0400

----------------------------------------------------------------------
 c_glib/arrow-glib/Makefile.am             |   9 ++
 c_glib/arrow-glib/array.cpp               |  56 ++++++++++
 c_glib/arrow-glib/array.h                 |   6 +
 c_glib/arrow-glib/arrow-glib.h            |   1 +
 c_glib/arrow-glib/compute.cpp             | 145 +++++++++++++++++++++++++
 c_glib/arrow-glib/compute.h               |  39 +++++++
 c_glib/arrow-glib/compute.hpp             |  27 +++++
 c_glib/configure.ac                       |   2 +-
 c_glib/doc/reference/arrow-glib-docs.sgml |  16 +++
 c_glib/test/helper/omittable.rb           |  10 +-
 c_glib/test/test-boolean-array.rb         |   2 +-
 c_glib/test/test-buffer.rb                |   2 +-
 c_glib/test/test-cast.rb                  |  45 ++++++++
 c_glib/test/test-double-array.rb          |   2 +-
 c_glib/test/test-float-array.rb           |   2 +-
 c_glib/test/test-int16-array.rb           |   2 +-
 c_glib/test/test-tensor.rb                |   4 +-
 c_glib/test/test-uint16-array.rb          |   2 +-
 c_glib/test/test-uint32-array.rb          |   2 +-
 c_glib/test/test-uint64-array.rb          |   2 +-
 ci/travis_before_script_c_glib.sh         |   4 +
 21 files changed, 368 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/c1492bf4/c_glib/arrow-glib/Makefile.am
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/Makefile.am b/c_glib/arrow-glib/Makefile.am
index f33a8d1..fafd6d2 100644
--- a/c_glib/arrow-glib/Makefile.am
+++ b/c_glib/arrow-glib/Makefile.am
@@ -70,6 +70,9 @@ libarrow_glib_la_headers +=			\
 	reader.h				\
 	writer.h
 
+libarrow_glib_la_headers +=			\
+	compute.h
+
 libarrow_glib_la_generated_headers =		\
 	enums.h
 
@@ -108,6 +111,9 @@ libarrow_glib_la_sources +=			\
 	reader.cpp				\
 	writer.cpp
 
+libarrow_glib_la_sources +=			\
+	compute.cpp
+
 libarrow_glib_la_cpp_headers =			\
 	array.hpp				\
 	array-builder.hpp			\
@@ -138,6 +144,9 @@ libarrow_glib_la_cpp_headers +=			\
 	reader.hpp				\
 	writer.hpp
 
+libarrow_glib_la_cpp_headers +=			\
+	compute.hpp
+
 libarrow_glib_la_SOURCES =			\
 	$(libarrow_glib_la_sources)		\
 	$(libarrow_glib_la_cpp_headers)

http://git-wip-us.apache.org/repos/asf/arrow/blob/c1492bf4/c_glib/arrow-glib/array.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/array.cpp b/c_glib/arrow-glib/array.cpp
index 007f233..1bdbb0c 100644
--- a/c_glib/arrow-glib/array.cpp
+++ b/c_glib/arrow-glib/array.cpp
@@ -23,6 +23,7 @@
 
 #include <arrow-glib/array.hpp>
 #include <arrow-glib/buffer.hpp>
+#include <arrow-glib/compute.hpp>
 #include <arrow-glib/data-type.hpp>
 #include <arrow-glib/error.hpp>
 #include <arrow-glib/type.hpp>
@@ -500,6 +501,61 @@ garrow_array_to_string(GArrowArray *array, GError **error)
   }
 }
 
+/**
+ * garrow_array_cast:
+ * @array: A #GArrowArray.
+ * @target_data_type: A #GArrowDataType of cast target data.
+ * @options: (nullable): A #GArrowCastOptions.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: (nullable) (transfer full):
+ *   A newly created casted array on success, %NULL on error.
+ *
+ * Since: 0.7.0
+ */
+GArrowArray *
+garrow_array_cast(GArrowArray *array,
+                  GArrowDataType *target_data_type,
+                  GArrowCastOptions *options,
+                  GError **error)
+{
+  auto arrow_array = garrow_array_get_raw(array);
+  auto arrow_array_raw = arrow_array.get();
+  auto memory_pool = arrow::default_memory_pool();
+  arrow::compute::FunctionContext context(memory_pool);
+  auto arrow_target_data_type = garrow_data_type_get_raw(target_data_type);
+  std::shared_ptr<arrow::Array> arrow_casted_array;
+  arrow::Status status;
+  if (options) {
+    auto arrow_options = garrow_cast_options_get_raw(options);
+    status = arrow::compute::Cast(&context,
+                                  *arrow_array_raw,
+                                  arrow_target_data_type,
+                                  *arrow_options,
+                                  &arrow_casted_array);
+  } else {
+    arrow::compute::CastOptions arrow_options;
+    status = arrow::compute::Cast(&context,
+                                  *arrow_array_raw,
+                                  arrow_target_data_type,
+                                  arrow_options,
+                                  &arrow_casted_array);
+  }
+
+  if (!status.ok()) {
+    std::stringstream message;
+    message << "[array][cast] <";
+    message << arrow_array->type()->ToString();
+    message << "> -> <";
+    message << arrow_target_data_type->ToString();
+    message << ">";
+    garrow_error_check(error, status, message.str().c_str());
+    return NULL;
+  }
+
+  return garrow_array_new_raw(&arrow_casted_array);
+}
+
 
 G_DEFINE_TYPE(GArrowNullArray,               \
               garrow_null_array,             \

http://git-wip-us.apache.org/repos/asf/arrow/blob/c1492bf4/c_glib/arrow-glib/array.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/array.h b/c_glib/arrow-glib/array.h
index ebfcf43..8a61122 100644
--- a/c_glib/arrow-glib/array.h
+++ b/c_glib/arrow-glib/array.h
@@ -20,6 +20,7 @@
 #pragma once
 
 #include <arrow-glib/buffer.h>
+#include <arrow-glib/compute.h>
 #include <arrow-glib/data-type.h>
 
 G_BEGIN_DECLS
@@ -82,6 +83,11 @@ GArrowArray   *garrow_array_slice       (GArrowArray *array,
 gchar         *garrow_array_to_string   (GArrowArray *array,
                                          GError **error);
 
+GArrowArray   *garrow_array_cast        (GArrowArray *array,
+                                         GArrowDataType *target_data_type,
+                                         GArrowCastOptions *options,
+                                         GError **error);
+
 #define GARROW_TYPE_NULL_ARRAY                  \
   (garrow_null_array_get_type())
 #define GARROW_NULL_ARRAY(obj)                          \

http://git-wip-us.apache.org/repos/asf/arrow/blob/c1492bf4/c_glib/arrow-glib/arrow-glib.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/arrow-glib.h b/c_glib/arrow-glib/arrow-glib.h
index 7ab9531..f15f16d 100644
--- a/c_glib/arrow-glib/arrow-glib.h
+++ b/c_glib/arrow-glib/arrow-glib.h
@@ -23,6 +23,7 @@
 #include <arrow-glib/array-builder.h>
 #include <arrow-glib/chunked-array.h>
 #include <arrow-glib/column.h>
+#include <arrow-glib/compute.h>
 #include <arrow-glib/data-type.h>
 #include <arrow-glib/enums.h>
 #include <arrow-glib/error.h>

http://git-wip-us.apache.org/repos/asf/arrow/blob/c1492bf4/c_glib/arrow-glib/compute.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/compute.cpp b/c_glib/arrow-glib/compute.cpp
new file mode 100644
index 0000000..f7a48d1
--- /dev/null
+++ b/c_glib/arrow-glib/compute.cpp
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <arrow-glib/compute.hpp>
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: compute
+ * @section_id: compute-classes
+ * @title: Compute classes
+ * @include: arrow-glib/arrow-glib.h
+ *
+ * #GArrowCastOptions is a class to custom garrow_array_cast().
+ */
+
+typedef struct GArrowCastOptionsPrivate_ {
+  arrow::compute::CastOptions options;
+} GArrowCastOptionsPrivate;
+
+enum {
+  PROP_0,
+  PROP_ALLOW_INT_OVERFLOW
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(GArrowCastOptions,
+                           garrow_cast_options,
+                           G_TYPE_OBJECT)
+
+#define GARROW_CAST_OPTIONS_GET_PRIVATE(object) \
+  static_cast<GArrowCastOptionsPrivate *>(      \
+    garrow_cast_options_get_instance_private(   \
+      GARROW_CAST_OPTIONS(object)))
+
+static void
+garrow_cast_options_set_property(GObject *object,
+                                 guint prop_id,
+                                 const GValue *value,
+                                 GParamSpec *pspec)
+{
+  auto priv = GARROW_CAST_OPTIONS_GET_PRIVATE(object);
+
+  switch (prop_id) {
+  case PROP_ALLOW_INT_OVERFLOW:
+    priv->options.allow_int_overflow = g_value_get_boolean(value);
+    break;
+  default:
+    G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+    break;
+  }
+}
+
+static void
+garrow_cast_options_get_property(GObject *object,
+                                 guint prop_id,
+                                 GValue *value,
+                                 GParamSpec *pspec)
+{
+  auto priv = GARROW_CAST_OPTIONS_GET_PRIVATE(object);
+
+  switch (prop_id) {
+  case PROP_ALLOW_INT_OVERFLOW:
+    g_value_set_boolean(value, priv->options.allow_int_overflow);
+    break;
+  default:
+    G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+    break;
+  }
+}
+
+static void
+garrow_cast_options_init(GArrowCastOptions *object)
+{
+}
+
+static void
+garrow_cast_options_class_init(GArrowCastOptionsClass *klass)
+{
+  GParamSpec *spec;
+
+  auto gobject_class = G_OBJECT_CLASS(klass);
+
+  gobject_class->set_property = garrow_cast_options_set_property;
+  gobject_class->get_property = garrow_cast_options_get_property;
+
+  spec = g_param_spec_boolean("allow_int_overflow",
+                              "Allow int overflow",
+                              "Whether integer overflow is allowed or not",
+                              FALSE,
+                              static_cast<GParamFlags>(G_PARAM_READWRITE));
+  g_object_class_install_property(gobject_class, PROP_ALLOW_INT_OVERFLOW, spec);
+}
+
+/**
+ * garrow_cast_options_new:
+ *
+ * Returns: A newly created #GArrowCastOptions.
+ *
+ * Since: 0.7.0
+ */
+GArrowCastOptions *
+garrow_cast_options_new(void)
+{
+  auto cast_options = g_object_new(GARROW_TYPE_CAST_OPTIONS, NULL);
+  return GARROW_CAST_OPTIONS(cast_options);
+}
+
+G_END_DECLS
+
+GArrowCastOptions *
+garrow_cast_options_new_raw(arrow::compute::CastOptions *arrow_cast_options)
+{
+  auto cast_options =
+    g_object_new(GARROW_TYPE_CAST_OPTIONS,
+                 "allow-int-overflow", arrow_cast_options->allow_int_overflow,
+                 NULL);
+  return GARROW_CAST_OPTIONS(cast_options);
+}
+
+arrow::compute::CastOptions *
+garrow_cast_options_get_raw(GArrowCastOptions *cast_options)
+{
+  auto priv = GARROW_CAST_OPTIONS_GET_PRIVATE(cast_options);
+  return &(priv->options);
+}

http://git-wip-us.apache.org/repos/asf/arrow/blob/c1492bf4/c_glib/arrow-glib/compute.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/compute.h b/c_glib/arrow-glib/compute.h
new file mode 100644
index 0000000..4b944ad
--- /dev/null
+++ b/c_glib/arrow-glib/compute.h
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GARROW_TYPE_CAST_OPTIONS (garrow_cast_options_get_type())
+G_DECLARE_DERIVABLE_TYPE(GArrowCastOptions,
+                         garrow_cast_options,
+                         GARROW,
+                         CAST_OPTIONS,
+                         GObject)
+struct _GArrowCastOptionsClass
+{
+  GObjectClass parent_class;
+};
+
+GArrowCastOptions *garrow_cast_options_new(void);
+
+G_END_DECLS

http://git-wip-us.apache.org/repos/asf/arrow/blob/c1492bf4/c_glib/arrow-glib/compute.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/compute.hpp b/c_glib/arrow-glib/compute.hpp
new file mode 100644
index 0000000..bdeaad2
--- /dev/null
+++ b/c_glib/arrow-glib/compute.hpp
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+#include <arrow/compute/api.h>
+
+#include <arrow-glib/compute.h>
+
+GArrowCastOptions *garrow_cast_options_new_raw(arrow::compute::CastOptions *arrow_cast_options);
+arrow::compute::CastOptions *garrow_cast_options_get_raw(GArrowCastOptions *cast_options);

http://git-wip-us.apache.org/repos/asf/arrow/blob/c1492bf4/c_glib/configure.ac
----------------------------------------------------------------------
diff --git a/c_glib/configure.ac b/c_glib/configure.ac
index 103f11b..b4e3016 100644
--- a/c_glib/configure.ac
+++ b/c_glib/configure.ac
@@ -73,7 +73,7 @@ AC_ARG_WITH(arrow-cpp-build-dir,
   [GARROW_ARROW_CPP_BUILD_DIR="$withval"],
   [GARROW_ARROW_CPP_BUILD_DIR=""])
 if test "x$GARROW_ARROW_CPP_BUILD_DIR" = "x"; then
-  PKG_CHECK_MODULES([ARROW], [arrow])
+  PKG_CHECK_MODULES([ARROW], [arrow arrow-compute])
 else
   ARROW_INCLUDE_DIR="\$(abs_top_srcdir)/../cpp/src"
   ARROW_LIB_DIR="${GARROW_ARROW_CPP_BUILD_DIR}/${GARROW_ARROW_CPP_BUILD_TYPE}"

http://git-wip-us.apache.org/repos/asf/arrow/blob/c1492bf4/c_glib/doc/reference/arrow-glib-docs.sgml
----------------------------------------------------------------------
diff --git a/c_glib/doc/reference/arrow-glib-docs.sgml b/c_glib/doc/reference/arrow-glib-docs.sgml
index 26fd2f6..9c0475c 100644
--- a/c_glib/doc/reference/arrow-glib-docs.sgml
+++ b/c_glib/doc/reference/arrow-glib-docs.sgml
@@ -128,6 +128,22 @@
     <title>Index of deprecated API</title>
     <xi:include href="xml/api-index-deprecated.xml"><xi:fallback /></xi:include>
   </index>
+  <index id="api-index-0-7-0" role="0.7.0">
+    <title>Index of new symbols in 0.7.0</title>
+    <xi:include href="xml/api-index-0.7.0.xml"><xi:fallback /></xi:include>
+  </index>
+  <index id="api-index-0-6-0" role="0.6.0">
+    <title>Index of new symbols in 0.6.0</title>
+    <xi:include href="xml/api-index-0.6.0.xml"><xi:fallback /></xi:include>
+  </index>
+  <index id="api-index-0-5-0" role="0.5.0">
+    <title>Index of new symbols in 0.5.0</title>
+    <xi:include href="xml/api-index-0.5.0.xml"><xi:fallback /></xi:include>
+  </index>
+  <index id="api-index-0-4-0" role="0.4.0">
+    <title>Index of new symbols in 0.4.0</title>
+    <xi:include href="xml/api-index-0.4.0.xml"><xi:fallback /></xi:include>
+  </index>
   <index id="api-index-0-3-0" role="0.3.0">
     <title>Index of new symbols in 0.3.0</title>
     <xi:include href="xml/api-index-0.3.0.xml"><xi:fallback /></xi:include>

http://git-wip-us.apache.org/repos/asf/arrow/blob/c1492bf4/c_glib/test/helper/omittable.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/helper/omittable.rb b/c_glib/test/helper/omittable.rb
index a16ad32..a1c0334 100644
--- a/c_glib/test/helper/omittable.rb
+++ b/c_glib/test/helper/omittable.rb
@@ -17,12 +17,20 @@
 
 module Helper
   module Omittable
-    def require_gi(major, minor, micro)
+    def require_gi_bindings(major, minor, micro)
       return if GLib.check_binding_version?(major, minor, micro)
       message =
         "Require gobject-introspection #{major}.#{minor}.#{micro} or later: " +
         GLib::BINDING_VERSION.join(".")
       omit(message)
     end
+
+    def require_gi(major, minor, micro)
+      return if GObjectIntrospection::Version.or_later?(major, minor, micro)
+      message =
+        "Require GObject Introspection #{major}.#{minor}.#{micro} or later: " +
+        GObjectIntrospection::Version::STRING
+      omit(message)
+    end
   end
 end

http://git-wip-us.apache.org/repos/asf/arrow/blob/c1492bf4/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 622e4e9..ae22bce 100644
--- a/c_glib/test/test-boolean-array.rb
+++ b/c_glib/test/test-boolean-array.rb
@@ -44,7 +44,7 @@ class TestBooleanArray < Test::Unit::TestCase
   end
 
   def test_values
-    require_gi(3, 1, 9)
+    require_gi_bindings(3, 1, 9)
     builder = Arrow::BooleanArrayBuilder.new
     builder.append(true)
     builder.append(false)

http://git-wip-us.apache.org/repos/asf/arrow/blob/c1492bf4/c_glib/test/test-buffer.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-buffer.rb b/c_glib/test/test-buffer.rb
index 39ae631..3b02df7 100644
--- a/c_glib/test/test-buffer.rb
+++ b/c_glib/test/test-buffer.rb
@@ -51,7 +51,7 @@ class TestBuffer < Test::Unit::TestCase
   end
 
   def test_mutable_data
-    require_gi(3, 1, 2)
+    require_gi_bindings(3, 1, 2)
     assert_nil(@buffer.mutable_data)
   end
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/c1492bf4/c_glib/test/test-cast.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-cast.rb b/c_glib/test/test-cast.rb
new file mode 100644
index 0000000..f32cd83
--- /dev/null
+++ b/c_glib/test/test-cast.rb
@@ -0,0 +1,45 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestCast < Test::Unit::TestCase
+  include Helper::Buildable
+  include Helper::Omittable
+
+  def test_safe
+    require_gi(1, 42, 0)
+    data = [-1, 2, nil]
+    assert_equal(build_int32_array(data),
+                 build_int8_array(data).cast(Arrow::Int32DataType.new))
+  end
+
+  sub_test_case("allow-int-overflow") do
+    def test_default
+      require_gi(1, 42, 0)
+      assert_raise(Arrow::Error::Invalid) do
+        build_int32_array([128]).cast(Arrow::Int8DataType.new)
+      end
+    end
+
+    def test_true
+      options = Arrow::CastOptions.new
+      options.allow_int_overflow = true
+      assert_equal(build_int8_array([-128]),
+                   build_int32_array([128]).cast(Arrow::Int8DataType.new,
+                                                 options))
+    end
+  end
+end

http://git-wip-us.apache.org/repos/asf/arrow/blob/c1492bf4/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 c4a2d30..1213a5d 100644
--- a/c_glib/test/test-double-array.rb
+++ b/c_glib/test/test-double-array.rb
@@ -44,7 +44,7 @@ class TestDoubleArray < Test::Unit::TestCase
   end
 
   def test_values
-    require_gi(3, 1, 7)
+    require_gi_bindings(3, 1, 7)
     builder = Arrow::DoubleArrayBuilder.new
     builder.append(1.5)
     builder.append(3)

http://git-wip-us.apache.org/repos/asf/arrow/blob/c1492bf4/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 ce77c8b..c8e1b4d 100644
--- a/c_glib/test/test-float-array.rb
+++ b/c_glib/test/test-float-array.rb
@@ -44,7 +44,7 @@ class TestFloatArray < Test::Unit::TestCase
   end
 
   def test_values
-    require_gi(3, 1, 7)
+    require_gi_bindings(3, 1, 7)
     builder = Arrow::FloatArrayBuilder.new
     builder.append(1.5)
     builder.append(3)

http://git-wip-us.apache.org/repos/asf/arrow/blob/c1492bf4/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 8703e80..13646e0 100644
--- a/c_glib/test/test-int16-array.rb
+++ b/c_glib/test/test-int16-array.rb
@@ -44,7 +44,7 @@ class TestInt16Array < Test::Unit::TestCase
   end
 
   def test_values
-    require_gi(3, 1, 7)
+    require_gi_bindings(3, 1, 7)
     builder = Arrow::Int16ArrayBuilder.new
     builder.append(-1)
     builder.append(2)

http://git-wip-us.apache.org/repos/asf/arrow/blob/c1492bf4/c_glib/test/test-tensor.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-tensor.rb b/c_glib/test/test-tensor.rb
index bdfc657..6cead58 100644
--- a/c_glib/test/test-tensor.rb
+++ b/c_glib/test/test-tensor.rb
@@ -66,12 +66,12 @@ class TestTensor < Test::Unit::TestCase
   end
 
   def test_shape
-    require_gi(3, 1, 2)
+    require_gi_bindings(3, 1, 2)
     assert_equal(@shape, @tensor.shape)
   end
 
   def test_strides
-    require_gi(3, 1, 2)
+    require_gi_bindings(3, 1, 2)
     assert_equal([4, 2, 1], @tensor.strides)
   end
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/c1492bf4/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 1c79c99..1362c8e 100644
--- a/c_glib/test/test-uint16-array.rb
+++ b/c_glib/test/test-uint16-array.rb
@@ -44,7 +44,7 @@ class TestUInt16Array < Test::Unit::TestCase
   end
 
   def test_values
-    require_gi(3, 1, 7)
+    require_gi_bindings(3, 1, 7)
     builder = Arrow::UInt16ArrayBuilder.new
     builder.append(1)
     builder.append(2)

http://git-wip-us.apache.org/repos/asf/arrow/blob/c1492bf4/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 a4d1e32..01b3edb 100644
--- a/c_glib/test/test-uint32-array.rb
+++ b/c_glib/test/test-uint32-array.rb
@@ -44,7 +44,7 @@ class TestUInt32Array < Test::Unit::TestCase
   end
 
   def test_values
-    require_gi(3, 1, 7)
+    require_gi_bindings(3, 1, 7)
     builder = Arrow::UInt32ArrayBuilder.new
     builder.append(1)
     builder.append(2)

http://git-wip-us.apache.org/repos/asf/arrow/blob/c1492bf4/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 b7f9c40..a002af2 100644
--- a/c_glib/test/test-uint64-array.rb
+++ b/c_glib/test/test-uint64-array.rb
@@ -44,7 +44,7 @@ class TestUInt64Array < Test::Unit::TestCase
   end
 
   def test_values
-    require_gi(3, 1, 7)
+    require_gi_bindings(3, 1, 7)
     builder = Arrow::UInt64ArrayBuilder.new
     builder.append(1)
     builder.append(2)

http://git-wip-us.apache.org/repos/asf/arrow/blob/c1492bf4/ci/travis_before_script_c_glib.sh
----------------------------------------------------------------------
diff --git a/ci/travis_before_script_c_glib.sh b/ci/travis_before_script_c_glib.sh
index 7ab8e2e..6799ae4 100755
--- a/ci/travis_before_script_c_glib.sh
+++ b/ci/travis_before_script_c_glib.sh
@@ -26,6 +26,10 @@ if [ $TRAVIS_OS_NAME == "osx" ]; then
   brew upgrade git cmake wget libtool
 
   export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/opt/libffi/lib/pkgconfig
+else
+  sudo apt-add-repository -y ppa:jonathonf/gtk3.18
+  sudo apt-get update
+  sudo apt-get install -V -y libglib2.0-dev
 fi
 
 gem install test-unit gobject-introspection


Mime
View raw message