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-746: [GLib] Add garrow_array_get_data_type()
Date Fri, 31 Mar 2017 16:59:02 GMT
Repository: arrow
Updated Branches:
  refs/heads/master e5b682760 -> 4e77d3382


ARROW-746: [GLib] Add garrow_array_get_data_type()

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

Closes #470 from kou/glib-add-garrow-array-get-data-type and squashes the following commits:

3f4de67 [Kouhei Sutou] [GLib] Add garrow_array_get_data_type()


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

Branch: refs/heads/master
Commit: 4e77d3382f6cc6450c79b1ebefea0bbd1f2dd379
Parents: e5b6827
Author: Kouhei Sutou <kou@clear-code.com>
Authored: Fri Mar 31 12:58:55 2017 -0400
Committer: Wes McKinney <wes.mckinney@twosigma.com>
Committed: Fri Mar 31 12:58:55 2017 -0400

----------------------------------------------------------------------
 c_glib/arrow-glib/array.cpp | 15 +++++++++++++++
 c_glib/arrow-glib/array.h   |  3 ++-
 c_glib/test/test-array.rb   |  6 ++++++
 3 files changed, 23 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/4e77d338/c_glib/arrow-glib/array.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/array.cpp b/c_glib/arrow-glib/array.cpp
index 5dacb07..b084054 100644
--- a/c_glib/arrow-glib/array.cpp
+++ b/c_glib/arrow-glib/array.cpp
@@ -24,6 +24,7 @@
 #include <arrow-glib/array.hpp>
 #include <arrow-glib/binary-array.h>
 #include <arrow-glib/boolean-array.h>
+#include <arrow-glib/data-type.hpp>
 #include <arrow-glib/double-array.h>
 #include <arrow-glib/float-array.h>
 #include <arrow-glib/int8-array.h>
@@ -174,6 +175,20 @@ garrow_array_get_n_nulls(GArrowArray *array)
 }
 
 /**
+ * garrow_array_get_data_type:
+ * @array: A #GArrowArray.
+ *
+ * Returns: (transfer full): The #GArrowDataType for the array.
+ */
+GArrowDataType *
+garrow_array_get_data_type(GArrowArray *array)
+{
+  auto arrow_array = garrow_array_get_raw(array);
+  auto arrow_data_type = arrow_array->type();
+  return garrow_data_type_new_raw(&arrow_data_type);
+}
+
+/**
  * garrow_array_slice:
  * @array: A #GArrowArray.
  * @offset: The offset of sub #GArrowArray.

http://git-wip-us.apache.org/repos/asf/arrow/blob/4e77d338/c_glib/arrow-glib/array.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/array.h b/c_glib/arrow-glib/array.h
index 9b1fa7e..6467db5 100644
--- a/c_glib/arrow-glib/array.h
+++ b/c_glib/arrow-glib/array.h
@@ -19,7 +19,7 @@
 
 #pragma once
 
-#include <glib-object.h>
+#include <arrow-glib/data-type.h>
 
 G_BEGIN_DECLS
 
@@ -60,6 +60,7 @@ GType          garrow_array_get_type    (void) G_GNUC_CONST;
 gint64         garrow_array_get_length  (GArrowArray *array);
 gint64         garrow_array_get_offset  (GArrowArray *array);
 gint64         garrow_array_get_n_nulls (GArrowArray *array);
+GArrowDataType *garrow_array_get_data_type(GArrowArray *array);
 GArrowArray   *garrow_array_slice       (GArrowArray *array,
                                          gint64 offset,
                                          gint64 length);

http://git-wip-us.apache.org/repos/asf/arrow/blob/4e77d338/c_glib/test/test-array.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-array.rb b/c_glib/test/test-array.rb
index d68827c..c427f02 100644
--- a/c_glib/test/test-array.rb
+++ b/c_glib/test/test-array.rb
@@ -31,6 +31,12 @@ class TestArray < Test::Unit::TestCase
     assert_equal(2, array.n_nulls)
   end
 
+  def test_data_type
+    builder = Arrow::BooleanArrayBuilder.new
+    array = builder.finish
+    assert_equal(Arrow::BooleanDataType.new, array.data_type)
+  end
+
   def test_slice
     builder = Arrow::BooleanArrayBuilder.new
     builder.append(true)


Mime
View raw message