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

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

wesm commented on a change in pull request #1377: ARROW-1874: [GLib] Add 
garrow_array_unique()
URL: https://github.com/apache/arrow/pull/1377#discussion_r154449963
 
 

 ##########
 File path: c_glib/arrow-glib/basic-array.cpp
 ##########
 @@ -563,6 +563,39 @@ garrow_array_cast(GArrowArray *array,
   return garrow_array_new_raw(&arrow_casted_array);
 }
 
+/**
+ * garrow_array_unique:
+ * @array: A #GArrowArray.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: (nullable) (transfer full):
+ *   A newly created unique elements array on success, %NULL on error.
+ *
+ * Since: 0.8.0
+ */
+GArrowArray *
+garrow_array_unique(GArrowArray *array,
+                    GError **error)
+{
+  auto arrow_array = garrow_array_get_raw(array);
+  auto memory_pool = arrow::default_memory_pool();
+  arrow::compute::FunctionContext context(memory_pool);
+  std::shared_ptr<arrow::Array> arrow_unique_array;
+  auto status = arrow::compute::Unique(&context,
+                                       arrow::compute::Datum(arrow_array),
+                                       &arrow_unique_array);
+  if (!status.ok()) {
+    std::stringstream message;
+    message << "[array][unique] <";
+    message << arrow_array->type()->ToString();
+    message << ">";
+    garrow_error_check(error, status, message.str().c_str());
+    return NULL;
+  }
+
+  return garrow_array_new_raw(&arrow_unique_array);
 
 Review comment:
   I'm hopeful as more kernel functions are implemented that some common 
patterns will emerge to make things simpler in binding layers like this

----------------------------------------------------------------
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] Add garrow_array_unique()
> --------------------------------
>
>                 Key: ARROW-1874
>                 URL: https://issues.apache.org/jira/browse/ARROW-1874
>             Project: Apache Arrow
>          Issue Type: New Feature
>          Components: GLib
>            Reporter: Kouhei Sutou
>            Assignee: Kouhei Sutou
>              Labels: pull-request-available
>             Fix For: 0.8.0
>
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to