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-35550: [MATLAB] Add public toMATLAB method to arrow.array.Array for converting to MATLAB types #35551

Merged
merged 4 commits into from
May 16, 2023

Conversation

kevingurney
Copy link
Member

@kevingurney kevingurney commented May 11, 2023

Rationale for this change

In order to allow clients to write generic code for different concrete arrow.array.Array subclasses in MATLAB, it would be helpful to have one generic toMATLAB method. toMATLAB would convert the arrow.array.Array into a corresponding MATLAB type.

For example, arrow.array.Float64Array would be converted to a MATLAB double array.

>> doubleMatlabArray = toMATLAB(float64ArrowArray) % Convert the arrow.array.Float64Array to a MATLAB double array

What changes are included in this PR?

  1. Added a public toMATLAB method to the arrow.array.Array superclass.

Example of using toMATLAB on an arrow.array.Float64Array:

>> arrowArray = arrow.array.Float64Array(1:10)

arrowArray = 

[
  1,
  2,
  3,
  4,
  5,
  6,
  7,
  8,
  9,
  10
]
>> matlabArray = toMATLAB(arrowArray)

matlabArray =

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10

>> class(matlabArray)

ans =

    'double'

Are these changes tested?

  1. Yes, we added tests for toMATLAB to tFloat32Array.m and tFloat64Array.m.
  2. This was qualified on a Debian 11 machine.

Future Directions

  1. Move the toMATLAB tests to the shared test utility class (i.e. [MATLAB] Create shared test class utility for numeric arrays. #35537).

Notes

  1. Thanks to @sgilmore10 for her help with this pull request!

@github-actions
Copy link

Thanks for opening a pull request!

If this is not a minor PR. 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 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}

See also:

@kevingurney kevingurney changed the title Gh 35550 GH-35550: [MATLAB] Add public toMATLAB method to arrow.array.Array for converting to MATLAB types May 11, 2023
@github-actions github-actions bot added the awaiting review Awaiting review label May 11, 2023
kevingurney and others added 2 commits May 15, 2023 11:49
…oxy ToMatlab to toMATLAB.

Co-authored-by: Sarah Gilmore <sgilmore@mathworks.com>
Co-authored-by: Kevin Gurney <kgurney@mathworks.com>
@kevingurney kevingurney marked this pull request as ready for review May 15, 2023 16:12
matlab/test/arrow/array/tFloat32Array.m Outdated Show resolved Hide resolved
Comment on lines 25 to 26
REGISTER_METHOD(Array, ToString);
REGISTER_METHOD(Array, ToMatlab);
REGISTER_METHOD(Array, toMATLAB);
Copy link
Member

Choose a reason for hiding this comment

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

I'm not familiar with MATLAB API but is it natural that ToString uses T and toMATLAB uses t?

Copy link
Member

Choose a reason for hiding this comment

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

Hi @kou, That's a mistake on our part. ToString should be toString. Typically, we use lower camel case for MATLAB method names. Thanks for catching this!

Copy link
Member

@sgilmore10 sgilmore10 May 16, 2023

Choose a reason for hiding this comment

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

  1. Changed ToString() to toString().
  2. Also renamed the c++ method Length() to length(). However, since this Length is a property on the MATLAB arrow.array.Array class, I left the property name alone. In MATLAB, property names are typically upper camel case.

Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
@github-actions github-actions bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels May 16, 2023
2. Rename Length() c++ method to length()
Copy link
Member

@kou kou left a comment

Choose a reason for hiding this comment

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

+1

@kou kou merged commit 88339cd into apache:main May 16, 2023
9 checks passed
@github-actions github-actions bot added awaiting merge Awaiting merge and removed awaiting committer review Awaiting committer review labels May 16, 2023
@ursabot
Copy link

ursabot commented May 19, 2023

Benchmark runs are scheduled for baseline = 505a2e4 and contender = 88339cd. 88339cd is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Finished ⬇️0.29% ⬆️0.09%] test-mac-arm
[Finished ⬇️1.02% ⬆️0.0%] ursa-i9-9960x
[Finished ⬇️0.27% ⬆️0.06%] ursa-thinkcentre-m75q
Buildkite builds:
[Finished] 88339cd8 ec2-t3-xlarge-us-east-2
[Finished] 88339cd8 test-mac-arm
[Finished] 88339cd8 ursa-i9-9960x
[Finished] 88339cd8 ursa-thinkcentre-m75q
[Finished] 505a2e45 ec2-t3-xlarge-us-east-2
[Finished] 505a2e45 test-mac-arm
[Finished] 505a2e45 ursa-i9-9960x
[Finished] 505a2e45 ursa-thinkcentre-m75q
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

@ursabot
Copy link

ursabot commented May 19, 2023

['Python', 'R'] benchmarks have high level of regressions.
ursa-i9-9960x

@sgilmore10 sgilmore10 deleted the GH-35550 branch June 27, 2023 23:52
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 public toMATLAB method to arrow.array.Array for converting to MATLAB types
4 participants