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-868: [GLib] Use GBytes to reduce copy
Date Fri, 21 Apr 2017 21:51:36 GMT
Repository: arrow
Updated Branches:
  refs/heads/master b4a75b1e1 -> 423235ccb


ARROW-868: [GLib] Use GBytes to reduce copy

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

Closes #576 from kou/glib-binary-array-use-gbytes and squashes the following commits:

7aeb799 [Kouhei Sutou] [GLib] Use GBytes to reduce copy


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

Branch: refs/heads/master
Commit: 423235ccb39737d66e1c47d119879787d9e10847
Parents: b4a75b1
Author: Kouhei Sutou <kou@clear-code.com>
Authored: Fri Apr 21 17:51:31 2017 -0400
Committer: Wes McKinney <wes.mckinney@twosigma.com>
Committed: Fri Apr 21 17:51:31 2017 -0400

----------------------------------------------------------------------
 c_glib/arrow-glib/array.cpp      | 13 +++++++------
 c_glib/arrow-glib/array.h        |  5 ++---
 c_glib/test/test-binary-array.rb |  5 +++--
 3 files changed, 12 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/423235cc/c_glib/arrow-glib/array.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/array.cpp b/c_glib/arrow-glib/array.cpp
index c86bff9..dc1386b 100644
--- a/c_glib/arrow-glib/array.cpp
+++ b/c_glib/arrow-glib/array.cpp
@@ -672,19 +672,20 @@ garrow_binary_array_class_init(GArrowBinaryArrayClass *klass)
  * garrow_binary_array_get_value:
  * @array: A #GArrowBinaryArray.
  * @i: The index of the target value.
- * @length: (out): The length of the value.
  *
- * Returns: (array length=length): The i-th value.
+ * Returns: (transfer full): The i-th value.
  */
-const guint8 *
+GBytes *
 garrow_binary_array_get_value(GArrowBinaryArray *array,
-                              gint64 i,
-                              gint32 *length)
+                              gint64 i)
 {
   auto arrow_array = garrow_array_get_raw(GARROW_ARRAY(array));
   auto arrow_binary_array =
     static_cast<arrow::BinaryArray *>(arrow_array.get());
-  return arrow_binary_array->GetValue(i, length);
+
+  int32_t length;
+  auto value = arrow_binary_array->GetValue(i, &length);
+  return g_bytes_new_static(value, length);
 }
 
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/423235cc/c_glib/arrow-glib/array.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/array.h b/c_glib/arrow-glib/array.h
index b417cdb..7406456 100644
--- a/c_glib/arrow-glib/array.h
+++ b/c_glib/arrow-glib/array.h
@@ -660,9 +660,8 @@ struct _GArrowBinaryArrayClass
 
 GType garrow_binary_array_get_type(void) G_GNUC_CONST;
 
-const guint8 *garrow_binary_array_get_value(GArrowBinaryArray *array,
-                                            gint64 i,
-                                            gint32 *length);
+GBytes *garrow_binary_array_get_value(GArrowBinaryArray *array,
+                                      gint64 i);
 
 #define GARROW_TYPE_STRING_ARRAY                \
   (garrow_string_array_get_type())

http://git-wip-us.apache.org/repos/asf/arrow/blob/423235cc/c_glib/test/test-binary-array.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-binary-array.rb b/c_glib/test/test-binary-array.rb
index 82a537e..6fe8924 100644
--- a/c_glib/test/test-binary-array.rb
+++ b/c_glib/test/test-binary-array.rb
@@ -17,9 +17,10 @@
 
 class TestBinaryArray < Test::Unit::TestCase
   def test_value
+    data = "\x00\x01\x02"
     builder = Arrow::BinaryArrayBuilder.new
-    builder.append("\x00\x01\x02")
+    builder.append(data)
     array = builder.finish
-    assert_equal([0, 1, 2], array.get_value(0))
+    assert_equal(data, array.get_value(0).to_s)
   end
 end


Mime
View raw message