diff --git a/matlab/src/cpp/arrow/matlab/error/error.h b/matlab/src/cpp/arrow/matlab/error/error.h index b8376c0a06ecb..7dcecfa433567 100644 --- a/matlab/src/cpp/arrow/matlab/error/error.h +++ b/matlab/src/cpp/arrow/matlab/error/error.h @@ -174,6 +174,7 @@ namespace arrow::matlab::error { static const char* INVALID_TIME_UNIT = "arrow:type:InvalidTimeUnit"; static const char* FIELD_FAILED_TO_CREATE_TYPE_PROXY = "arrow:field:FailedToCreateTypeProxy"; static const char* ARRAY_FAILED_TO_CREATE_TYPE_PROXY = "arrow:array:FailedToCreateTypeProxy"; + static const char* LIST_TYPE_FAILED_TO_CREATE_VALUE_TYPE_PROXY = "arrow:type:list:FailedToCreateValueTypeProxy"; static const char* ARROW_TABULAR_SCHEMA_AMBIGUOUS_FIELD_NAME = "arrow:tabular:schema:AmbiguousFieldName"; static const char* UNKNOWN_PROXY_FOR_ARRAY_TYPE = "arrow:array:UnknownProxyForArrayType"; static const char* RECORD_BATCH_NUMERIC_INDEX_WITH_EMPTY_RECORD_BATCH = "arrow:tabular:recordbatch:NumericIndexWithEmptyRecordBatch"; diff --git a/matlab/src/cpp/arrow/matlab/proxy/factory.cc b/matlab/src/cpp/arrow/matlab/proxy/factory.cc index 3091d248f8ca1..5caf8d9fc8f2d 100644 --- a/matlab/src/cpp/arrow/matlab/proxy/factory.cc +++ b/matlab/src/cpp/arrow/matlab/proxy/factory.cc @@ -35,6 +35,7 @@ #include "arrow/matlab/type/proxy/time32_type.h" #include "arrow/matlab/type/proxy/time64_type.h" #include "arrow/matlab/type/proxy/struct_type.h" +#include "arrow/matlab/type/proxy/list_type.h" #include "arrow/matlab/type/proxy/field.h" #include "arrow/matlab/io/feather/proxy/writer.h" #include "arrow/matlab/io/feather/proxy/reader.h" @@ -89,6 +90,7 @@ libmexclass::proxy::MakeResult Factory::make_proxy(const ClassName& class_name, REGISTER_PROXY(arrow.type.proxy.Date32Type , arrow::matlab::type::proxy::Date32Type); REGISTER_PROXY(arrow.type.proxy.Date64Type , arrow::matlab::type::proxy::Date64Type); REGISTER_PROXY(arrow.type.proxy.StructType , arrow::matlab::type::proxy::StructType); + REGISTER_PROXY(arrow.type.proxy.ListType , arrow::matlab::type::proxy::ListType); REGISTER_PROXY(arrow.io.feather.proxy.Writer , arrow::matlab::io::feather::proxy::Writer); REGISTER_PROXY(arrow.io.feather.proxy.Reader , arrow::matlab::io::feather::proxy::Reader); REGISTER_PROXY(arrow.io.csv.proxy.TableWriter , arrow::matlab::io::csv::proxy::TableWriter); diff --git a/matlab/src/cpp/arrow/matlab/type/proxy/list_type.cc b/matlab/src/cpp/arrow/matlab/type/proxy/list_type.cc new file mode 100644 index 0000000000000..141a7a18750b6 --- /dev/null +++ b/matlab/src/cpp/arrow/matlab/type/proxy/list_type.cc @@ -0,0 +1,64 @@ +// 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. + +#include "arrow/matlab/type/proxy/list_type.h" +#include "arrow/matlab/type/proxy/wrap.h" +#include "libmexclass/proxy/ProxyManager.h" +#include "arrow/matlab/error/error.h" + +namespace arrow::matlab::type::proxy { + + ListType::ListType(std::shared_ptr list_type) : Type(std::move(list_type)) { + REGISTER_METHOD(ListType, getValueType); + } + + void ListType::getValueType(libmexclass::proxy::method::Context& context) { + namespace mda = ::matlab::data; + mda::ArrayFactory factory; + + const auto list_type = std::static_pointer_cast(data_type); + const auto value_type = list_type->value_type(); + const auto value_type_id = static_cast(value_type->id()); + + MATLAB_ASSIGN_OR_ERROR_WITH_CONTEXT(auto value_type_proxy, + type::proxy::wrap(value_type), + context, + error::LIST_TYPE_FAILED_TO_CREATE_VALUE_TYPE_PROXY); + const auto value_type_proxy_id = libmexclass::proxy::ProxyManager::manageProxy(value_type_proxy); + + mda::StructArray output = factory.createStructArray({1, 1}, {"ValueTypeProxyID", "ValueTypeID"}); + output[0]["ValueTypeProxyID"] = factory.createScalar(value_type_proxy_id); + output[0]["ValueTypeID"] = factory.createScalar(value_type_id); + + context.outputs[0] = output; + } + + libmexclass::proxy::MakeResult ListType::make(const libmexclass::proxy::FunctionArguments& constructor_arguments) { + namespace mda = ::matlab::data; + using namespace libmexclass::proxy; + using ListTypeProxy = arrow::matlab::type::proxy::ListType; + + mda::StructArray args = constructor_arguments[0]; + const mda::TypedArray value_type_proxy_id_mda = args[0]["ValueTypeProxyID"]; + const auto value_type_proxy_id = value_type_proxy_id_mda[0]; + const auto proxy = ProxyManager::getProxy(value_type_proxy_id); + const auto value_type_proxy = std::static_pointer_cast(proxy); + const auto value_type = value_type_proxy->unwrap(); + const auto list_type = std::static_pointer_cast(arrow::list(value_type)); + return std::make_shared(std::move(list_type)); + } +} diff --git a/matlab/src/cpp/arrow/matlab/type/proxy/list_type.h b/matlab/src/cpp/arrow/matlab/type/proxy/list_type.h new file mode 100644 index 0000000000000..1d7599e0537a3 --- /dev/null +++ b/matlab/src/cpp/arrow/matlab/type/proxy/list_type.h @@ -0,0 +1,36 @@ +// 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. + +#pragma once + +#include "arrow/matlab/type/proxy/type.h" + +namespace arrow::matlab::type::proxy { + + class ListType : public arrow::matlab::type::proxy::Type { + + public: + ListType(std::shared_ptr list_type); + + ~ListType() {} + + void getValueType(libmexclass::proxy::method::Context& context); + + static libmexclass::proxy::MakeResult make(const libmexclass::proxy::FunctionArguments& constructor_arguments); + }; + +} diff --git a/matlab/src/cpp/arrow/matlab/type/proxy/struct_type.h b/matlab/src/cpp/arrow/matlab/type/proxy/struct_type.h index 8ec6217b34278..d3659e5784242 100644 --- a/matlab/src/cpp/arrow/matlab/type/proxy/struct_type.h +++ b/matlab/src/cpp/arrow/matlab/type/proxy/struct_type.h @@ -29,6 +29,6 @@ namespace arrow::matlab::type::proxy { ~StructType() {} static libmexclass::proxy::MakeResult make(const libmexclass::proxy::FunctionArguments& constructor_arguments); -}; + }; -} \ No newline at end of file +} diff --git a/matlab/src/cpp/arrow/matlab/type/proxy/wrap.cc b/matlab/src/cpp/arrow/matlab/type/proxy/wrap.cc index 3dd86e91409fa..df2d561b69df7 100644 --- a/matlab/src/cpp/arrow/matlab/type/proxy/wrap.cc +++ b/matlab/src/cpp/arrow/matlab/type/proxy/wrap.cc @@ -24,6 +24,7 @@ #include "arrow/matlab/type/proxy/date32_type.h" #include "arrow/matlab/type/proxy/date64_type.h" #include "arrow/matlab/type/proxy/string_type.h" +#include "arrow/matlab/type/proxy/list_type.h" #include "arrow/matlab/type/proxy/struct_type.h" namespace arrow::matlab::type::proxy { @@ -65,7 +66,9 @@ namespace arrow::matlab::type::proxy { return std::make_shared(std::static_pointer_cast(type)); case ID::STRING: return std::make_shared(std::static_pointer_cast(type)); - case ID::STRUCT: + case ID::LIST: + return std::make_shared(std::static_pointer_cast(type)); + case ID::STRUCT: return std::make_shared(std::static_pointer_cast(type)); default: return arrow::Status::NotImplemented("Unsupported DataType: " + type->ToString()); diff --git a/matlab/src/matlab/+arrow/+type/+traits/ListTraits.m b/matlab/src/matlab/+arrow/+type/+traits/ListTraits.m new file mode 100644 index 0000000000000..c1c87790342ea --- /dev/null +++ b/matlab/src/matlab/+arrow/+type/+traits/ListTraits.m @@ -0,0 +1,30 @@ +% 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. + +classdef ListTraits < arrow.type.traits.TypeTraits + + properties (Constant) + ArrayConstructor = missing + ArrayClassName = missing + ArrayProxyClassName = missing + ArrayStaticConstructor = missing + TypeConstructor = @arrow.type.ListType + TypeClassName = "arrow.type.ListType" + TypeProxyClassName = "arrow.type.proxy.ListType" + MatlabConstructor = missing + MatlabClassName = missing + end + +end diff --git a/matlab/src/matlab/+arrow/+type/+traits/traits.m b/matlab/src/matlab/+arrow/+type/+traits/traits.m index 9badf63eebb81..d7de576486c99 100644 --- a/matlab/src/matlab/+arrow/+type/+traits/traits.m +++ b/matlab/src/matlab/+arrow/+type/+traits/traits.m @@ -56,6 +56,8 @@ typeTraits = Date32Traits(); case ID.Date64 typeTraits = Date64Traits(); + case ID.List + typeTraits = ListTraits(); case ID.Struct typeTraits = StructTraits(); otherwise @@ -100,4 +102,4 @@ error("arrow:type:traits:UnsupportedInputType", "The input argument to the traits function " + ... "must be a MATLAB class string or an arrow.type.ID enumeration."); end -end \ No newline at end of file +end diff --git a/matlab/src/matlab/+arrow/+type/ID.m b/matlab/src/matlab/+arrow/+type/ID.m index b2c4facbe4065..deddd3ae3b74a 100644 --- a/matlab/src/matlab/+arrow/+type/ID.m +++ b/matlab/src/matlab/+arrow/+type/ID.m @@ -17,31 +17,31 @@ classdef ID < uint64 enumeration - Boolean (1) - UInt8 (2) - Int8 (3) - UInt16 (4) - Int16 (5) - UInt32 (6) - Int32 (7) - UInt64 (8) - Int64 (9) - % Float16 (10) not yet supported - Float32 (11) - Float64 (12) - String (13) - % Binary (14) + Boolean (1) + UInt8 (2) + Int8 (3) + UInt16 (4) + Int16 (5) + UInt32 (6) + Int32 (7) + UInt64 (8) + Int64 (9) + % Float16 (10) + Float32 (11) + Float64 (12) + String (13) + % Binary (14) % FixedSizeBinary (15) - Date32 (16) - Date64 (17) - Timestamp (18) - Time32 (19) - Time64 (20) + Date32 (16) + Date64 (17) + Timestamp (18) + Time32 (19) + Time64 (20) % IntervalMonths (21) % IntervalDayTime (22) % Decimal128 (23) % Decimal256 (24) - % List (25) + List (25) Struct (26) end end diff --git a/matlab/src/matlab/+arrow/+type/ListType.m b/matlab/src/matlab/+arrow/+type/ListType.m new file mode 100644 index 0000000000000..4166cfd5a809a --- /dev/null +++ b/matlab/src/matlab/+arrow/+type/ListType.m @@ -0,0 +1,57 @@ +% 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. + +classdef ListType < arrow.type.Type + + properties (Dependent, GetAccess=public, SetAccess=private) + % The inner element type T of the List. + % For example: for List, ValueType = UInt64. + ValueType + end + + methods + function obj = ListType(proxy) + arguments + proxy(1, 1) libmexclass.proxy.Proxy {validate(proxy, "arrow.type.proxy.ListType")} + end + import arrow.internal.proxy.validate + obj@arrow.type.Type(proxy); + end + end + + methods(Access = protected) + function groups = getDisplayPropertyGroups(~) + targets = ["ID", "ValueType"]; + groups = matlab.mixin.util.PropertyGroup(targets); + end + end + + + methods + function valueType = get.ValueType(obj) + valueTypeStruct = obj.Proxy.getValueType(); + traits = arrow.type.traits.traits(arrow.type.ID(valueTypeStruct.ValueTypeID)); + proxy = libmexclass.proxy.Proxy(Name=traits.TypeProxyClassName, ID=valueTypeStruct.ValueTypeProxyID); + valueType = traits.TypeConstructor(proxy); + end + end + + methods (Hidden) + function data = preallocateMATLABArray(~, numElements) + % Preallocate an empty cell array. + data = cell(numElements, 1); + end + end +end diff --git a/matlab/src/matlab/+arrow/list.m b/matlab/src/matlab/+arrow/list.m new file mode 100644 index 0000000000000..bdee4558853e8 --- /dev/null +++ b/matlab/src/matlab/+arrow/list.m @@ -0,0 +1,26 @@ +%LIST Creates an arrow.type.ListType object + +% 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. +function listType = list(valueType) + arguments + valueType(1, 1) arrow.type.Type + end + + valueTypeProxyID = valueType.Proxy.ID; + args = struct(ValueTypeProxyID=valueTypeProxyID); + proxy = arrow.internal.proxy.create("arrow.type.proxy.ListType", args); + listType = arrow.type.ListType(proxy); +end diff --git a/matlab/test/arrow/type/tField.m b/matlab/test/arrow/type/tField.m index f84034d032c23..2176316b79cfd 100644 --- a/matlab/test/arrow/type/tField.m +++ b/matlab/test/arrow/type/tField.m @@ -42,6 +42,7 @@ function TestSupportedTypes(testCase) arrow.float64, ... arrow.string, ... arrow.timestamp, ... + arrow.list(arrow.uint64()), ... arrow.struct(arrow.field("A", arrow.float32())) }; for ii = 1:numel(supportedTypes) diff --git a/matlab/test/arrow/type/tID.m b/matlab/test/arrow/type/tID.m index e97d77e81c124..67197dfdaa60c 100644 --- a/matlab/test/arrow/type/tID.m +++ b/matlab/test/arrow/type/tID.m @@ -47,6 +47,7 @@ function CastToUInt64(testCase) ID.Timestamp, 18, ... ID.Time32, 19, ... ID.Time64, 20, ... + ID.List, 25, ... ID.Struct, 26 ... ); diff --git a/matlab/test/arrow/type/tListType.m b/matlab/test/arrow/type/tListType.m new file mode 100644 index 0000000000000..e0d528a6a7da5 --- /dev/null +++ b/matlab/test/arrow/type/tListType.m @@ -0,0 +1,143 @@ +% TLISTTYPE Tests for arrow.type.ListType + +% 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. + +classdef tListType < matlab.unittest.TestCase + + properties (Constant) + BasicList = arrow.list(arrow.int8()) + NestedList = arrow.list(arrow.list(arrow.list(arrow.uint64()))) + ConstructionFcn = @arrow.list + TypeID = arrow.type.ID.List + ClassName = "arrow.type.ListType" + end + + methods (Test) + + function ConstructionFcnBasic(testCase) + % Verify construction function returns an instance of the + % expected arrow.type.Type subclass. + type = testCase.BasicList; + testCase.verifyInstanceOf(type, testCase.ClassName); + end + + function ConstructionFcnTooFewInputsError(testCase) + % Verify construction function errors if given too few input arguments. + fcn = @() testCase.ConstructionFcn(); + testCase.verifyError(fcn, "MATLAB:minrhs"); + end + + function ConstructionFcnTooManyInputsError(testCase) + % Verify construction function errors if given too many input arguments. + fcn = @() testCase.ConstructionFcn(1, 2); + testCase.verifyError(fcn, "MATLAB:TooManyInputs"); + end + + function ConstructionFcnInvalidValueTypeError(testCase) + % Verify construction function errors if the supplied + % valueType is not an arrow.type.Type object. + valueType = "abc"; + fcn = @() testCase.ConstructionFcn(valueType); + testCase.verifyError(fcn, "MATLAB:validation:UnableToConvert"); + end + + function ConstructionFcnEmptyValueTypeError(testCase) + % Verify construction function errors if given an empty + % arrow.type.Type array as the valueType input argument. + valueType = arrow.type.Type.empty(0, 0); + fcn = @() testCase.ConstructionFcn(valueType); + testCase.verifyError(fcn, "MATLAB:validation:IncompatibleSize"); + end + + function ValueTypeGetter(testCase) + % Verify the ValueType property getter returns the expected value. + valueType = arrow.int8(); + type = arrow.list(valueType); + testCase.verifyEqual(type.ValueType, valueType); + + valueType = arrow.list(arrow.uint64()); + type = arrow.list(valueType); + testCase.verifyEqual(type.ValueType, valueType); + end + + function ValueTypeNoSetter(testCase) + % Verify the ValueType property is not settable. + type = testCase.BasicList; + fcn = @() setfield(type, "ValueType", arrow.string()); + testCase.verifyError(fcn, "MATLAB:class:SetProhibited"); + end + + function IDGetter(testCase) + % Verify the ID property getter returns the expected enum value. + type = testCase.BasicList; + actual = type.ID; + expected = testCase.TypeID; + testCase.verifyEqual(actual, expected); + end + + function IDNoSetter(testCase) + % Verify the ID property is not settable. + type = testCase.BasicList; + fcn = @() setfield(type, "ID", arrow.type.ID.Boolean); + testCase.verifyError(fcn, "MATLAB:class:SetProhibited"); + end + + function IsEqualTrue(testCase) + % Verify two ListTypes are considered equal if their + % ValueType properties are equal. + + valueType = arrow.string(); + type1 = arrow.list(arrow.list(valueType)); + type2 = arrow.list(arrow.list(valueType)); + testCase.verifyTrue(isequal(type1, type2)); + + % Non-scalar arrow.type.ListType arrays + type3 = [type1 type2]; + type4 = [type1 type2]; + testCase.verifyTrue(isequal(type3, type4)); + end + + function IsEqualFalse(testCase) + % Verify isequal returns false when expected. + + valueType = arrow.time32(); + type1 = arrow.list(valueType); + + valueType = arrow.time64(); + type2 = arrow.list(valueType); + + valueType = arrow.timestamp(); + type3 = arrow.list(valueType); + + valueType = arrow.list(arrow.timestamp()); + type4 = arrow.list(valueType); + + % ValueType properties are different. + testCase.verifyFalse(isequal(type1, type2)); + testCase.verifyFalse(isequal(type3, type4)); + + % Non-scalar arrow.type.ListType arrays + type5 = [type1 type2]; + type6 = [type1; type2]; + type7 = [type3 type4]; + type8 = [type4 type3]; + testCase.verifyFalse(isequal(type5, type6)); + testCase.verifyFalse(isequal(type7, type8)); + end + + end + +end diff --git a/matlab/test/arrow/type/tTypeDisplay.m b/matlab/test/arrow/type/tTypeDisplay.m index 6f5a4bcd97717..0445fcd74a4eb 100644 --- a/matlab/test/arrow/type/tTypeDisplay.m +++ b/matlab/test/arrow/type/tTypeDisplay.m @@ -265,5 +265,34 @@ function StructTypeDisplay(testCase) actualDisplay = evalc('disp(type)'); verify(testCase, actualDisplay, expectedDisplay); end + + function ListTypeDisplay(testCase) + % Verify the display of ListType objects. + % + % Example: + % + % ListType with properties: + % + % ID: Struct + % ValueType: [1x1 arrow.type.StringType] + + import arrow.internal.test.display.verify + import arrow.internal.test.display.makeLinkString + import arrow.internal.test.display.makeDimensionString + + valueType = arrow.string(); + type = arrow.list(valueType); %#ok + classnameLink = makeLinkString(FullClassName="arrow.type.ListType", ClassName="ListType", BoldFont=true); + header = " " + classnameLink + " with properties:" + newline; + body = strjust(pad(["ID:"; "ValueType:"])); + dimensionString = makeDimensionString([1 1]); + typeString = compose("[%s %s]", dimensionString, string(class(valueType))); + body = body + " " + ["List"; typeString]; + body = " " + body; + footer = string(newline); + expectedDisplay = char(strjoin([header body' footer], newline)); + actualDisplay = evalc('disp(type)'); + verify(testCase, actualDisplay, expectedDisplay); + end end end diff --git a/matlab/test/arrow/type/traits/tListTraits.m b/matlab/test/arrow/type/traits/tListTraits.m new file mode 100644 index 0000000000000..93a8d8a0d10c5 --- /dev/null +++ b/matlab/test/arrow/type/traits/tListTraits.m @@ -0,0 +1,31 @@ +% 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. + +classdef tListTraits < hTypeTraits + + properties + TraitsConstructor = @arrow.type.traits.ListTraits + ArrayConstructor = missing + ArrayClassName = missing + ArrayProxyClassName = missing + ArrayStaticConstructor = missing + TypeConstructor = @arrow.type.ListType + TypeClassName = "arrow.type.ListType" + TypeProxyClassName = "arrow.type.proxy.ListType" + MatlabConstructor = missing + MatlabClassName = missing + end + +end \ No newline at end of file diff --git a/matlab/test/arrow/type/traits/ttraits.m b/matlab/test/arrow/type/traits/ttraits.m index d2d80b3f8f8f5..9acf72bf56130 100644 --- a/matlab/test/arrow/type/traits/ttraits.m +++ b/matlab/test/arrow/type/traits/ttraits.m @@ -211,6 +211,18 @@ function TestStruct(testCase) testCase.verifyEqual(actualTraits, expectedTraits); end + function TestList(testCase) + import arrow.type.traits.* + import arrow.type.* + + type = ID.List; + expectedTraits = ListTraits(); + + actualTraits = traits(type); + + testCase.verifyEqual(actualTraits, expectedTraits); + end + function TestMatlabUInt8(testCase) import arrow.type.traits.* diff --git a/matlab/tools/cmake/BuildMatlabArrowInterface.cmake b/matlab/tools/cmake/BuildMatlabArrowInterface.cmake index 50daab65324f4..c3940933679a5 100644 --- a/matlab/tools/cmake/BuildMatlabArrowInterface.cmake +++ b/matlab/tools/cmake/BuildMatlabArrowInterface.cmake @@ -67,6 +67,7 @@ set(MATLAB_ARROW_LIBMEXCLASS_CLIENT_PROXY_SOURCES "${CMAKE_SOURCE_DIR}/src/cpp/a "${CMAKE_SOURCE_DIR}/src/cpp/arrow/matlab/type/proxy/time32_type.cc" "${CMAKE_SOURCE_DIR}/src/cpp/arrow/matlab/type/proxy/time64_type.cc" "${CMAKE_SOURCE_DIR}/src/cpp/arrow/matlab/type/proxy/struct_type.cc" + "${CMAKE_SOURCE_DIR}/src/cpp/arrow/matlab/type/proxy/list_type.cc" "${CMAKE_SOURCE_DIR}/src/cpp/arrow/matlab/type/proxy/field.cc" "${CMAKE_SOURCE_DIR}/src/cpp/arrow/matlab/type/proxy/wrap.cc" "${CMAKE_SOURCE_DIR}/src/cpp/arrow/matlab/io/feather/proxy/writer.cc"