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

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

wesm closed pull request #1617: ARROW-2166: [GLib] Add Slice api to Column
URL: https://github.com/apache/arrow/pull/1617
 
 
   

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/column.cpp b/c_glib/arrow-glib/column.cpp
index a7222b176..55d06ea9e 100644
--- a/c_glib/arrow-glib/column.cpp
+++ b/c_glib/arrow-glib/column.cpp
@@ -160,6 +160,26 @@ garrow_column_new_chunked_array(GArrowField *field,
   return garrow_column_new_raw(&arrow_column);
 }
 
+/**
+ * garrow_column_slice:
+ * @column: A #GArrowColumn.
+ * @offset: The offset of sub #GArrowColumn.
+ * @length: The length of sub #GArrowColumn.
+ *
+ * Returns: (transfer full): The sub #GArrowColumn. It covers only from
+ *   `offset` to `offset + length` range. The sub #GArrowColumn shares
+ *   values with the base #GArrowColumn.
+ */
+GArrowColumn *
+garrow_column_slice(GArrowColumn *column,
+                    guint64 offset,
+                    guint64 length)
+{
+  const auto arrow_column = garrow_column_get_raw(column);
+  auto arrow_sub_column = arrow_column->Slice(offset, length);
+  return garrow_column_new_raw(&arrow_sub_column);
+}
+
 /**
  * garrow_column_equal:
  * @column: A #GArrowColumn.
diff --git a/c_glib/arrow-glib/column.h b/c_glib/arrow-glib/column.h
index b649c5f1e..f2c181d43 100644
--- a/c_glib/arrow-glib/column.h
+++ b/c_glib/arrow-glib/column.h
@@ -71,6 +71,9 @@ GArrowColumn *garrow_column_new_array(GArrowField *field,
                                       GArrowArray *array);
 GArrowColumn *garrow_column_new_chunked_array(GArrowField *field,
                                               GArrowChunkedArray 
*chunked_array);
+GArrowColumn *garrow_column_slice(GArrowColumn *column,
+                                  guint64 offset,
+                                  guint64 length);
 
 gboolean            garrow_column_equal         (GArrowColumn *column,
                                                  GArrowColumn *other_column);
diff --git a/c_glib/test/test-column.rb b/c_glib/test/test-column.rb
index 96e02b603..01127de6e 100644
--- a/c_glib/test/test-column.rb
+++ b/c_glib/test/test-column.rb
@@ -96,4 +96,20 @@ def test_data
     column = Arrow::Column.new(field, chunked_array)
     assert_equal(3, column.data.length)
   end
+
+  def test_slice
+    field = Arrow::Field.new("enabled", Arrow::BooleanDataType.new)
+    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)
+    column = Arrow::Column.new(field, chunked_array)
+    sub_column = column.slice(1, 3)
+    assert_equal(chunks2, sub_column.data.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:
[email protected]


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



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

Reply via email to