Skip to content

Conversation

@sgilmore10
Copy link
Member

@sgilmore10 sgilmore10 commented Nov 10, 2023

Rationale for this change

In order to support MATLAB indexing semantics on the arrow.array.Array classes, we first need to add a method for "slicing" an Arrow Array to the C++ Array Proxy classes.

What changes are included in this PR?

  1. Added a slice method to the C++ Arrow Array Proxy class.
  2. Added a slice method to arrow.array.Array. This method invokes the slice method on the proxy class.

Example

>> a = arrow.array([1 2 NaN 4 5 NaN 7])

a = 

  Float64Array with 7 elements and 2 null values:

    1 | 2 | null | 4 | 5 | null | 7

% Note: MATLAB uses 1-based indexing.
>> slice = a.slice(int64(2), int64(4))

slice = 

  Float64Array with 4 elements and 1 null value:

    2 | null | 4 | 5

Are these changes tested?

Yes, added a new test file called tSlice.m.

Are there any user-facing changes?

The slice method is public, but hidden.

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.

Thanks for working on this!

@kevingurney
Copy link
Member

+1

@kevingurney kevingurney merged commit e18ace3 into apache:main Nov 13, 2023
@kevingurney kevingurney deleted the GH-38415 branch November 13, 2023 15:05
@kevingurney kevingurney removed the awaiting review Awaiting review label Nov 13, 2023
@github-actions github-actions bot added the awaiting merge Awaiting merge label Nov 13, 2023
@conbench-apache-arrow
Copy link

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

There were no benchmark performance regressions. 🎉

The full Conbench report has more details.

loicalleyne pushed a commit to loicalleyne/arrow that referenced this pull request Nov 13, 2023
…xy class (apache#38674)

### Rationale for this change

In order to support MATLAB indexing semantics on the `arrow.array.Array` classes, we first need to add a method for "slicing" an Arrow Array to the C++ Array Proxy classes.

### What changes are included in this PR?

1. Added a `slice` method to the C++ Arrow Array Proxy class. 
2. Added a `slice` method to `arrow.array.Array`. This method invokes the `slice` method on the proxy class. 

**Example**

```matlab

>> a = arrow.array([1 2 NaN 4 5 NaN 7])

a = 

  Float64Array with 7 elements and 2 null values:

    1 | 2 | null | 4 | 5 | null | 7

% Note: MATLAB uses 1-based indexing.
>> slice = a.slice(int64(2), int64(4))

slice = 

  Float64Array with 4 elements and 1 null value:

    2 | null | 4 | 5

```

### Are these changes tested?

Yes, added a new test file called `tSlice.m`.

### Are there any user-facing changes?

The `slice` method is public, but [hidden](https://www.mathworks.com/help/matlab/matlab_oop/method-attributes.html). 

* Closes: apache#38415

Authored-by: Sarah Gilmore <sgilmore@mathworks.com>
Signed-off-by: Kevin Gurney <kgurney@mathworks.com>
dgreiss pushed a commit to dgreiss/arrow that referenced this pull request Feb 19, 2024
…xy class (apache#38674)

### Rationale for this change

In order to support MATLAB indexing semantics on the `arrow.array.Array` classes, we first need to add a method for "slicing" an Arrow Array to the C++ Array Proxy classes.

### What changes are included in this PR?

1. Added a `slice` method to the C++ Arrow Array Proxy class. 
2. Added a `slice` method to `arrow.array.Array`. This method invokes the `slice` method on the proxy class. 

**Example**

```matlab

>> a = arrow.array([1 2 NaN 4 5 NaN 7])

a = 

  Float64Array with 7 elements and 2 null values:

    1 | 2 | null | 4 | 5 | null | 7

% Note: MATLAB uses 1-based indexing.
>> slice = a.slice(int64(2), int64(4))

slice = 

  Float64Array with 4 elements and 1 null value:

    2 | null | 4 | 5

```

### Are these changes tested?

Yes, added a new test file called `tSlice.m`.

### Are there any user-facing changes?

The `slice` method is public, but [hidden](https://www.mathworks.com/help/matlab/matlab_oop/method-attributes.html). 

* Closes: apache#38415

Authored-by: Sarah Gilmore <sgilmore@mathworks.com>
Signed-off-by: Kevin Gurney <kgurney@mathworks.com>
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] Add indexing "slice" method to C++ Array Proxy class

2 participants