kevingurney opened a new pull request, #41737:
URL: https://github.com/apache/arrow/pull/41737
### Rationale for this change
Now that #41653 and #41654 have been addressed, we should add MATLAB APIs
for importing/exporting `arrow.array.Array` objects using the C Data Interface
format.
This pull request adds two new APIs for importing and exporting
`arrow.array.Array` objects using the C Data Interface format.
#### Example
```matlab
>> expected = arrow.array([1, 2, 3])
expected =
Float64Array with 3 elements and 0 null values:
1 | 2 | 3
>> cArray = arrow.c.Array()
cArray =
Array with properties:
Address: 140341875084944
>> cSchema = arrow.c.Schema()
cSchema =
Schema with properties:
Address: 140341880022320
% Export the Array to C Data Interface Format
>> expected.export(cArray.Address, cSchema.Address)
% Import the Array from C Data Interface Format
>> actual = arrow.array.Array.import(cArray, cSchema)
actual =
Float64Array with 3 elements and 0 null values:
1 | 2 | 3
% The Array is the same after round-tripping to C Data Interface format
>> isequal(actual, expected)
ans =
logical
1
```
### What changes are included in this PR?
1. Added new `arrow.array.Array.export(cArrowArrayAddress,
cArrowSchemaAddress)` method for exporting `Array` objects to C Data Interface
format.
2. Added new static `arrow.array.Array.import(cArray, cSchema)` method for
importing `Array`s from C Data Interface format.
3. Added new internal `arrow.c.internal.ArrayImporter` class for importing
`Array` objects from C Data Interface format.
### Are these changes tested?
Yes.
1. Added new test file `matlab/test/arrow/c/tRoundTrip.m` with basic
round-trip tests for importing/exporting `Array` objects using the C Data
Interface format.
### Are there any user-facing changes?
Yes.
1. There are now two new user-facing APIs added to the `arrow.array.Array`
class. These are `arrow.array.Array.export(cArrowArrayAddress,
cArrowSchemaAddress)` and `arrow.array.Array.import(cArray, cSchema)`. These
APIs can be used to import/export `Array` objects using the C Data Interface
format.
### Future Directions
1. Add integration tests for sharing data between MATLAB/mlarrow and
Python/pyarrow running in the same process using the [MATLAB interface to
Python](https://www.mathworks.com/help/matlab/call-python-libraries.html).
2. Add support for exporting/importing `arrow.tabular.RecordBatch` objects
using the C Data Interface format.
3. Add support for the Arrow [C stream interface
format](https://arrow.apache.org/docs/format/CStreamInterface.html).
### Notes
1. Thanks @sgilmore10 for your help with this pull request!
--
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]