kou commented on code in PR #46381:
URL: https://github.com/apache/arrow/pull/46381#discussion_r2082765543
##########
c_glib/arrow-glib/basic-data-type.cpp:
##########
@@ -2347,6 +2347,34 @@ garrow_fixed_shape_tensor_data_type_new(GArrowDataType
*value_type,
return data_type;
}
+/**
+ * garrow_fixed_shape_tensor_data_type_get_shape:
+ * @object: A #GArrowDataType of individual tensor elements.
+ * @length: (out) (optional): return location for the number of elements in
the returned
+ * array
+ *
+ * Returns: (transfer full) (array length=length): Shape of tensor elements.
+ */
+gint64 *
+garrow_fixed_shape_tensor_data_type_get_shape(GArrowFixedShapeTensorDataType
*object,
+ gsize *length)
+{
+ const auto priv = GARROW_DATA_TYPE_GET_PRIVATE(object);
+ auto arrow_data_type =
+
std::static_pointer_cast<arrow::extension::FixedShapeTensorType>(priv->data_type);
+ auto arrow_shape = arrow_data_type->shape();
+
+ gsize n_shape = arrow_shape.size();
+ auto shape = static_cast<gint64 *>(g_malloc_n(sizeof(gint64), n_shape));
+
+ for (gsize i = 0; i < n_shape; ++i) {
+ shape[i] = arrow_shape[i];
+ }
+
+ *length = n_shape;
+ return shape;
Review Comment:
```suggestion
return arrow_shape.data();
```
##########
c_glib/arrow-glib/basic-data-type.cpp:
##########
@@ -2347,6 +2347,34 @@ garrow_fixed_shape_tensor_data_type_new(GArrowDataType
*value_type,
return data_type;
}
+/**
+ * garrow_fixed_shape_tensor_data_type_get_shape:
+ * @object: A #GArrowDataType of individual tensor elements.
+ * @length: (out) (optional): return location for the number of elements in
the returned
+ * array
Review Comment:
```suggestion
* @length: (out): return location for the number of elements in the
returned array.
```
##########
c_glib/arrow-glib/basic-data-type.cpp:
##########
@@ -2347,6 +2347,34 @@ garrow_fixed_shape_tensor_data_type_new(GArrowDataType
*value_type,
return data_type;
}
+/**
+ * garrow_fixed_shape_tensor_data_type_get_shape:
+ * @object: A #GArrowDataType of individual tensor elements.
+ * @length: (out) (optional): return location for the number of elements in
the returned
+ * array
+ *
+ * Returns: (transfer full) (array length=length): Shape of tensor elements.
+ */
+gint64 *
+garrow_fixed_shape_tensor_data_type_get_shape(GArrowFixedShapeTensorDataType
*object,
+ gsize *length)
+{
+ const auto priv = GARROW_DATA_TYPE_GET_PRIVATE(object);
+ auto arrow_data_type =
+
std::static_pointer_cast<arrow::extension::FixedShapeTensorType>(priv->data_type);
+ auto arrow_shape = arrow_data_type->shape();
+
+ gsize n_shape = arrow_shape.size();
Review Comment:
```suggestion
*length = arrow_shape.size();
```
##########
c_glib/arrow-glib/basic-data-type.cpp:
##########
@@ -2347,6 +2347,34 @@ garrow_fixed_shape_tensor_data_type_new(GArrowDataType
*value_type,
return data_type;
}
+/**
+ * garrow_fixed_shape_tensor_data_type_get_shape:
+ * @object: A #GArrowDataType of individual tensor elements.
+ * @length: (out) (optional): return location for the number of elements in
the returned
+ * array
+ *
+ * Returns: (transfer full) (array length=length): Shape of tensor elements.
+ */
+gint64 *
Review Comment:
Let's use shape in C++ directly:
```suggestion
* Returns: (array length=length): Shape of tensor elements.
*/
const gint64 *
```
--
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]