[ 
https://issues.apache.org/jira/browse/ARROW-2146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16362221#comment-16362221
 ] 

ASF GitHub Bot commented on ARROW-2146:
---------------------------------------

xhochy closed pull request #1600: ARROW-2146: [GLib] Add Slice api to 
ChunkedArray
URL: https://github.com/apache/arrow/pull/1600
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/c_glib/arrow-glib/chunked-array.cpp 
b/c_glib/arrow-glib/chunked-array.cpp
index 69195c57b..a4f817559 100644
--- a/c_glib/arrow-glib/chunked-array.cpp
+++ b/c_glib/arrow-glib/chunked-array.cpp
@@ -274,6 +274,26 @@ garrow_chunked_array_get_chunks(GArrowChunkedArray 
*chunked_array)
   return g_list_reverse(chunks);
 }
 
+/**
+ * garrow_chunked_array_slice:
+ * @chunked_array: A #GArrowChunkedArray.
+ * @offset: The offset of sub #GArrowChunkedArray.
+ * @length: The length of sub #GArrowChunkedArray.
+ *
+ * Returns: (transfer full): The sub #GArrowChunkedArray. It covers only from
+ *   `offset` to `offset + length` range. The sub #GArrowChunkedArray shares
+ *   values with the base #GArrowChunkedArray.
+ */
+GArrowChunkedArray  *
+garrow_chunked_array_slice(GArrowChunkedArray *chunked_array,
+                           guint64 offset,
+                           guint64 length)
+{
+  const auto arrow_chunked_array = garrow_chunked_array_get_raw(chunked_array);
+  auto arrow_sub_chunked_array = arrow_chunked_array->Slice(offset, length);
+  return garrow_chunked_array_new_raw(&arrow_sub_chunked_array);
+}
+
 G_END_DECLS
 
 GArrowChunkedArray *
diff --git a/c_glib/arrow-glib/chunked-array.h 
b/c_glib/arrow-glib/chunked-array.h
index 0c3c81a74..d109150d2 100644
--- a/c_glib/arrow-glib/chunked-array.h
+++ b/c_glib/arrow-glib/chunked-array.h
@@ -82,5 +82,8 @@ guint   garrow_chunked_array_get_n_chunks (GArrowChunkedArray 
*chunked_array);
 GArrowArray *garrow_chunked_array_get_chunk(GArrowChunkedArray *chunked_array,
                                             guint i);
 GList *garrow_chunked_array_get_chunks(GArrowChunkedArray *chunked_array);
+GArrowChunkedArray *garrow_chunked_array_slice(GArrowChunkedArray 
*chunked_array,
+                                               guint64 offset,
+                                               guint64 length);
 
 G_END_DECLS
diff --git a/c_glib/test/test-chunked-array.rb 
b/c_glib/test/test-chunked-array.rb
index 4f6a4fb0d..252e1e2bb 100644
--- a/c_glib/test/test-chunked-array.rb
+++ b/c_glib/test/test-chunked-array.rb
@@ -95,4 +95,18 @@ def test_chunks
     assert_equal([2, 1],
                  chunked_array.chunks.collect(&:length))
   end
+
+  def test_slice
+    chunks1 = [
+      build_boolean_array([true, false, true]),
+      build_boolean_array([false, true]),
+    ]
+    chunks2 = [
+      build_boolean_array([false, true]),
+      build_boolean_array([false]),
+    ]
+    chunked_array = Arrow::ChunkedArray.new(chunks1)
+    sub_chunked_array = chunked_array.slice(1, 3)
+    assert_equal(chunks2, sub_chunked_array.chunks)
+  end
 end


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> [GLib] Implement Slice for ChunkedArray
> ---------------------------------------
>
>                 Key: ARROW-2146
>                 URL: https://issues.apache.org/jira/browse/ARROW-2146
>             Project: Apache Arrow
>          Issue Type: Improvement
>            Reporter: yosuke shiro
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 0.9.0
>
>
> Add {{Slice}} api to ChunkedArray.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to