kevingurney commented on code in PR #45973:
URL: https://github.com/apache/arrow/pull/45973#discussion_r2029335367
##########
matlab/doc/matlab_interface_for_apache_arrow_design.md:
##########
@@ -179,22 +180,28 @@ Roughly speaking, local memory sharing workflows can be
divided into two categor
To share a MATLAB `arrow.Array` with PyArrow efficiently, a user could use the
`exportToCDataInterface` method to export the Arrow memory wrapped by an
`arrow.Array` to the C Data Interface format, consisting of two C-style
structs, [`ArrowArray`] and [`ArrowSchema`], which represent the Arrow data and
associated metadata.
-Memory addresses to the `ArrowArray` and `ArrowSchema` structs are returned by
the call to `exportToCDataInterface`. These addresses can be passed to Python
directly, without having to make any copies of the underlying Arrow data
structures that they refer to. A user can then wrap the underlying data pointed
to by the `ArrowArray` struct (which is already in the [Arrow Columnar
Format]), as well as extract the necessary metadata from the `ArrowSchema`
struct, to create a `pyarrow.Array` by using the static method
`py.pyarrow.Array._import_from_c`.
+Memory addresses to the `ArrowArray` and `ArrowSchema` structs are returned by
the call to `export`. These addresses can be passed to Python directly, without
having to make any copies of the underlying Arrow data structures that they
refer to. A user can then wrap the underlying data pointed to by the
`ArrowArray` struct (which is already in the [Arrow Columnar Format]), as well
as extract the necessary metadata from the `ArrowSchema` struct, to create a
`pyarrow.Array` by using the static method `pyarrow.Array._import_from_c`.
###### Example Code:
``` matlab
% Create a MATLAB arrow.Array.
>> AA = arrow.array([1, 2, 3, 4, 5]);
+% create C Data Interface for array values and schema
+>> cArray = arrow.c.Array();
+>> cSchema = arrow.c.Schema();
+
% Export the MATLAB arrow.Array to the C Data Interface format, returning the
% memory addresses of the required ArrowArray and ArrowSchema C-style structs.
->> [arrayMemoryAddress, schemaMemoryAddress] = AA.exportToCDataInterface();
+>> AA.export(cArray.Address, cSchema.Address);
% Import the memory addresses of the C Data Interface format structs to create
a pyarrow.Array.
->> PA = py.pyarrow.Array._import_from_c(arrayMemoryAddress,
schemaMemoryAddress);
+>> PA = pyrun("import pyarrow as pa; array =
pa.Array._import_from_c(arrayMemoryAddress, schemaMemoryAddress)", "array",
arrayMemoryAddress=cArray.Address, schemaMemoryAddress=cSchema.Address);
Review Comment:
The latest changes use `pyrunfile`. Marking this as resolved.
--
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]