diff --git a/c_glib/arrow-glib/basic-data-type.cpp b/c_glib/arrow-glib/basic-data-type.cpp index ecb537aa1f905..f922106065a8d 100644 --- a/c_glib/arrow-glib/basic-data-type.cpp +++ b/c_glib/arrow-glib/basic-data-type.cpp @@ -127,6 +127,8 @@ G_BEGIN_DECLS * * #GArrowExtensionDataTypeRegistry is a class to manage extension * data types. + * + * #GArrowBinaryViewDataType is a class for the binary view data type. */ struct GArrowDataTypePrivate @@ -2207,6 +2209,34 @@ garrow_extension_data_type_registry_lookup(GArrowExtensionDataTypeRegistry *regi return GARROW_EXTENSION_DATA_TYPE(data_type); } +G_DEFINE_TYPE(GArrowBinaryViewDataType, + garrow_binary_view_data_type, + GARROW_TYPE_DATA_TYPE) + +static void +garrow_binary_view_data_type_init(GArrowBinaryViewDataType *object) +{ +} + +static void +garrow_binary_view_data_type_class_init(GArrowBinaryViewDataTypeClass *klass) +{ +} + +/** + * garrow_binary_view_data_type_new: + * + * Returns: The newly created binary view data type. + */ +GArrowBinaryViewDataType * +garrow_binary_view_data_type_new(void) +{ + auto arrow_data_type = arrow::binary_view(); + GArrowBinaryViewDataType *data_type = GARROW_BINARY_VIEW_DATA_TYPE( + g_object_new(GARROW_TYPE_BINARY_VIEW_DATA_TYPE, "data-type", &arrow_data_type, NULL)); + return data_type; +} + G_END_DECLS GArrowDataType * diff --git a/c_glib/arrow-glib/basic-data-type.h b/c_glib/arrow-glib/basic-data-type.h index edbe15e2df521..b98488211a78e 100644 --- a/c_glib/arrow-glib/basic-data-type.h +++ b/c_glib/arrow-glib/basic-data-type.h @@ -770,4 +770,20 @@ GArrowExtensionDataType * garrow_extension_data_type_registry_lookup(GArrowExtensionDataTypeRegistry *registry, const gchar *name); +#define GARROW_TYPE_BINARY_VIEW_DATA_TYPE (garrow_binary_view_data_type_get_type()) +GARROW_AVAILABLE_IN_19_0 +G_DECLARE_DERIVABLE_TYPE(GArrowBinaryViewDataType, + garrow_binary_view_data_type, + GARROW, + BINARY_VIEW_DATA_TYPE, + GArrowDataType) +struct _GArrowBinaryViewDataTypeClass +{ + GArrowDataTypeClass parent_class; +}; + +GARROW_AVAILABLE_IN_19_0 +GArrowBinaryViewDataType * +garrow_binary_view_data_type_new(void); + G_END_DECLS diff --git a/c_glib/arrow-glib/type.cpp b/c_glib/arrow-glib/type.cpp index 26d21f6d82587..42372bc8dda6e 100644 --- a/c_glib/arrow-glib/type.cpp +++ b/c_glib/arrow-glib/type.cpp @@ -114,6 +114,8 @@ garrow_type_from_raw(arrow::Type::type type) return GARROW_TYPE_MONTH_DAY_NANO_INTERVAL; case arrow::Type::type::RUN_END_ENCODED: return GARROW_TYPE_RUN_END_ENCODED; + case arrow::Type::type::BINARY_VIEW: + return GARROW_TYPE_BINARY_VIEW; default: return GARROW_TYPE_NA; } diff --git a/c_glib/arrow-glib/type.h b/c_glib/arrow-glib/type.h index a817da4b9413e..f85cf3f2ee416 100644 --- a/c_glib/arrow-glib/type.h +++ b/c_glib/arrow-glib/type.h @@ -70,6 +70,8 @@ G_BEGIN_DECLS * @GARROW_TYPE_LARGE_LIST: A list of some logical data type with 64-bit offsets. * @GARROW_TYPE_MONTH_DAY_NANO_INTERVAL: MONTH_DAY_NANO interval in SQL style. * @GARROW_TYPE_RUN_END_ENCODED: Run-end encoded data. + * @GARROW_TYPE_BINARY_VIEW: Bytes view type with 4-byte prefix and inline small string + * optimization. * @GARROW_TYPE_DECIMAL32: Precision- and scale-based decimal * @GARROW_TYPE_DECIMAL64: Precision- and scale-based decimal * type with 64-bit. Storage type depends on the parameters. @@ -116,7 +118,9 @@ typedef enum { GARROW_TYPE_LARGE_LIST, GARROW_TYPE_MONTH_DAY_NANO_INTERVAL, GARROW_TYPE_RUN_END_ENCODED, - /* TODO: Remove = 43 when we add STRING_VIEW(39)..LARGE_LIST_VIEW(42). */ + /* TODO: Remove = 40 when we add STRING_VIEW(39) */ + GARROW_TYPE_BINARY_VIEW = 40, + /* TODO: Remove = 43 when we add LIST_VIEW(41)..LARGE_LIST_VIEW(42). */ GARROW_TYPE_DECIMAL32 = 43, GARROW_TYPE_DECIMAL64, } GArrowType; diff --git a/c_glib/test/test-binary-view-data-type.rb b/c_glib/test/test-binary-view-data-type.rb new file mode 100644 index 0000000000000..f143b62df4ebc --- /dev/null +++ b/c_glib/test/test-binary-view-data-type.rb @@ -0,0 +1,33 @@ +# 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 TestBinaryViewDataType < Test::Unit::TestCase + def test_type + data_type = Arrow::BinaryViewDataType.new + assert_equal(Arrow::Type::BINARY_VIEW, data_type.id) + end + + def test_name + data_type = Arrow::BinaryViewDataType.new + assert_equal("binary_view", data_type.name) + end + + def test_to_s + data_type = Arrow::BinaryViewDataType.new + assert_equal("binary_view", data_type.to_s) + end +end