Skip to content

Commit

Permalink
GH-37345: [MATLAB] Add function handle to fromMATLAB static constru…
Browse files Browse the repository at this point in the history
…ction methods to `TypeTraits` classes (#37370)

### Rationale for this change

Each concrete `arrow.array.Array` subclass has an associated `fromMATLAB `static construction method. It would be helpful if the `TypeTraits` classes had access to these corresponding fromMATLAB methods.

This would involve adding a new property like `ArrayStaticConstructor` to the TypeTraits classes.

For example:

```matlab
>> arrow.type.traits.Int8Traits

ans = 

  Int8Traits with properties:

       ArrayConstructor: @ arrow.array.Int8Array
         ArrayClassName: "arrow.array.Int8Array"
    ArrayProxyClassName: "arrow.array.proxy.Int8Array"
 ArrayStaticConstructor: @ arrow.array.Int8Array.fromMATLAB
        TypeConstructor: @ arrow.type.Int8Type
          TypeClassName: "arrow.type.Int8Type"
     TypeProxyClassName: "arrow.type.proxy.Int8Type"
      MatlabConstructor: @ int8
        MatlabClassName: "int8"
```
### What changes are included in this PR?

1. Added a new abstract property called `ArrayStaticConstructor` to the parent class `arrow.type.traits.TypeTraits`.
2. Defined the `ArrayStaticConstructor` property in all concrete classes of `ArrayStaticConstructor`.

### Are these changes tested?

Yes. Added a new test case to abstract test class `hTypeTraits.m`.

### Are there any user-facing changes?

No.

* Closes: #37345

Authored-by: Sarah Gilmore <[email protected]>
Signed-off-by: Kevin Gurney <[email protected]>
  • Loading branch information
sgilmore10 authored Aug 25, 2023
1 parent faccbef commit 4586689
Show file tree
Hide file tree
Showing 30 changed files with 46 additions and 12 deletions.
3 changes: 2 additions & 1 deletion matlab/src/matlab/+arrow/+type/+traits/BooleanTraits.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
ArrayConstructor = @arrow.array.BooleanArray
ArrayClassName = "arrow.array.BooleanArray"
ArrayProxyClassName = "arrow.array.proxy.BooleanArray"
TypeConstructor = @arrow.type.BooleanType;
ArrayStaticConstructor = @arrow.array.BooleanArray.fromMATLAB
TypeConstructor = @arrow.type.BooleanType
TypeClassName = "arrow.type.BooleanType"
TypeProxyClassName = "arrow.type.proxy.BooleanType"
MatlabConstructor = @logical
Expand Down
3 changes: 2 additions & 1 deletion matlab/src/matlab/+arrow/+type/+traits/Float32Traits.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
ArrayConstructor = @arrow.array.Float32Array
ArrayClassName = "arrow.array.Float32Array"
ArrayProxyClassName = "arrow.array.proxy.Float32Array"
TypeConstructor = @arrow.type.Float32Type;
ArrayStaticConstructor = @arrow.array.Float32Array.fromMATLAB
TypeConstructor = @arrow.type.Float32Type
TypeClassName = "arrow.type.Float32Type"
TypeProxyClassName = "arrow.type.proxy.Float32Type"
MatlabConstructor = @single
Expand Down
3 changes: 2 additions & 1 deletion matlab/src/matlab/+arrow/+type/+traits/Float64Traits.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
ArrayConstructor = @arrow.array.Float64Array
ArrayClassName = "arrow.array.Float64Array"
ArrayProxyClassName = "arrow.array.proxy.Float64Array"
TypeConstructor = @arrow.type.Float64Type;
ArrayStaticConstructor = @arrow.array.Float64Array.fromMATLAB
TypeConstructor = @arrow.type.Float64Type
TypeClassName = "arrow.type.Float64Type"
TypeProxyClassName = "arrow.type.proxy.Float64Type"
MatlabConstructor = @double
Expand Down
3 changes: 2 additions & 1 deletion matlab/src/matlab/+arrow/+type/+traits/Int16Traits.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
ArrayConstructor = @arrow.array.Int16Array
ArrayClassName = "arrow.array.Int16Array"
ArrayProxyClassName = "arrow.array.proxy.Int16Array"
TypeConstructor = @arrow.type.Int16Type;
ArrayStaticConstructor = @arrow.array.Int16Array.fromMATLAB
TypeConstructor = @arrow.type.Int16Type
TypeClassName = "arrow.type.Int16Type"
TypeProxyClassName = "arrow.type.proxy.Int16Type"
MatlabConstructor = @int16
Expand Down
1 change: 1 addition & 0 deletions matlab/src/matlab/+arrow/+type/+traits/Int32Traits.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
ArrayConstructor = @arrow.array.Int32Array
ArrayClassName = "arrow.array.Int32Array"
ArrayProxyClassName = "arrow.array.proxy.Int32Array"
ArrayStaticConstructor = @arrow.array.Int32Array.fromMATLAB
TypeConstructor = @arrow.type.Int32Type;
TypeClassName = "arrow.type.Int32Type"
TypeProxyClassName = "arrow.type.proxy.Int32Type"
Expand Down
3 changes: 2 additions & 1 deletion matlab/src/matlab/+arrow/+type/+traits/Int64Traits.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
ArrayConstructor = @arrow.array.Int64Array
ArrayClassName = "arrow.array.Int64Array"
ArrayProxyClassName = "arrow.array.proxy.Int64Array"
TypeConstructor = @arrow.type.Int64Type;
ArrayStaticConstructor = @arrow.array.Int64Array.fromMATLAB
TypeConstructor = @arrow.type.Int64Type
TypeClassName = "arrow.type.Int64Type"
TypeProxyClassName = "arrow.type.proxy.Int64Type"
MatlabConstructor = @int64
Expand Down
3 changes: 2 additions & 1 deletion matlab/src/matlab/+arrow/+type/+traits/Int8Traits.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
ArrayConstructor = @arrow.array.Int8Array
ArrayClassName = "arrow.array.Int8Array"
ArrayProxyClassName = "arrow.array.proxy.Int8Array"
TypeConstructor = @arrow.type.Int8Type;
ArrayStaticConstructor = @arrow.array.Int8Array.fromMATLAB
TypeConstructor = @arrow.type.Int8Type
TypeClassName = "arrow.type.Int8Type"
TypeProxyClassName = "arrow.type.proxy.Int8Type"
MatlabConstructor = @int8
Expand Down
3 changes: 2 additions & 1 deletion matlab/src/matlab/+arrow/+type/+traits/StringTraits.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
ArrayConstructor = @arrow.array.StringArray
ArrayClassName = "arrow.array.StringArray"
ArrayProxyClassName = "arrow.array.proxy.StringArray"
TypeConstructor = @arrow.type.StringType;
ArrayStaticConstructor = @arrow.array.StringArray.fromMATLAB
TypeConstructor = @arrow.type.StringType
TypeClassName = "arrow.type.StringType"
TypeProxyClassName = "arrow.type.proxy.StringType"
MatlabConstructor = @string
Expand Down
1 change: 1 addition & 0 deletions matlab/src/matlab/+arrow/+type/+traits/Time32Traits.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
ArrayConstructor = @arrow.array.Time32Array
ArrayClassName = "arrow.array.Time32Array"
ArrayProxyClassName = "arrow.array.proxy.Time32Array"
ArrayStaticConstructor = @arrow.array.Time32Array.fromMATLAB
TypeConstructor = @arrow.type.Time32Type;
TypeClassName = "arrow.type.Time32Type"
TypeProxyClassName = "arrow.type.proxy.Time32Type"
Expand Down
1 change: 1 addition & 0 deletions matlab/src/matlab/+arrow/+type/+traits/Time64Traits.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
ArrayConstructor = @arrow.array.Time64Array
ArrayClassName = "arrow.array.Time64Array"
ArrayProxyClassName = "arrow.array.proxy.Time64Array"
ArrayStaticConstructor = @arrow.array.Time64Array.fromMATLAB
TypeConstructor = @arrow.type.Time64Type;
TypeClassName = "arrow.type.Time64Type"
TypeProxyClassName = "arrow.type.proxy.Time64Type"
Expand Down
3 changes: 2 additions & 1 deletion matlab/src/matlab/+arrow/+type/+traits/TimestampTraits.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
ArrayConstructor = @arrow.array.TimestampArray
ArrayClassName = "arrow.array.TimestampArray"
ArrayProxyClassName = "arrow.array.proxy.TimestampArray"
TypeConstructor = @arrow.type.TimestampType;
ArrayStaticConstructor = @arrow.array.TimestampArray.fromMATLAB
TypeConstructor = @arrow.type.TimestampType
TypeClassName = "arrow.type.TimestampType"
TypeProxyClassName = "arrow.type.proxy.TimestampType"
MatlabConstructor = @datetime
Expand Down
1 change: 1 addition & 0 deletions matlab/src/matlab/+arrow/+type/+traits/TypeTraits.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
ArrayConstructor
ArrayClassName
ArrayProxyClassName
ArrayStaticConstructor
TypeConstructor
TypeClassName
TypeProxyClassName
Expand Down
3 changes: 2 additions & 1 deletion matlab/src/matlab/+arrow/+type/+traits/UInt16Traits.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
ArrayConstructor = @arrow.array.UInt16Array
ArrayClassName = "arrow.array.UInt16Array"
ArrayProxyClassName = "arrow.array.proxy.UInt16Array"
TypeConstructor = @arrow.type.UInt16Type;
ArrayStaticConstructor = @arrow.array.UInt16Array.fromMATLAB
TypeConstructor = @arrow.type.UInt16Type
TypeClassName = "arrow.type.UInt16Type"
TypeProxyClassName = "arrow.type.proxy.UInt16Type"
MatlabConstructor = @uint16
Expand Down
3 changes: 2 additions & 1 deletion matlab/src/matlab/+arrow/+type/+traits/UInt32Traits.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
ArrayConstructor = @arrow.array.UInt32Array
ArrayClassName = "arrow.array.UInt32Array"
ArrayProxyClassName = "arrow.array.proxy.UInt32Array"
TypeConstructor = @arrow.type.UInt32Type;
ArrayStaticConstructor = @arrow.array.UInt32Array.fromMATLAB
TypeConstructor = @arrow.type.UInt32Type
TypeClassName = "arrow.type.UInt32Type"
TypeProxyClassName = "arrow.type.proxy.UInt32Type"
MatlabConstructor = @uint32
Expand Down
3 changes: 2 additions & 1 deletion matlab/src/matlab/+arrow/+type/+traits/UInt64Traits.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
ArrayConstructor = @arrow.array.UInt64Array
ArrayClassName = "arrow.array.UInt64Array"
ArrayProxyClassName = "arrow.array.proxy.UInt64Array"
TypeConstructor = @arrow.type.UInt64Type;
ArrayStaticConstructor = @arrow.array.UInt64Array.fromMATLAB
TypeConstructor = @arrow.type.UInt64Type
TypeClassName = "arrow.type.UInt64Type"
TypeProxyClassName = "arrow.type.proxy.UInt64Type"
MatlabConstructor = @uint64
Expand Down
3 changes: 2 additions & 1 deletion matlab/src/matlab/+arrow/+type/+traits/UInt8Traits.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
ArrayConstructor = @arrow.array.UInt8Array
ArrayClassName = "arrow.array.UInt8Array"
ArrayProxyClassName = "arrow.array.proxy.UInt8Array"
TypeConstructor = @arrow.type.UInt8Type;
ArrayStaticConstructor = @arrow.array.UInt8Array.fromMATLAB
TypeConstructor = @arrow.type.UInt8Type
TypeClassName = "arrow.type.UInt8Type"
TypeProxyClassName = "arrow.type.proxy.UInt8Type"
MatlabConstructor = @uint8
Expand Down
5 changes: 5 additions & 0 deletions matlab/test/arrow/type/traits/hTypeTraits.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
ArrayConstructor
ArrayClassName
ArrayProxyClassName
ArrayStaticConstructor
TypeConstructor
TypeClassName
TypeProxyClassName
Expand Down Expand Up @@ -53,6 +54,10 @@ function TestArrayProxyClassName(testCase)
testCase.verifyEqual(testCase.Traits.ArrayProxyClassName, testCase.ArrayProxyClassName);
end

function TestArrayStaticConstructor(testCase)
testCase.verifyEqual(testCase.Traits.ArrayStaticConstructor, testCase.ArrayStaticConstructor);
end

function TestTypeConstructor(testCase)
testCase.verifyEqual(testCase.Traits.TypeConstructor, testCase.TypeConstructor);
end
Expand Down
1 change: 1 addition & 0 deletions matlab/test/arrow/type/traits/tBooleanTraits.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
ArrayConstructor = @arrow.array.BooleanArray
ArrayClassName = "arrow.array.BooleanArray"
ArrayProxyClassName = "arrow.array.proxy.BooleanArray"
ArrayStaticConstructor = @arrow.array.BooleanArray.fromMATLAB
TypeConstructor = @arrow.type.BooleanType
TypeClassName = "arrow.type.BooleanType"
TypeProxyClassName = "arrow.type.proxy.BooleanType"
Expand Down
1 change: 1 addition & 0 deletions matlab/test/arrow/type/traits/tInt16Traits.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
ArrayConstructor = @arrow.array.Int16Array
ArrayClassName = "arrow.array.Int16Array"
ArrayProxyClassName = "arrow.array.proxy.Int16Array"
ArrayStaticConstructor = @arrow.array.Int16Array.fromMATLAB
TypeConstructor = @arrow.type.Int16Type
TypeClassName = "arrow.type.Int16Type"
TypeProxyClassName = "arrow.type.proxy.Int16Type"
Expand Down
1 change: 1 addition & 0 deletions matlab/test/arrow/type/traits/tInt32Traits.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
ArrayConstructor = @arrow.array.Int32Array
ArrayClassName = "arrow.array.Int32Array"
ArrayProxyClassName = "arrow.array.proxy.Int32Array"
ArrayStaticConstructor = @arrow.array.Int32Array.fromMATLAB
TypeConstructor = @arrow.type.Int32Type
TypeClassName = "arrow.type.Int32Type"
TypeProxyClassName = "arrow.type.proxy.Int32Type"
Expand Down
1 change: 1 addition & 0 deletions matlab/test/arrow/type/traits/tInt64Traits.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
ArrayConstructor = @arrow.array.Int64Array
ArrayClassName = "arrow.array.Int64Array"
ArrayProxyClassName = "arrow.array.proxy.Int64Array"
ArrayStaticConstructor = @arrow.array.Int64Array.fromMATLAB
TypeConstructor = @arrow.type.Int64Type
TypeClassName = "arrow.type.Int64Type"
TypeProxyClassName = "arrow.type.proxy.Int64Type"
Expand Down
1 change: 1 addition & 0 deletions matlab/test/arrow/type/traits/tInt8Traits.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
ArrayConstructor = @arrow.array.Int8Array
ArrayClassName = "arrow.array.Int8Array"
ArrayProxyClassName = "arrow.array.proxy.Int8Array"
ArrayStaticConstructor = @arrow.array.Int8Array.fromMATLAB
TypeConstructor = @arrow.type.Int8Type
TypeClassName = "arrow.type.Int8Type"
TypeProxyClassName = "arrow.type.proxy.Int8Type"
Expand Down
1 change: 1 addition & 0 deletions matlab/test/arrow/type/traits/tStringTraits.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
ArrayConstructor = @arrow.array.StringArray
ArrayClassName = "arrow.array.StringArray"
ArrayProxyClassName = "arrow.array.proxy.StringArray"
ArrayStaticConstructor = @arrow.array.StringArray.fromMATLAB
TypeConstructor = @arrow.type.StringType
TypeClassName = "arrow.type.StringType"
TypeProxyClassName = "arrow.type.proxy.StringType"
Expand Down
1 change: 1 addition & 0 deletions matlab/test/arrow/type/traits/tTime32Traits.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
ArrayConstructor = @arrow.array.Time32Array
ArrayClassName = "arrow.array.Time32Array"
ArrayProxyClassName = "arrow.array.proxy.Time32Array"
ArrayStaticConstructor = @arrow.array.Time32Array.fromMATLAB
TypeConstructor = @arrow.type.Time32Type
TypeClassName = "arrow.type.Time32Type"
TypeProxyClassName = "arrow.type.proxy.Time32Type"
Expand Down
1 change: 1 addition & 0 deletions matlab/test/arrow/type/traits/tTime64Traits.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
ArrayConstructor = @arrow.array.Time64Array
ArrayClassName = "arrow.array.Time64Array"
ArrayProxyClassName = "arrow.array.proxy.Time64Array"
ArrayStaticConstructor = @arrow.array.Time64Array.fromMATLAB
TypeConstructor = @arrow.type.Time64Type
TypeClassName = "arrow.type.Time64Type"
TypeProxyClassName = "arrow.type.proxy.Time64Type"
Expand Down
1 change: 1 addition & 0 deletions matlab/test/arrow/type/traits/tTimestampTraits.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
ArrayConstructor = @arrow.array.TimestampArray
ArrayClassName = "arrow.array.TimestampArray"
ArrayProxyClassName = "arrow.array.proxy.TimestampArray"
ArrayStaticConstructor = @arrow.array.TimestampArray.fromMATLAB
TypeConstructor = @arrow.type.TimestampType
TypeClassName = "arrow.type.TimestampType"
TypeProxyClassName = "arrow.type.proxy.TimestampType"
Expand Down
1 change: 1 addition & 0 deletions matlab/test/arrow/type/traits/tUInt16Traits.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
ArrayConstructor = @arrow.array.UInt16Array
ArrayClassName = "arrow.array.UInt16Array"
ArrayProxyClassName = "arrow.array.proxy.UInt16Array"
ArrayStaticConstructor = @arrow.array.UInt16Array.fromMATLAB
TypeConstructor = @arrow.type.UInt16Type
TypeClassName = "arrow.type.UInt16Type"
TypeProxyClassName = "arrow.type.proxy.UInt16Type"
Expand Down
1 change: 1 addition & 0 deletions matlab/test/arrow/type/traits/tUInt32Traits.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
ArrayConstructor = @arrow.array.UInt32Array
ArrayClassName = "arrow.array.UInt32Array"
ArrayProxyClassName = "arrow.array.proxy.UInt32Array"
ArrayStaticConstructor = @arrow.array.UInt32Array.fromMATLAB
TypeConstructor = @arrow.type.UInt32Type
TypeClassName = "arrow.type.UInt32Type"
TypeProxyClassName = "arrow.type.proxy.UInt32Type"
Expand Down
1 change: 1 addition & 0 deletions matlab/test/arrow/type/traits/tUInt64Traits.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
ArrayConstructor = @arrow.array.UInt64Array
ArrayClassName = "arrow.array.UInt64Array"
ArrayProxyClassName = "arrow.array.proxy.UInt64Array"
ArrayStaticConstructor = @arrow.array.UInt64Array.fromMATLAB
TypeConstructor = @arrow.type.UInt64Type
TypeClassName = "arrow.type.UInt64Type"
TypeProxyClassName = "arrow.type.proxy.UInt64Type"
Expand Down
1 change: 1 addition & 0 deletions matlab/test/arrow/type/traits/tUInt8Traits.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
ArrayConstructor = @arrow.array.UInt8Array
ArrayClassName = "arrow.array.UInt8Array"
ArrayProxyClassName = "arrow.array.proxy.UInt8Array"
ArrayStaticConstructor = @arrow.array.UInt8Array.fromMATLAB
TypeConstructor = @arrow.type.UInt8Type
TypeClassName = "arrow.type.UInt8Type"
TypeProxyClassName = "arrow.type.proxy.UInt8Type"
Expand Down

0 comments on commit 4586689

Please sign in to comment.