Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-38354: [MATLAB] Implement fromMATLAB method for arrow.array.ListArray #38561

Merged
merged 20 commits into from
Nov 2, 2023

Conversation

sgilmore10
Copy link
Member

@sgilmore10 sgilmore10 commented Nov 2, 2023

Rationale for this change

We should implement a static fromMATLAB method for arrow.array.ListArray that takes in a MATLAB cell array and returns an instance of arrow.array.ListArray. Adding this method enables users to create an arrow.array.ListArray by passing a MATLAB cell array to the arrow.array gateway function:

>> C = {[1 2 3], [4 5], 6};
>> array = arrow.array(C)

array = 

  ListArray with 3 elements and 0 null values:

    [
        [
            1,
            2,
            3
        ],
        [
            4,
            5
        ],
        [
            6
        ]
    ]

Internally, the arrow.array gateway function will call arrow.array.ListArray.fromMATLAB to construct a ListArray from the given cell array.

What changes are included in this PR?

  1. Implemented fromMATLAB method on arrow.array.ListArray. This method accepts a MATLAB cell array and returns an instance of arrow.array.ListArray.
  2. Set the ArrayStaticConstructor property of arrow.type.traits.ListTraits to @arrow.array.ListArray.fromMATLAB.
  3. Added a switch case for "cell" to the arrow.array gateway function that invokes arrow.array.ListArray.fromMATLAB with the input cell array.

Are these changes tested?

Yes. I added a new test class to the test/arrow/array/list folder named tFromMATLAB.m.

Are there any user-facing changes?

Yes. Users can now create instances of arrow.array.ListArray by passing cell arrays to arrow.array:

>> C = {["A" "B"], ["C" "D" "E"], missing, ["F" "G"], string.empty(0, 1)};
>> array = arrow.array(C)

array = 

  ListArray with 5 elements and 1 null value:

    [
        [
            "A",
            "B"
        ],
        [
            "C",
            "D",
            "E"
        ],
        null,
        [
            "F",
            "G"
        ],
        []
    ]

Copy link
Member

@kevingurney kevingurney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! It's really nice to see support for nested cell arrays being added to arrow.array!

matlab/src/matlab/+arrow/+array/ListArray.m Outdated Show resolved Hide resolved
matlab/src/matlab/+arrow/+array/ListArray.m Show resolved Hide resolved
matlab/src/matlab/+arrow/+array/ListArray.m Outdated Show resolved Hide resolved
matlab/src/matlab/+arrow/+array/ListArray.m Show resolved Hide resolved
matlab/src/matlab/+arrow/+array/ListArray.m Outdated Show resolved Hide resolved
matlab/test/arrow/array/list/tFromMATLAB.m Outdated Show resolved Hide resolved
matlab/test/arrow/array/list/tFromMATLAB.m Outdated Show resolved Hide resolved
matlab/test/arrow/array/list/tFromMATLAB.m Outdated Show resolved Hide resolved
matlab/test/arrow/array/list/tFromMATLAB.m Show resolved Hide resolved
@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting review Awaiting review labels Nov 2, 2023
@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Nov 2, 2023
@kevingurney
Copy link
Member

+1

@github-actions github-actions bot added awaiting merge Awaiting merge and removed awaiting change review Awaiting change review labels Nov 2, 2023
@kevingurney kevingurney merged commit cd6e635 into apache:main Nov 2, 2023
9 checks passed
@kevingurney kevingurney deleted the GH-38354 branch November 2, 2023 20:25
@kevingurney kevingurney removed the awaiting merge Awaiting merge label Nov 2, 2023
Copy link

After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit cd6e635.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 2 possible false positives for unstable benchmarks that are known to sometimes produce them.

loicalleyne pushed a commit to loicalleyne/arrow that referenced this pull request Nov 13, 2023
…ay.ListArray` (apache#38561)

### Rationale for this change

We should implement a static `fromMATLAB` method for `arrow.array.ListArray` that takes in a MATLAB `cell` array and returns an instance of `arrow.array.ListArray`. Adding this method enables users to create an `arrow.array.ListArray` by passing a MATLAB `cell` array to the `arrow.array` gateway function:

```matlab
>> C = {[1 2 3], [4 5], 6};
>> array = arrow.array(C)

