kou commented on code in PR #47366: URL: https://github.com/apache/arrow/pull/47366#discussion_r2292529947
########## c_glib/arrow-glib/composite-array.cpp: ########## @@ -2044,4 +2046,117 @@ garrow_run_end_encoded_array_find_physical_length(GArrowRunEndEncodedArray *arra return arrow_run_end_encoded_array->FindPhysicalLength(); } +G_DEFINE_TYPE(GArrowFixedSizeListArray, garrow_fixed_size_list_array, GARROW_TYPE_ARRAY) + +static void +garrow_fixed_size_list_array_init(GArrowFixedSizeListArray *object) +{ +} + +static void +garrow_fixed_size_list_array_class_init(GArrowFixedSizeListArrayClass *klass) +{ +} + +/** + * garrow_fixed_size_list_array_new_list_size + * @value_array: The value of the fixed list size array. + * @list_size: The list size of the fixed list size array. + * @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. + * @error: (nullable): Return location for a #GError or %NULL. + * + * Returns: (nullable): A newly created #GArrowFixedSizeListArray + * or %NULL on error. + * + * Since: 22.0.0 + */ +GArrowFixedSizeListArray * +garrow_fixed_size_list_array_new_list_size(GArrowArray *value_array, + gint32 list_size, + GArrowBuffer *null_bitmap, + gint64 n_nulls, + GError **error) +{ + std::shared_ptr<arrow::Array> arrow_value_array = garrow_array_get_raw(value_array); Review Comment: ```suggestion auto arrow_value_array = garrow_array_get_raw(value_array); ``` ########## c_glib/arrow-glib/composite-array.cpp: ########## @@ -2044,4 +2046,117 @@ garrow_run_end_encoded_array_find_physical_length(GArrowRunEndEncodedArray *arra return arrow_run_end_encoded_array->FindPhysicalLength(); } +G_DEFINE_TYPE(GArrowFixedSizeListArray, garrow_fixed_size_list_array, GARROW_TYPE_ARRAY) + +static void +garrow_fixed_size_list_array_init(GArrowFixedSizeListArray *object) +{ +} + +static void +garrow_fixed_size_list_array_class_init(GArrowFixedSizeListArrayClass *klass) +{ +} + +/** + * garrow_fixed_size_list_array_new_list_size + * @value_array: The value of the fixed list size array. Review Comment: ```suggestion * @value_array: The value of the fixed size list array. ``` ########## c_glib/arrow-glib/composite-array.cpp: ########## @@ -2044,4 +2046,117 @@ garrow_run_end_encoded_array_find_physical_length(GArrowRunEndEncodedArray *arra return arrow_run_end_encoded_array->FindPhysicalLength(); } +G_DEFINE_TYPE(GArrowFixedSizeListArray, garrow_fixed_size_list_array, GARROW_TYPE_ARRAY) + +static void +garrow_fixed_size_list_array_init(GArrowFixedSizeListArray *object) +{ +} + +static void +garrow_fixed_size_list_array_class_init(GArrowFixedSizeListArrayClass *klass) +{ +} + +/** + * garrow_fixed_size_list_array_new_list_size + * @value_array: The value of the fixed list size array. + * @list_size: The list size of the fixed list size array. + * @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. + * @error: (nullable): Return location for a #GError or %NULL. + * + * Returns: (nullable): A newly created #GArrowFixedSizeListArray + * or %NULL on error. + * + * Since: 22.0.0 + */ +GArrowFixedSizeListArray * +garrow_fixed_size_list_array_new_list_size(GArrowArray *value_array, + gint32 list_size, + GArrowBuffer *null_bitmap, + gint64 n_nulls, + GError **error) +{ + std::shared_ptr<arrow::Array> arrow_value_array = garrow_array_get_raw(value_array); + auto arrow_null_bitmap = garrow_buffer_get_raw(null_bitmap); + + auto arrow_fixed_size_list_array_result = + arrow::FixedSizeListArray::FromArrays(arrow_value_array, + list_size, + arrow_null_bitmap, + n_nulls); + + garrow::check(error, + arrow_fixed_size_list_array_result, + "[fixed-size-list-array][new-list-size]"); + std::shared_ptr<arrow::Array> arrow_array = *arrow_fixed_size_list_array_result; + return GARROW_FIXED_SIZE_LIST_ARRAY(garrow_array_new_raw(&arrow_array)); +} + +/** + * garrow_fixed_size_list_array_new_type_array + * @value_array: The value of the fixed list size array. + * @data_type: The data type of the fixed list size array. + * @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. + * @error: (nullable): Return location for a #GError or %NULL. + * + * Returns: (nullable): A newly created #GArrowFixedSizeListArray + * or %NULL on error. + * + * Since: 22.0.0 + */ +GArrowFixedSizeListArray * +garrow_fixed_size_list_array_new_data_type(GArrowArray *value_array, + GArrowDataType *data_type, + GArrowBuffer *null_bitmap, + gint64 n_nulls, + GError **error) +{ + std::shared_ptr<arrow::Array> arrow_value_array = garrow_array_get_raw(value_array); + std::shared_ptr<arrow::DataType> arrow_data_type = garrow_data_type_get_raw(data_type); + std::shared_ptr<arrow::Buffer> arrow_null_bitmap = garrow_buffer_get_raw(null_bitmap); + + auto arrow_fixed_size_list_array_result = + arrow::FixedSizeListArray::FromArrays(arrow_value_array, + arrow_data_type, + arrow_null_bitmap, + n_nulls); + + garrow::check(error, + arrow_fixed_size_list_array_result, + "[fixed-size-list-array][new-data-type]"); + std::shared_ptr<arrow::Array> arrow_array = *arrow_fixed_size_list_array_result; + return GARROW_FIXED_SIZE_LIST_ARRAY(garrow_array_new_raw(&arrow_array)); +} + +/** + * garrow_fixed_size_list_array_get_values + * @array: A #GArrowFixedSizeListArray + * + * Returns: (transfer full): The element array. + * + * It should be freed with g_free() when no longer needed. + * + * Since: 22.0.0 + */ +GArrowArray * +garrow_fixed_size_list_array_get_values(GArrowFixedSizeListArray *array) +{ + auto arrow_array = garrow_array_get_raw(GARROW_ARRAY(array)); + auto arrow_fixed_size_list_array = + std::static_pointer_cast<arrow::FixedSizeListArray>(arrow_array); + auto arrow_value_array = arrow_fixed_size_list_array->values(); + Review Comment: ```suggestion ``` ########## c_glib/arrow-glib/composite-array.cpp: ########## @@ -2044,4 +2046,117 @@ garrow_run_end_encoded_array_find_physical_length(GArrowRunEndEncodedArray *arra return arrow_run_end_encoded_array->FindPhysicalLength(); } +G_DEFINE_TYPE(GArrowFixedSizeListArray, garrow_fixed_size_list_array, GARROW_TYPE_ARRAY) + +static void +garrow_fixed_size_list_array_init(GArrowFixedSizeListArray *object) +{ +} + +static void +garrow_fixed_size_list_array_class_init(GArrowFixedSizeListArrayClass *klass) +{ +} + +/** + * garrow_fixed_size_list_array_new_list_size + * @value_array: The value of the fixed list size array. + * @list_size: The list size of the fixed list size array. + * @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. + * @error: (nullable): Return location for a #GError or %NULL. + * + * Returns: (nullable): A newly created #GArrowFixedSizeListArray + * or %NULL on error. + * + * Since: 22.0.0 + */ +GArrowFixedSizeListArray * +garrow_fixed_size_list_array_new_list_size(GArrowArray *value_array, + gint32 list_size, + GArrowBuffer *null_bitmap, + gint64 n_nulls, + GError **error) +{ + std::shared_ptr<arrow::Array> arrow_value_array = garrow_array_get_raw(value_array); + auto arrow_null_bitmap = garrow_buffer_get_raw(null_bitmap); + + auto arrow_fixed_size_list_array_result = + arrow::FixedSizeListArray::FromArrays(arrow_value_array, + list_size, + arrow_null_bitmap, + n_nulls); + + garrow::check(error, + arrow_fixed_size_list_array_result, + "[fixed-size-list-array][new-list-size]"); + std::shared_ptr<arrow::Array> arrow_array = *arrow_fixed_size_list_array_result; + return GARROW_FIXED_SIZE_LIST_ARRAY(garrow_array_new_raw(&arrow_array)); +} + +/** + * garrow_fixed_size_list_array_new_type_array + * @value_array: The value of the fixed list size array. + * @data_type: The data type of the fixed list size array. + * @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. + * @error: (nullable): Return location for a #GError or %NULL. + * + * Returns: (nullable): A newly created #GArrowFixedSizeListArray + * or %NULL on error. + * + * Since: 22.0.0 + */ +GArrowFixedSizeListArray * +garrow_fixed_size_list_array_new_data_type(GArrowArray *value_array, + GArrowDataType *data_type, + GArrowBuffer *null_bitmap, + gint64 n_nulls, + GError **error) +{ + std::shared_ptr<arrow::Array> arrow_value_array = garrow_array_get_raw(value_array); + std::shared_ptr<arrow::DataType> arrow_data_type = garrow_data_type_get_raw(data_type); + std::shared_ptr<arrow::Buffer> arrow_null_bitmap = garrow_buffer_get_raw(null_bitmap); + + auto arrow_fixed_size_list_array_result = + arrow::FixedSizeListArray::FromArrays(arrow_value_array, + arrow_data_type, + arrow_null_bitmap, + n_nulls); + + garrow::check(error, + arrow_fixed_size_list_array_result, + "[fixed-size-list-array][new-data-type]"); + std::shared_ptr<arrow::Array> arrow_array = *arrow_fixed_size_list_array_result; + return GARROW_FIXED_SIZE_LIST_ARRAY(garrow_array_new_raw(&arrow_array)); Review Comment: ```suggestion if (garrow::check(error, arrow_fixed_size_list_array_result, "[fixed-size-list-array][new-data-type]")) { std::shared_ptr<arrow::Array> arrow_array = *arrow_fixed_size_list_array_result; return GARROW_FIXED_SIZE_LIST_ARRAY(garrow_array_new_raw(&arrow_array)); } else { return nullptr; } ``` ########## c_glib/arrow-glib/composite-array.cpp: ########## @@ -2044,4 +2046,117 @@ garrow_run_end_encoded_array_find_physical_length(GArrowRunEndEncodedArray *arra return arrow_run_end_encoded_array->FindPhysicalLength(); } +G_DEFINE_TYPE(GArrowFixedSizeListArray, garrow_fixed_size_list_array, GARROW_TYPE_ARRAY) + +static void +garrow_fixed_size_list_array_init(GArrowFixedSizeListArray *object) +{ +} + +static void +garrow_fixed_size_list_array_class_init(GArrowFixedSizeListArrayClass *klass) +{ +} + +/** + * garrow_fixed_size_list_array_new_list_size + * @value_array: The value of the fixed list size array. + * @list_size: The list size of the fixed list size array. Review Comment: ```suggestion * @list_size: The list size of the fixed size list array. ``` ########## c_glib/arrow-glib/composite-array.cpp: ########## @@ -2044,4 +2046,117 @@ garrow_run_end_encoded_array_find_physical_length(GArrowRunEndEncodedArray *arra return arrow_run_end_encoded_array->FindPhysicalLength(); } +G_DEFINE_TYPE(GArrowFixedSizeListArray, garrow_fixed_size_list_array, GARROW_TYPE_ARRAY) + +static void +garrow_fixed_size_list_array_init(GArrowFixedSizeListArray *object) +{ +} + +static void +garrow_fixed_size_list_array_class_init(GArrowFixedSizeListArrayClass *klass) +{ +} + +/** + * garrow_fixed_size_list_array_new_list_size + * @value_array: The value of the fixed list size array. + * @list_size: The list size of the fixed list size array. + * @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. + * @error: (nullable): Return location for a #GError or %NULL. + * + * Returns: (nullable): A newly created #GArrowFixedSizeListArray + * or %NULL on error. + * + * Since: 22.0.0 + */ +GArrowFixedSizeListArray * +garrow_fixed_size_list_array_new_list_size(GArrowArray *value_array, + gint32 list_size, + GArrowBuffer *null_bitmap, + gint64 n_nulls, + GError **error) +{ + std::shared_ptr<arrow::Array> arrow_value_array = garrow_array_get_raw(value_array); + auto arrow_null_bitmap = garrow_buffer_get_raw(null_bitmap); + + auto arrow_fixed_size_list_array_result = + arrow::FixedSizeListArray::FromArrays(arrow_value_array, + list_size, + arrow_null_bitmap, + n_nulls); + + garrow::check(error, + arrow_fixed_size_list_array_result, + "[fixed-size-list-array][new-list-size]"); + std::shared_ptr<arrow::Array> arrow_array = *arrow_fixed_size_list_array_result; + return GARROW_FIXED_SIZE_LIST_ARRAY(garrow_array_new_raw(&arrow_array)); Review Comment: ```suggestion if (garrow::check(error, arrow_fixed_size_list_array_result, "[fixed-size-list-array][new-list-size]")) { auto arrow_array = *arrow_fixed_size_list_array_result; return GARROW_FIXED_SIZE_LIST_ARRAY(garrow_array_new_raw(&arrow_array)); } else { return nullptr; } ``` ########## c_glib/arrow-glib/composite-array.cpp: ########## @@ -2044,4 +2046,117 @@ garrow_run_end_encoded_array_find_physical_length(GArrowRunEndEncodedArray *arra return arrow_run_end_encoded_array->FindPhysicalLength(); } +G_DEFINE_TYPE(GArrowFixedSizeListArray, garrow_fixed_size_list_array, GARROW_TYPE_ARRAY) + +static void +garrow_fixed_size_list_array_init(GArrowFixedSizeListArray *object) +{ +} + +static void +garrow_fixed_size_list_array_class_init(GArrowFixedSizeListArrayClass *klass) +{ +} + +/** + * garrow_fixed_size_list_array_new_list_size + * @value_array: The value of the fixed list size array. + * @list_size: The list size of the fixed list size array. + * @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. + * @error: (nullable): Return location for a #GError or %NULL. + * + * Returns: (nullable): A newly created #GArrowFixedSizeListArray + * or %NULL on error. + * + * Since: 22.0.0 + */ +GArrowFixedSizeListArray * +garrow_fixed_size_list_array_new_list_size(GArrowArray *value_array, + gint32 list_size, + GArrowBuffer *null_bitmap, + gint64 n_nulls, + GError **error) +{ + std::shared_ptr<arrow::Array> arrow_value_array = garrow_array_get_raw(value_array); + auto arrow_null_bitmap = garrow_buffer_get_raw(null_bitmap); + + auto arrow_fixed_size_list_array_result = + arrow::FixedSizeListArray::FromArrays(arrow_value_array, + list_size, + arrow_null_bitmap, + n_nulls); + + garrow::check(error, + arrow_fixed_size_list_array_result, + "[fixed-size-list-array][new-list-size]"); + std::shared_ptr<arrow::Array> arrow_array = *arrow_fixed_size_list_array_result; + return GARROW_FIXED_SIZE_LIST_ARRAY(garrow_array_new_raw(&arrow_array)); +} + +/** + * garrow_fixed_size_list_array_new_type_array + * @value_array: The value of the fixed list size array. + * @data_type: The data type of the fixed list size array. Review Comment: ```suggestion * @data_type: The data type of the fixed size list array. ``` ########## c_glib/arrow-glib/composite-array.cpp: ########## @@ -2044,4 +2046,117 @@ garrow_run_end_encoded_array_find_physical_length(GArrowRunEndEncodedArray *arra return arrow_run_end_encoded_array->FindPhysicalLength(); } +G_DEFINE_TYPE(GArrowFixedSizeListArray, garrow_fixed_size_list_array, GARROW_TYPE_ARRAY) + +static void +garrow_fixed_size_list_array_init(GArrowFixedSizeListArray *object) +{ +} + +static void +garrow_fixed_size_list_array_class_init(GArrowFixedSizeListArrayClass *klass) +{ +} + +/** + * garrow_fixed_size_list_array_new_list_size + * @value_array: The value of the fixed list size array. + * @list_size: The list size of the fixed list size array. + * @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. + * @error: (nullable): Return location for a #GError or %NULL. + * + * Returns: (nullable): A newly created #GArrowFixedSizeListArray + * or %NULL on error. + * + * Since: 22.0.0 + */ +GArrowFixedSizeListArray * +garrow_fixed_size_list_array_new_list_size(GArrowArray *value_array, + gint32 list_size, + GArrowBuffer *null_bitmap, + gint64 n_nulls, + GError **error) +{ + std::shared_ptr<arrow::Array> arrow_value_array = garrow_array_get_raw(value_array); + auto arrow_null_bitmap = garrow_buffer_get_raw(null_bitmap); + + auto arrow_fixed_size_list_array_result = + arrow::FixedSizeListArray::FromArrays(arrow_value_array, + list_size, + arrow_null_bitmap, + n_nulls); + + garrow::check(error, + arrow_fixed_size_list_array_result, + "[fixed-size-list-array][new-list-size]"); + std::shared_ptr<arrow::Array> arrow_array = *arrow_fixed_size_list_array_result; + return GARROW_FIXED_SIZE_LIST_ARRAY(garrow_array_new_raw(&arrow_array)); +} + +/** + * garrow_fixed_size_list_array_new_type_array + * @value_array: The value of the fixed list size array. Review Comment: ```suggestion * @value_array: The value of the fixed size list array. ``` ########## c_glib/arrow-glib/composite-array.cpp: ########## @@ -2044,4 +2046,117 @@ garrow_run_end_encoded_array_find_physical_length(GArrowRunEndEncodedArray *arra return arrow_run_end_encoded_array->FindPhysicalLength(); } +G_DEFINE_TYPE(GArrowFixedSizeListArray, garrow_fixed_size_list_array, GARROW_TYPE_ARRAY) + +static void +garrow_fixed_size_list_array_init(GArrowFixedSizeListArray *object) +{ +} + +static void +garrow_fixed_size_list_array_class_init(GArrowFixedSizeListArrayClass *klass) +{ +} + +/** + * garrow_fixed_size_list_array_new_list_size + * @value_array: The value of the fixed list size array. + * @list_size: The list size of the fixed list size array. + * @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. + * @error: (nullable): Return location for a #GError or %NULL. + * + * Returns: (nullable): A newly created #GArrowFixedSizeListArray + * or %NULL on error. + * + * Since: 22.0.0 + */ +GArrowFixedSizeListArray * +garrow_fixed_size_list_array_new_list_size(GArrowArray *value_array, + gint32 list_size, + GArrowBuffer *null_bitmap, + gint64 n_nulls, + GError **error) +{ + std::shared_ptr<arrow::Array> arrow_value_array = garrow_array_get_raw(value_array); + auto arrow_null_bitmap = garrow_buffer_get_raw(null_bitmap); + + auto arrow_fixed_size_list_array_result = + arrow::FixedSizeListArray::FromArrays(arrow_value_array, + list_size, + arrow_null_bitmap, + n_nulls); + + garrow::check(error, + arrow_fixed_size_list_array_result, + "[fixed-size-list-array][new-list-size]"); + std::shared_ptr<arrow::Array> arrow_array = *arrow_fixed_size_list_array_result; + return GARROW_FIXED_SIZE_LIST_ARRAY(garrow_array_new_raw(&arrow_array)); +} + +/** + * garrow_fixed_size_list_array_new_type_array + * @value_array: The value of the fixed list size array. + * @data_type: The data type of the fixed list size array. + * @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. + * @error: (nullable): Return location for a #GError or %NULL. + * + * Returns: (nullable): A newly created #GArrowFixedSizeListArray + * or %NULL on error. + * + * Since: 22.0.0 + */ +GArrowFixedSizeListArray * +garrow_fixed_size_list_array_new_data_type(GArrowArray *value_array, + GArrowDataType *data_type, + GArrowBuffer *null_bitmap, + gint64 n_nulls, + GError **error) +{ + std::shared_ptr<arrow::Array> arrow_value_array = garrow_array_get_raw(value_array); + std::shared_ptr<arrow::DataType> arrow_data_type = garrow_data_type_get_raw(data_type); + std::shared_ptr<arrow::Buffer> arrow_null_bitmap = garrow_buffer_get_raw(null_bitmap); Review Comment: ```suggestion auto arrow_value_array = garrow_array_get_raw(value_array); auto arrow_data_type = garrow_data_type_get_raw(data_type); auto arrow_null_bitmap = garrow_buffer_get_raw(null_bitmap); ``` ########## c_glib/arrow-glib/composite-array.cpp: ########## @@ -2044,4 +2046,117 @@ garrow_run_end_encoded_array_find_physical_length(GArrowRunEndEncodedArray *arra return arrow_run_end_encoded_array->FindPhysicalLength(); } +G_DEFINE_TYPE(GArrowFixedSizeListArray, garrow_fixed_size_list_array, GARROW_TYPE_ARRAY) + +static void +garrow_fixed_size_list_array_init(GArrowFixedSizeListArray *object) +{ +} + +static void +garrow_fixed_size_list_array_class_init(GArrowFixedSizeListArrayClass *klass) +{ +} + +/** + * garrow_fixed_size_list_array_new_list_size + * @value_array: The value of the fixed list size array. + * @list_size: The list size of the fixed list size array. + * @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. + * @error: (nullable): Return location for a #GError or %NULL. + * + * Returns: (nullable): A newly created #GArrowFixedSizeListArray + * or %NULL on error. + * + * Since: 22.0.0 + */ +GArrowFixedSizeListArray * +garrow_fixed_size_list_array_new_list_size(GArrowArray *value_array, + gint32 list_size, + GArrowBuffer *null_bitmap, + gint64 n_nulls, + GError **error) +{ + std::shared_ptr<arrow::Array> arrow_value_array = garrow_array_get_raw(value_array); + auto arrow_null_bitmap = garrow_buffer_get_raw(null_bitmap); + + auto arrow_fixed_size_list_array_result = + arrow::FixedSizeListArray::FromArrays(arrow_value_array, + list_size, + arrow_null_bitmap, + n_nulls); + + garrow::check(error, + arrow_fixed_size_list_array_result, + "[fixed-size-list-array][new-list-size]"); + std::shared_ptr<arrow::Array> arrow_array = *arrow_fixed_size_list_array_result; + return GARROW_FIXED_SIZE_LIST_ARRAY(garrow_array_new_raw(&arrow_array)); +} + +/** + * garrow_fixed_size_list_array_new_type_array Review Comment: ```suggestion * garrow_fixed_size_list_array_new_data_type ``` ########## c_glib/arrow-glib/composite-array.cpp: ########## @@ -2044,4 +2046,117 @@ garrow_run_end_encoded_array_find_physical_length(GArrowRunEndEncodedArray *arra return arrow_run_end_encoded_array->FindPhysicalLength(); } +G_DEFINE_TYPE(GArrowFixedSizeListArray, garrow_fixed_size_list_array, GARROW_TYPE_ARRAY) + +static void +garrow_fixed_size_list_array_init(GArrowFixedSizeListArray *object) +{ +} + +static void +garrow_fixed_size_list_array_class_init(GArrowFixedSizeListArrayClass *klass) +{ +} + +/** + * garrow_fixed_size_list_array_new_list_size + * @value_array: The value of the fixed list size array. + * @list_size: The list size of the fixed list size array. + * @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. + * @error: (nullable): Return location for a #GError or %NULL. + * + * Returns: (nullable): A newly created #GArrowFixedSizeListArray + * or %NULL on error. + * + * Since: 22.0.0 + */ +GArrowFixedSizeListArray * +garrow_fixed_size_list_array_new_list_size(GArrowArray *value_array, + gint32 list_size, + GArrowBuffer *null_bitmap, + gint64 n_nulls, + GError **error) +{ + std::shared_ptr<arrow::Array> arrow_value_array = garrow_array_get_raw(value_array); + auto arrow_null_bitmap = garrow_buffer_get_raw(null_bitmap); + + auto arrow_fixed_size_list_array_result = + arrow::FixedSizeListArray::FromArrays(arrow_value_array, Review Comment: `FromArrays()` is OK because `Make()` doesn't exist`. ########## c_glib/test/test-fixed-size-list-array.rb: ########## @@ -0,0 +1,47 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +class TestFixedSizeListArray < Test::Unit::TestCase + include Helper::Buildable + + sub_test_case(".new") do + def setup + @array_length = 3 + @list_elem_size = 4 + @value_array = build_uint8_array([10, 20, 30, 40, nil, nil, nil, nil, 50, 60, 70, 80]) + @null_bitmap = Arrow::Buffer.new([0b101].pack("C*")) + @null_count = 1 + end + + def test_new_array + array = Arrow::FixedSizeListArray.new(@value_array, @list_elem_size, @null_bitmap, + @null_count) + assert_equal([@array_length, Arrow::UInt8DataType.new, @list_elem_size, @value_array], + [array.length, array.value_data_type.field.data_type, + array.value_data_type.list_size, array.values]) + end + + def new_data_type + data_type = Arrow::FixedSizeListDataType.new(Arrow::UInt8DataType.new, list_elem_size) + + array = Arrow::FixedSizeListArray.new(@value_array, data_type, @null_bitmap, @null_count) + assert_equal([@array_length, Arrow::UInt8DataType.new, @list_elem_size, @value_array], + [array.length, array.value_data_type.field.data_type, + array.value_data_type.list_size, array.values]) + end + end Review Comment: Could you use `sub_test_case` to group tests? ```ruby sub_test_case("#initialize") do def test_list_size end def test_data_type end end ``` ########## c_glib/arrow-glib/composite-array.cpp: ########## @@ -2044,4 +2046,117 @@ garrow_run_end_encoded_array_find_physical_length(GArrowRunEndEncodedArray *arra return arrow_run_end_encoded_array->FindPhysicalLength(); } +G_DEFINE_TYPE(GArrowFixedSizeListArray, garrow_fixed_size_list_array, GARROW_TYPE_ARRAY) + +static void +garrow_fixed_size_list_array_init(GArrowFixedSizeListArray *object) +{ +} + +static void +garrow_fixed_size_list_array_class_init(GArrowFixedSizeListArrayClass *klass) +{ +} + +/** + * garrow_fixed_size_list_array_new_list_size + * @value_array: The value of the fixed list size array. + * @list_size: The list size of the fixed list size array. + * @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. + * @error: (nullable): Return location for a #GError or %NULL. + * + * Returns: (nullable): A newly created #GArrowFixedSizeListArray + * or %NULL on error. + * + * Since: 22.0.0 + */ +GArrowFixedSizeListArray * +garrow_fixed_size_list_array_new_list_size(GArrowArray *value_array, + gint32 list_size, + GArrowBuffer *null_bitmap, + gint64 n_nulls, + GError **error) +{ + std::shared_ptr<arrow::Array> arrow_value_array = garrow_array_get_raw(value_array); + auto arrow_null_bitmap = garrow_buffer_get_raw(null_bitmap); + + auto arrow_fixed_size_list_array_result = + arrow::FixedSizeListArray::FromArrays(arrow_value_array, + list_size, + arrow_null_bitmap, + n_nulls); + + garrow::check(error, + arrow_fixed_size_list_array_result, + "[fixed-size-list-array][new-list-size]"); + std::shared_ptr<arrow::Array> arrow_array = *arrow_fixed_size_list_array_result; + return GARROW_FIXED_SIZE_LIST_ARRAY(garrow_array_new_raw(&arrow_array)); +} + +/** + * garrow_fixed_size_list_array_new_type_array + * @value_array: The value of the fixed list size array. + * @data_type: The data type of the fixed list size array. + * @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. + * @error: (nullable): Return location for a #GError or %NULL. + * + * Returns: (nullable): A newly created #GArrowFixedSizeListArray + * or %NULL on error. + * + * Since: 22.0.0 + */ +GArrowFixedSizeListArray * +garrow_fixed_size_list_array_new_data_type(GArrowArray *value_array, + GArrowDataType *data_type, + GArrowBuffer *null_bitmap, + gint64 n_nulls, + GError **error) +{ + std::shared_ptr<arrow::Array> arrow_value_array = garrow_array_get_raw(value_array); + std::shared_ptr<arrow::DataType> arrow_data_type = garrow_data_type_get_raw(data_type); + std::shared_ptr<arrow::Buffer> arrow_null_bitmap = garrow_buffer_get_raw(null_bitmap); + + auto arrow_fixed_size_list_array_result = + arrow::FixedSizeListArray::FromArrays(arrow_value_array, + arrow_data_type, + arrow_null_bitmap, + n_nulls); + + garrow::check(error, + arrow_fixed_size_list_array_result, + "[fixed-size-list-array][new-data-type]"); + std::shared_ptr<arrow::Array> arrow_array = *arrow_fixed_size_list_array_result; + return GARROW_FIXED_SIZE_LIST_ARRAY(garrow_array_new_raw(&arrow_array)); +} + +/** + * garrow_fixed_size_list_array_get_values + * @array: A #GArrowFixedSizeListArray + * + * Returns: (transfer full): The element array. + * + * It should be freed with g_free() when no longer needed. Review Comment: ```suggestion * It should be freed with g_object_unref() when no longer needed. ``` ########## c_glib/test/test-fixed-size-list-array.rb: ########## @@ -0,0 +1,44 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +class TestFixedSizeListArray < Test::Unit::TestCase + include Helper::Buildable + + sub_test_case(".new") do + def setup + @array_length = 3 + @list_elem_size = 4 + @value_array = build_uint8_array([10, 20, 30, 40, nil, nil, nil, nil, 50, 60, 70, 80]) + @null_bitmap = Arrow::Buffer.new([0b101].pack("C*")) + @null_count = 1 + end + + def test_new_array + array = Arrow::FixedSizeListArray.new(@value_array, @list_elem_size, @null_bitmap, @null_count) + assert_equal([@array_length, Arrow::UInt8DataType.new, @list_elem_size, @value_array], + [array.length, array.value_data_type.field.data_type, array.value_data_type.list_size, array.values]) + end Review Comment: We can use `arrow::FixedSizeListArray::value_slice(i)` for this propose. ########## c_glib/test/test-fixed-size-list-array.rb: ########## @@ -0,0 +1,47 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +class TestFixedSizeListArray < Test::Unit::TestCase + include Helper::Buildable + + sub_test_case(".new") do + def setup + @array_length = 3 + @list_elem_size = 4 + @value_array = build_uint8_array([10, 20, 30, 40, nil, nil, nil, nil, 50, 60, 70, 80]) + @null_bitmap = Arrow::Buffer.new([0b101].pack("C*")) + @null_count = 1 + end + + def test_new_array + array = Arrow::FixedSizeListArray.new(@value_array, @list_elem_size, @null_bitmap, + @null_count) + assert_equal([@array_length, Arrow::UInt8DataType.new, @list_elem_size, @value_array], + [array.length, array.value_data_type.field.data_type, + array.value_data_type.list_size, array.values]) + end + + def new_data_type Review Comment: ```suggestion def test_new_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