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-863: [GLib] Use GBytes to implement zero-copy
Date Thu, 20 Apr 2017 14:06:21 GMT
Repository: arrow
Updated Branches:
  refs/heads/master a68f31b0f -> 3f9b26c0e


ARROW-863: [GLib] Use GBytes to implement zero-copy

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

Closes #572 from kou/glib-buffer-use-gbytes and squashes the following commits:

dc37de3 [Kouhei Sutou] [GLib] Use GBytes to implement zero-copy


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

Branch: refs/heads/master
Commit: 3f9b26c0edc84fb0d5c121937f966553bb12c0bf
Parents: a68f31b
Author: Kouhei Sutou <kou@clear-code.com>
Authored: Thu Apr 20 10:06:15 2017 -0400
Committer: Wes McKinney <wes.mckinney@twosigma.com>
Committed: Thu Apr 20 10:06:15 2017 -0400

----------------------------------------------------------------------
 c_glib/arrow-glib/buffer.cpp | 13 +++++++------
 c_glib/arrow-glib/buffer.h   |  3 +--
 c_glib/test/test-buffer.rb   |  6 +++---
 c_glib/test/test-tensor.rb   |  2 +-
 4 files changed, 12 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/3f9b26c0/c_glib/arrow-glib/buffer.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/buffer.cpp b/c_glib/arrow-glib/buffer.cpp
index 0ec52df..9853e89 100644
--- a/c_glib/arrow-glib/buffer.cpp
+++ b/c_glib/arrow-glib/buffer.cpp
@@ -167,18 +167,19 @@ garrow_buffer_get_capacity(GArrowBuffer *buffer)
 /**
  * garrow_buffer_get_data:
  * @buffer: A #GArrowBuffer.
- * @size: (out): The number of bytes of the data.
  *
- * Returns: (array length=size): The data of the buffer.
+ * Returns: (transfer full): The data of the buffer. The data is owned by
+ *   the buffer. You should not free or modify the data.
  *
  * Since: 0.3.0
  */
-const guint8 *
-garrow_buffer_get_data(GArrowBuffer *buffer, gint64 *size)
+GBytes *
+garrow_buffer_get_data(GArrowBuffer *buffer)
 {
   auto arrow_buffer = garrow_buffer_get_raw(buffer);
-  *size = arrow_buffer->size();
-  return arrow_buffer->data();
+  auto data = g_bytes_new_static(arrow_buffer->data(),
+                                 arrow_buffer->size());
+  return data;
 }
 
 /**

http://git-wip-us.apache.org/repos/asf/arrow/blob/3f9b26c0/c_glib/arrow-glib/buffer.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/buffer.h b/c_glib/arrow-glib/buffer.h
index 1e7d551..83e1d0d 100644
--- a/c_glib/arrow-glib/buffer.h
+++ b/c_glib/arrow-glib/buffer.h
@@ -61,8 +61,7 @@ GArrowBuffer  *garrow_buffer_new          (const guint8 *data,
                                            gint64 size);
 gboolean       garrow_buffer_is_mutable   (GArrowBuffer *buffer);
 gint64         garrow_buffer_get_capacity (GArrowBuffer *buffer);
-const guint8  *garrow_buffer_get_data     (GArrowBuffer *buffer,
-                                           gint64 *size);
+GBytes        *garrow_buffer_get_data     (GArrowBuffer *buffer);
 gint64         garrow_buffer_get_size     (GArrowBuffer *buffer);
 GArrowBuffer  *garrow_buffer_get_parent   (GArrowBuffer *buffer);
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/3f9b26c0/c_glib/test/test-buffer.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-buffer.rb b/c_glib/test/test-buffer.rb
index 1ea26f2..6bb9671 100644
--- a/c_glib/test/test-buffer.rb
+++ b/c_glib/test/test-buffer.rb
@@ -32,7 +32,7 @@ class TestBuffer < Test::Unit::TestCase
   end
 
   def test_data
-    assert_equal(@data, @buffer.data.pack("C*"))
+    assert_equal(@data, @buffer.data.to_s)
   end
 
   def test_size
@@ -45,11 +45,11 @@ class TestBuffer < Test::Unit::TestCase
 
   def test_copy
     copied_buffer = @buffer.copy(1, 3)
-    assert_equal(@data[1, 3], copied_buffer.data.pack("C*"))
+    assert_equal(@data[1, 3], copied_buffer.data.to_s)
   end
 
   def test_slice
     sliced_buffer = @buffer.slice(1, 3)
-    assert_equal(@data[1, 3], sliced_buffer.data.pack("C*"))
+    assert_equal(@data[1, 3], sliced_buffer.data.to_s)
   end
 end

http://git-wip-us.apache.org/repos/asf/arrow/blob/3f9b26c0/c_glib/test/test-tensor.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-tensor.rb b/c_glib/test/test-tensor.rb
index 3e1f541..225857b 100644
--- a/c_glib/test/test-tensor.rb
+++ b/c_glib/test/test-tensor.rb
@@ -49,7 +49,7 @@ class TestTensor < Test::Unit::TestCase
   end
 
   def test_buffer
-    assert_equal(@raw_data, @tensor.buffer.data)
+    assert_equal(@raw_data, @tensor.buffer.data.to_s.unpack("c*"))
   end
 
   def test_shape


Mime
View raw message