array = 

  ListArray with 3 elements and 0 null values:

    [
        [
            1,
            2,
            3
        ],
        [
            4,
            5
        ],
        [
            6
        ]
    ]
```
Internally, the `arrow.array` gateway function will call `arrow.array.ListArray.fromMATLAB` to construct a `ListArray` from the given `cell` array.

### What changes are included in this PR?

1. Implemented `fromMATLAB` method on `arrow.array.ListArray`. This method accepts a MATLAB `cell` array and returns an instance of `arrow.array.ListArray`. 
2. Set the `ArrayStaticConstructor` property of `arrow.type.traits.ListTraits` to `@ arrow.array.ListArray.fromMATLAB`.
3. Added a switch case for `"cell"` to the `arrow.array` gateway function that invokes `arrow.array.ListArray.fromMATLAB` with the input `cell` array.

### Are these changes tested?

Yes. I added a new test class to the `test/arrow/array/list` folder named `tFromMATLAB.m`.

### Are there any user-facing changes?

Yes. Users can now create instances of `arrow.array.ListArray` by passing `cell` arrays to `arrow.array`:

```matlab
>> C = {["A" "B"], ["C" "D" "E"], missing, ["F" "G"], string.empty(0, 1)};
>> array = arrow.array(C)

array = 

  ListArray with 5 elements and 1 null value:

    [
        [
            "A",
            "B"
        ],
        [
            "C",
            "D",
            "E"
        ],
        null,
        [
            "F",
            "G"
        ],
        []
    ]

```

* Closes: apache#38354

Authored-by: Sarah Gilmore <[email protected]>
Signed-off-by: Kevin Gurney <[email protected]>
dgreiss pushed a commit to dgreiss/arrow that referenced this pull request Feb 19, 2024
…ay.ListArray` (apache#38561)

### Rationale for this change

We should implement a static `fromMATLAB` method for `arrow.array.ListArray` that takes in a MATLAB `cell` array and returns an instance of `arrow.array.ListArray`. Adding this method enables users to create an `arrow.array.ListArray` by passing a MATLAB `cell` array to the `arrow.array` gateway function:

```matlab
>> C = {[1 2 3], [4 5], 6};
>> array = arrow.array(C)

array = 

  ListArray with 3 elements and 0 null values:

    [
        [
            1,
            2,
            3
        ],
        [
            4,
            5
        ],
        [
            6
        ]
    ]
```
Internally, the `arrow.array` gateway function will call `arrow.array.ListArray.fromMATLAB` to construct a `ListArray` from the given `cell` array.

### What changes are included in this PR?

1. Implemented `fromMATLAB` method on `arrow.array.ListArray`. This method accepts a MATLAB `cell` array and returns an instance of `arrow.array.ListArray`. 
2. Set the `ArrayStaticConstructor` property of `arrow.type.traits.ListTraits` to `@ arrow.array.ListArray.fromMATLAB`.
3. Added a switch case for `"cell"` to the `arrow.array` gateway function that invokes `arrow.array.ListArray.fromMATLAB` with the input `cell` array.

### Are these changes tested?

Yes. I added a new test class to the `test/arrow/array/list` folder named `tFromMATLAB.m`.

### Are there any user-facing changes?

Yes. Users can now create instances of `arrow.array.ListArray` by passing `cell` arrays to `arrow.array`:

```matlab
>> C = {["A" "B"], ["C" "D" "E"], missing, ["F" "G"], string.empty(0, 1)};
>> array = arrow.array(C)

array = 

  ListArray with 5 elements and 1 null value:

    [
        [
            "A",
            "B"
        ],
        [
            "C",
            "D",
            "E"
        ],
        null,
        [
            "F",
            "G"
        ],
        []
    ]

```

* Closes: apache#38354

Authored-by: Sarah Gilmore <[email protected]>
Signed-off-by: Kevin Gurney <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[MATLAB] Implement fromMATLAB method for arrow.array.ListArray.
2 participants