kou commented on code in PR #46305:
URL: https://github.com/apache/arrow/pull/46305#discussion_r2074763992


##########
c_glib/arrow-glib/basic-data-type.cpp:
##########
@@ -2267,6 +2271,73 @@ garrow_string_view_data_type_new(void)
   return data_type;
 }
 
+G_DEFINE_TYPE(GArrowFixedShapeTensorDataType,
+              garrow_fixed_shape_tensor_data_type,
+              GARROW_TYPE_EXTENSION_DATA_TYPE)
+
+static void
+garrow_fixed_shape_tensor_data_type_init(GArrowFixedShapeTensorDataType 
*object)
+{
+}
+
+static void
+garrow_fixed_shape_tensor_data_type_class_init(GArrowFixedShapeTensorDataTypeClass
 *klass)
+{
+}
+
+/**
+ * garrow_fixed_shape_tensor_data_type_new:
+ * @value_type: A #GArrowDataType.
+ * @size: The length of `shape`.
+ * @psize: The length of `permutation`.
+ * @shape: (array length=size): shape.
+ * @permutation: (array length=psize): permutation.
+ * @dim_name: (array length=size): dim_names.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: The newly created fixed shape tensor data type.
+ */
+GArrowFixedShapeTensorDataType *
+garrow_fixed_shape_tensor_data_type_new(GArrowDataType *value_type,
+                                        gint32 size,
+                                        gint32 psize,
+                                        const gint64 *shape,
+                                        const gint64 *permutation,
+                                        const gchar **dim_name,
+                                        GError **error)
+{
+  std::vector<int64_t> arrow_shape;
+  std::vector<int64_t> arrow_permutation;
+  std::vector<std::string> arrow_dim_names;
+
+  auto arrow_value_type = garrow_data_type_get_raw(value_type);
+
+  for (int i = 0; i < psize; i++) {
+    arrow_shape.push_back(permutation[i]);

Review Comment:
   `arrow_permutation`?



##########
c_glib/arrow-glib/basic-data-type.cpp:
##########
@@ -2267,6 +2271,73 @@ garrow_string_view_data_type_new(void)
   return data_type;
 }
 
+G_DEFINE_TYPE(GArrowFixedShapeTensorDataType,
+              garrow_fixed_shape_tensor_data_type,
+              GARROW_TYPE_EXTENSION_DATA_TYPE)
+
+static void
+garrow_fixed_shape_tensor_data_type_init(GArrowFixedShapeTensorDataType 
*object)
+{
+}
+
+static void
+garrow_fixed_shape_tensor_data_type_class_init(GArrowFixedShapeTensorDataTypeClass
 *klass)
+{
+}
+
+/**
+ * garrow_fixed_shape_tensor_data_type_new:
+ * @value_type: A #GArrowDataType.
+ * @size: The length of `shape`.
+ * @psize: The length of `permutation`.
+ * @shape: (array length=size): shape.
+ * @permutation: (array length=psize): permutation.
+ * @dim_name: (array length=size): dim_names.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: The newly created fixed shape tensor data type.
+ */
+GArrowFixedShapeTensorDataType *
+garrow_fixed_shape_tensor_data_type_new(GArrowDataType *value_type,
+                                        gint32 size,
+                                        gint32 psize,
+                                        const gint64 *shape,
+                                        const gint64 *permutation,
+                                        const gchar **dim_name,
+                                        GError **error)
+{
+  std::vector<int64_t> arrow_shape;
+  std::vector<int64_t> arrow_permutation;
+  std::vector<std::string> arrow_dim_names;
+
+  auto arrow_value_type = garrow_data_type_get_raw(value_type);
+
+  for (int i = 0; i < psize; i++) {
+    arrow_shape.push_back(permutation[i]);
+  }
+
+  for (int i = 0; i < size; i++) {
+    arrow_shape.push_back(shape[i]);
+    arrow_dim_names.push_back(dim_name[i]);
+  }
+
+  auto arrow_data_type = 
arrow::extension::FixedShapeTensorType::Make(arrow_value_type,
+                                                                      
arrow_shape,
+                                                                      
arrow_permutation,
+                                                                      
arrow_dim_names);
+
+  if (!garrow::check(error, arrow_data_type, "[fixed-shape-tensor][new]")) {
+    return NULL;
+  }
+
+  GArrowFixedShapeTensorDataType *data_type = 
GARROW_FIXED_SHAPE_TENSOR_DATA_TYPE(
+    g_object_new(GARROW_TYPE_FIXED_SHAPE_TENSOR_DATA_TYPE,
+                 "data-type",
+                 &arrow_data_type.ValueUnsafe(),

Review Comment:
   ```suggestion
       auto arrow_data_type = *arrow_data_type_result;
       g_object_new(GARROW_TYPE_FIXED_SHAPE_TENSOR_DATA_TYPE,
                    "data-type",
                    &arrow_data_type,
   ```



##########
c_glib/arrow-glib/basic-data-type.cpp:
##########
@@ -2267,6 +2271,73 @@ garrow_string_view_data_type_new(void)
   return data_type;
 }
 
+G_DEFINE_TYPE(GArrowFixedShapeTensorDataType,
+              garrow_fixed_shape_tensor_data_type,
+              GARROW_TYPE_EXTENSION_DATA_TYPE)
+
+static void
+garrow_fixed_shape_tensor_data_type_init(GArrowFixedShapeTensorDataType 
*object)
+{
+}
+
+static void
+garrow_fixed_shape_tensor_data_type_class_init(GArrowFixedShapeTensorDataTypeClass
 *klass)
+{
+}
+
+/**
+ * garrow_fixed_shape_tensor_data_type_new:
+ * @value_type: A #GArrowDataType.
+ * @size: The length of `shape`.
+ * @psize: The length of `permutation`.
+ * @shape: (array length=size): shape.
+ * @permutation: (array length=psize): permutation.
+ * @dim_name: (array length=size): dim_names.

Review Comment:
   `permutation` and `dim_names` can be `NULL`. So we can't share the same 
length argument.
   
   ```suggestion
    * @shape: (array length=shape_length): A physical shape of the contained 
tensors as an array.
    * @shape_length: The length of `shape`.
    * @permutation: (array length=permutation_length): An indices of the 
desired ordering of the original
    *    dimensions, defined as an array. This must be `NULL` or the same 
length array of `shape`.
    * @permutation_length: The length of `permutation`.
    * @dim_names: (array length=n_dim_names): Explicit names to tensor 
dimensions as an array.
    *   This must be `NULL` or the same length array of `shape`.
    * @n_dim_names. The length of `dim_names`.
   ```



##########
c_glib/arrow-glib/basic-data-type.cpp:
##########
@@ -2267,6 +2271,73 @@ garrow_string_view_data_type_new(void)
   return data_type;
 }
 
+G_DEFINE_TYPE(GArrowFixedShapeTensorDataType,
+              garrow_fixed_shape_tensor_data_type,
+              GARROW_TYPE_EXTENSION_DATA_TYPE)
+
+static void
+garrow_fixed_shape_tensor_data_type_init(GArrowFixedShapeTensorDataType 
*object)
+{
+}
+
+static void
+garrow_fixed_shape_tensor_data_type_class_init(GArrowFixedShapeTensorDataTypeClass
 *klass)
+{
+}
+
+/**
+ * garrow_fixed_shape_tensor_data_type_new:
+ * @value_type: A #GArrowDataType.
+ * @size: The length of `shape`.
+ * @psize: The length of `permutation`.
+ * @shape: (array length=size): shape.
+ * @permutation: (array length=psize): permutation.
+ * @dim_name: (array length=size): dim_names.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: The newly created fixed shape tensor data type.
+ */
+GArrowFixedShapeTensorDataType *
+garrow_fixed_shape_tensor_data_type_new(GArrowDataType *value_type,
+                                        gint32 size,
+                                        gint32 psize,
+                                        const gint64 *shape,
+                                        const gint64 *permutation,
+                                        const gchar **dim_name,
+                                        GError **error)
+{
+  std::vector<int64_t> arrow_shape;
+  std::vector<int64_t> arrow_permutation;
+  std::vector<std::string> arrow_dim_names;
+
+  auto arrow_value_type = garrow_data_type_get_raw(value_type);
+
+  for (int i = 0; i < psize; i++) {
+    arrow_shape.push_back(permutation[i]);
+  }
+
+  for (int i = 0; i < size; i++) {
+    arrow_shape.push_back(shape[i]);
+    arrow_dim_names.push_back(dim_name[i]);
+  }
+
+  auto arrow_data_type = 
arrow::extension::FixedShapeTensorType::Make(arrow_value_type,
+                                                                      
arrow_shape,
+                                                                      
arrow_permutation,
+                                                                      
arrow_dim_names);
+
+  if (!garrow::check(error, arrow_data_type, "[fixed-shape-tensor][new]")) {

Review Comment:
   ```suggestion
     auto arrow_data_type_result = 
arrow::extension::FixedShapeTensorType::Make(arrow_value_type,
                                                                         
arrow_shape,
                                                                         
arrow_permutation,
                                                                         
arrow_dim_names);
     if (!garrow::check(error, arrow_data_type_result, 
"[fixed-shape-tensor][new]")) {
   ```



##########
c_glib/arrow-glib/basic-data-type.cpp:
##########
@@ -2267,6 +2271,73 @@ garrow_string_view_data_type_new(void)
   return data_type;
 }
 
+G_DEFINE_TYPE(GArrowFixedShapeTensorDataType,
+              garrow_fixed_shape_tensor_data_type,
+              GARROW_TYPE_EXTENSION_DATA_TYPE)
+
+static void
+garrow_fixed_shape_tensor_data_type_init(GArrowFixedShapeTensorDataType 
*object)
+{
+}
+
+static void
+garrow_fixed_shape_tensor_data_type_class_init(GArrowFixedShapeTensorDataTypeClass
 *klass)
+{
+}
+
+/**
+ * garrow_fixed_shape_tensor_data_type_new:
+ * @value_type: A #GArrowDataType.

Review Comment:
   ```suggestion
    * @value_type: A #GArrowDataType of individual tensor elements.
   ```



##########
c_glib/arrow-glib/basic-data-type.cpp:
##########
@@ -2267,6 +2271,73 @@ garrow_string_view_data_type_new(void)
   return data_type;
 }
 
+G_DEFINE_TYPE(GArrowFixedShapeTensorDataType,
+              garrow_fixed_shape_tensor_data_type,
+              GARROW_TYPE_EXTENSION_DATA_TYPE)
+
+static void
+garrow_fixed_shape_tensor_data_type_init(GArrowFixedShapeTensorDataType 
*object)
+{
+}
+
+static void
+garrow_fixed_shape_tensor_data_type_class_init(GArrowFixedShapeTensorDataTypeClass
 *klass)
+{
+}
+
+/**
+ * garrow_fixed_shape_tensor_data_type_new:
+ * @value_type: A #GArrowDataType.
+ * @size: The length of `shape`.
+ * @psize: The length of `permutation`.
+ * @shape: (array length=size): shape.
+ * @permutation: (array length=psize): permutation.
+ * @dim_name: (array length=size): dim_names.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: The newly created fixed shape tensor data type.
+ */
+GArrowFixedShapeTensorDataType *
+garrow_fixed_shape_tensor_data_type_new(GArrowDataType *value_type,
+                                        gint32 size,
+                                        gint32 psize,
+                                        const gint64 *shape,
+                                        const gint64 *permutation,
+                                        const gchar **dim_name,
+                                        GError **error)
+{
+  std::vector<int64_t> arrow_shape;
+  std::vector<int64_t> arrow_permutation;
+  std::vector<std::string> arrow_dim_names;
+
+  auto arrow_value_type = garrow_data_type_get_raw(value_type);
+
+  for (int i = 0; i < psize; i++) {
+    arrow_shape.push_back(permutation[i]);
+  }
+
+  for (int i = 0; i < size; i++) {
+    arrow_shape.push_back(shape[i]);
+    arrow_dim_names.push_back(dim_name[i]);
+  }
+
+  auto arrow_data_type = 
arrow::extension::FixedShapeTensorType::Make(arrow_value_type,
+                                                                      
arrow_shape,
+                                                                      
arrow_permutation,
+                                                                      
arrow_dim_names);
+
+  if (!garrow::check(error, arrow_data_type, "[fixed-shape-tensor][new]")) {
+    return NULL;
+  }
+
+  GArrowFixedShapeTensorDataType *data_type = 
GARROW_FIXED_SHAPE_TENSOR_DATA_TYPE(

Review Comment:
   ```suggestion
     auto data_type = GARROW_FIXED_SHAPE_TENSOR_DATA_TYPE(
   ```



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to