kou commented on code in PR #45711:
URL: https://github.com/apache/arrow/pull/45711#discussion_r1986233988
##########
c_glib/arrow-glib/basic-array.cpp:
##########
@@ -2602,6 +2607,75 @@ garrow_binary_view_array_get_value(GArrowBinaryViewArray
*array, gint64 i)
return g_bytes_new_static(view.data(), view.length());
}
+G_DEFINE_TYPE(GArrowStringViewArray,
+ garrow_string_view_array,
+ GARROW_TYPE_BINARY_VIEW_ARRAY)
Review Comment:
It's OK.
##########
c_glib/arrow-glib/basic-array.cpp:
##########
@@ -2602,6 +2607,75 @@ garrow_binary_view_array_get_value(GArrowBinaryViewArray
*array, gint64 i)
return g_bytes_new_static(view.data(), view.length());
}
+G_DEFINE_TYPE(GArrowStringViewArray,
+ garrow_string_view_array,
+ GARROW_TYPE_BINARY_VIEW_ARRAY)
+static void
+garrow_string_view_array_init(GArrowStringViewArray *object)
+{
+}
+
+static void
+garrow_string_view_array_class_init(GArrowStringViewArrayClass *klass)
+{
+}
+
+/**
+ * garrow_string_view_array_new:
+ * @length: The number of elements.
+ * @views: The view buffer.
+ * @data_buffers: (element-type GArrowBuffer): The data buffers.
+ * @null_bitmap: (nullable): The bitmap that shows null elements. The
+ * N-th element is null when the N-th bit is 0, not null otherwise.
+ * If the array has no null elements, the bitmap must be %NULL and
+ * @n_nulls is 0.
+ * @n_nulls: The number of null elements. If -1 is specified, the
+ * number of nulls are computed from @null_bitmap.
+ * @offset: The position of the first element.
+ *
+ * Returns: A newly created #GArrowStringViewArray.
+ *
+ * Since: 20.0.0
+ */
+GArrowStringViewArray *
+garrow_string_view_array_new(gint64 length,
+ GArrowBuffer *views,
+ GList *data_buffers,
+ GArrowBuffer *null_bitmap,
+ gint64 n_nulls,
+ gint64 offset)
+{
+ std::vector<std::shared_ptr<arrow::Buffer>> arrow_data_buffers;
+ for (GList *node = data_buffers; node; node = g_list_next(node)) {
+
arrow_data_buffers.push_back(garrow_buffer_get_raw(GARROW_BUFFER(node->data)));
+ }
+ auto string_view_array =
Review Comment:
Could you use `arrow_` prefix for variables of Apache Arrow C++ objects?
```suggestion
auto arrow_string_view_array =
```
##########
c_glib/arrow-glib/basic-array.cpp:
##########
@@ -2602,6 +2607,75 @@ garrow_binary_view_array_get_value(GArrowBinaryViewArray
*array, gint64 i)
return g_bytes_new_static(view.data(), view.length());
}
+G_DEFINE_TYPE(GArrowStringViewArray,
+ garrow_string_view_array,
+ GARROW_TYPE_BINARY_VIEW_ARRAY)
+static void
+garrow_string_view_array_init(GArrowStringViewArray *object)
+{
+}
+
+static void
+garrow_string_view_array_class_init(GArrowStringViewArrayClass *klass)
+{
+}
+
+/**
+ * garrow_string_view_array_new:
+ * @length: The number of elements.
+ * @views: The view buffer.
+ * @data_buffers: (element-type GArrowBuffer): The data buffers.
+ * @null_bitmap: (nullable): The bitmap that shows null elements. The
+ * N-th element is null when the N-th bit is 0, not null otherwise.
+ * If the array has no null elements, the bitmap must be %NULL and
+ * @n_nulls is 0.
+ * @n_nulls: The number of null elements. If -1 is specified, the
+ * number of nulls are computed from @null_bitmap.
+ * @offset: The position of the first element.
+ *
+ * Returns: A newly created #GArrowStringViewArray.
+ *
+ * Since: 20.0.0
+ */
+GArrowStringViewArray *
+garrow_string_view_array_new(gint64 length,
+ GArrowBuffer *views,
+ GList *data_buffers,
+ GArrowBuffer *null_bitmap,
+ gint64 n_nulls,
+ gint64 offset)
+{
+ std::vector<std::shared_ptr<arrow::Buffer>> arrow_data_buffers;
+ for (GList *node = data_buffers; node; node = g_list_next(node)) {
+
arrow_data_buffers.push_back(garrow_buffer_get_raw(GARROW_BUFFER(node->data)));
+ }
+ auto string_view_array =
+ std::make_shared<arrow::StringViewArray>(arrow::utf8_view(),
+ length,
+ garrow_buffer_get_raw(views),
+ std::move(arrow_data_buffers),
+
garrow_buffer_get_raw(null_bitmap),
+ n_nulls,
+ offset);
+ return GARROW_STRING_VIEW_ARRAY(
+ g_object_new(GARROW_TYPE_STRING_VIEW_ARRAY, "array", &string_view_array,
nullptr));
Review Comment:
It's OK.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]