kou commented on code in PR #46774: URL: https://github.com/apache/arrow/pull/46774#discussion_r2143996915
########## c_glib/test/test-fixed-size-list-data-type.rb: ########## @@ -0,0 +1,51 @@ +# 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 TestFixedSizeListDataType < Test::Unit::TestCase + sub_test_case(".new") do + def setup + @value_type = Arrow::BooleanDataType.new + @list_size = 5 + @field_name = "bool_field" + end + + def test_field + field = Arrow::Field.new(@field_name, @value_type) + data_type = Arrow::FixedSizeListDataType.new(field, @list_size); + assert_equal(Arrow::Type::FIXED_SIZE_LIST, data_type.id); Review Comment: * We don't need `data_type.id` because `data_type.to_s` includes `fixed_size_list`. * It's OK with `#to_s` in this PR but we should have readers of `value_field` and `list_size` in the future. We can move `garrow_list_data_type_get_field()` to `garrow_base_list_data_type_get_field()` for `value_field`: ```diff diff --git a/c_glib/arrow-glib/composite-data-type.cpp b/c_glib/arrow-glib/composite-data-type.cpp index 8af1b0c862..ac5ed6809f 100644 --- a/c_glib/arrow-glib/composite-data-type.cpp +++ b/c_glib/arrow-glib/composite-data-type.cpp @@ -65,6 +65,25 @@ garrow_base_list_data_type_class_init(GArrowBaseListDataTypeClass *klass) { } +/** + * garrow_base_list_data_type_get_field: + * @base_list_data_type: A #GArrowBaseListDataType. + * + * Returns: (transfer full): The field of value. + * + * Since: 21.0.0 + */ +GArrowField * +garrow_base_list_data_type_get_field(GArrowBaseListDataType *base_list_data_type) +{ + auto data_type = GARROW_DATA_TYPE(base_list_data_type); + auto arrow_data_type = garrow_data_type_get_raw(data_type); + auto arrow_base_list_data_type = std::static_pointer_cast<arrow::BaseListType>(arrow_data_type); + + auto arrow_field = arrow_base_list_data_type->value_field(); + return garrow_field_new_raw(&arrow_field, nullptr); +} + G_DEFINE_TYPE(GArrowListDataType, garrow_list_data_type, GARROW_TYPE_BASE_LIST_DATA_TYPE) static void @@ -116,16 +135,14 @@ garrow_list_data_type_get_value_field(GArrowListDataType *list_data_type) * Returns: (transfer full): The field of value. * * Since: 0.13.0 + * + * Deprecated: 21.0.0: + * Use garrow_base_list_data_type_get_field() instead. */ GArrowField * garrow_list_data_type_get_field(GArrowListDataType *list_data_type) { - auto data_type = GARROW_DATA_TYPE(list_data_type); - auto arrow_data_type = garrow_data_type_get_raw(data_type); - auto arrow_list_data_type = static_cast<arrow::ListType *>(arrow_data_type.get()); - - auto arrow_field = arrow_list_data_type->value_field(); - return garrow_field_new_raw(&arrow_field, nullptr); + return garrow_base_list_data_type_get_field(GARROW_BASE_LIST_DATA_TYPE(list_data_type)); } G_DEFINE_TYPE(GArrowLargeListDataType, garrow_large_list_data_type, GARROW_TYPE_DATA_TYPE) diff --git a/c_glib/arrow-glib/composite-data-type.h b/c_glib/arrow-glib/composite-data-type.h index de9449c41c..02de84ec50 100644 --- a/c_glib/arrow-glib/composite-data-type.h +++ b/c_glib/arrow-glib/composite-data-type.h @@ -38,6 +38,10 @@ struct _GArrowBaseListDataTypeClass GArrowDataTypeClass parent_class; }; +GARROW_AVAILABLE_IN_21_0 +GArrowField * +garrow_base_list_data_type_get_field(GArrowBaseListDataType *base_list_data_type); + #define GARROW_TYPE_LIST_DATA_TYPE (garrow_list_data_type_get_type()) GARROW_AVAILABLE_IN_ALL G_DECLARE_DERIVABLE_TYPE(GArrowListDataType, ``` We can add `garrow_fixed_size_list_data_type_get_list_size()` (or `list-size` property) as the binding of https://github.com/apache/arrow/blob/91335980c3483694099e9b4ac131c050fe82008d/cpp/src/arrow/type.h#L1389 . -- 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]
