sgilmore10 opened a new pull request, #37525:
URL: https://github.com/apache/arrow/pull/37525
<!--
Thanks for opening a pull request!
If this is your first pull request you can find detailed information on how
to contribute here:
* [New Contributor's
Guide](https://arrow.apache.org/docs/dev/developers/guide/step_by_step/pr_lifecycle.html#reviews-and-merge-of-the-pull-request)
* [Contributing
Overview](https://arrow.apache.org/docs/dev/developers/overview.html)
If this is not a [minor
PR](https://github.com/apache/arrow/blob/main/CONTRIBUTING.md#Minor-Fixes).
Could you open an issue for this pull request on GitHub?
https://github.com/apache/arrow/issues/new/choose
Opening GitHub issues ahead of time contributes to the
[Openness](http://theapacheway.com/open/#:~:text=Openness%20allows%20new%20users%20the,must%20happen%20in%20the%20open.)
of the Apache Arrow project.
Then could you also rename the pull request title in the following format?
GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
or
MINOR: [${COMPONENT}] ${SUMMARY}
In the case of PARQUET issues on JIRA the title also supports:
PARQUET-${JIRA_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
-->
### Rationale for this change
In order to add an `arrow.tabular.Table` class to the MATLAB Interface, we
first need to add a MATLAB class representing `arrow::ChunkedArray`s. This is
required because an `arrow::Table` is backed by a vector of
`arrow::ChunkedArray`s, and the output of its `column(int index)` method is an
`arrow::ChunkedArray`.
### What changes are included in this PR?
1. Introduced a new class called `arrow.array.ChunkedArray`.
2. `arrow.array.ChunkedArray` has the following properties:
1. `Type` - datatype of the `arrow.array.Array`s
2. `Length` - Sum of the `arrow.array.Array` lengths
3. `NumChunks` - Number of `arrow.array.Array`s
3. `arrow.array.ChunkedArray` has the following methods:
1. `chunk(index)` - Returns the `arrow.array.Array` stored at the
specified index
2. `fromArrays(array1, array1, ..., arrayN, Type=type)` - Creates a
`ChunkedArray` from the arrays provided. If `Type` is provided, all arrays are
expected to have the specified `Type`.
**Example Usage**
```matlab
>> a1 = arrow.array(1:100);
>> a2 = arrow.array(101:250);
>> a3 = arrow.array(251:300);
% Create a ChunkedArray from 3 Float64Arrays
>> c = arrow.array.ChunkedArray.fromArrays(a1, a2, a3)
c =
ChunkedArray with properties:
Type: [1×1 arrow.type.Float64Type]
NumChunks: 3
Length: 300
% Extract the first chunk and compare it to a1
>> c1 = c.chunk(1);
>> tf = isequal(c1, a1)
tf =
logical
1
% Create an empty ChunkedArray by providing the Type nv-pair
>> c = arrow.array.ChunkedArray.fromArrays(Type=arrow.timestamp())
c =
ChunkedArray with properties:
Type: [1×1 arrow.type.TimestampType]
NumChunks: 0
Length: 0
```
### Are these changes tested?
Yes. I added a new test class called `tChunkedArray.m` that contains unit
tests for the new class.
### Are there any user-facing changes?
Yes. Users can now create a `ChunkedArray` in the MATLAB Interface.
### Future Directions
1. In this PR, we deliberately didn't include a convenience constructor
function because we're not sure if we want users to create `ChunkedArray`s
themselves. We think users will mostly use `ChunkedArray` when extracting
columns from `Table`s.
2. We will implement more methods on `ChunkedArray`, such as `flatten()` and
`combineChunks()`, etc.
--
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]