arrow icon indicating copy to clipboard operation
arrow copied to clipboard

GH-38369: [MATLAB] Create utility functions for simplifying management of `Proxy` instances for `Array`s

Open sgilmore10 opened this issue 6 months ago • 0 comments

Rationale for this change

This is a follow up to https://github.com/apache/arrow/pull/38357#discussion_r1365908049.

In the C++ code for the MATLAB interface, we frequently wrap/unwrap Arrow types, like arrow::Array, into/from a corresponding libmexclass Proxy objects. This currently takes several lines of code, leading to lots of code duplication and introduces room for subtle implementation errors.

It would be helpful to abstract away some of the steps involved in Proxy creation/management into a set of helper utilities that we can reuse in the C++ code for the MATLAB interface.

What changes are included in this PR?

  1. Added a new utility function that wraps a std::shared_ptr<arrow::Array> in a std::shared_ptr<arrow::matlab::array::proxy::Array>. Its function signature is
arrow::Result<std::shared_ptr<arrow::matlab::array::proxy::Array>> wrap(const std::shared_ptr<arrow::Array>& array);`
  1. Added a new utility function that wraps a std::shared_ptr<arrow::Array> in a std::shared_ptr<arrow::matlab::array::proxy::Array> and adds the proxy to the libmexclass::proxy::ProxyManager. Its function signature is
arrow::Result<std::shared_ptr<arrow::matlab::array::proxy::Array>> wrap_and_manage(const std::shared_ptr<arrow::Array>& array);
  1. Added a new utility function that wraps a std::shared_ptr<arrow::DataType> in a std::shared_ptr<arrow::matlab::type::proxy::Type>. Its function signature is
arrow::Result<std::shared_ptr<arrow::matlab::type::proxy::Type>> wrap(const std::shared_ptr<arrow::DataType>& type);
  1. Added a new utility function that wraps a std::shared_ptr<arrow::DataType> in a std::shared_ptr<arrow::matlab::type::proxy::DataType> and adds the proxy to the libmexclass::proxy::ProxyManager. It's function signature is
arrow::Result<std::shared_ptr<arrow::matlab::type::proxy::Type>> wrap_and_manage(const std::shared_ptr<arrow::DataType>& type);
  1. Deleted arrow::matlab::array::proxy::wrap and arrow::matlab::type::proxy::wrap functions.

Are these changes tested?

Tested via the existing MATLAB test classes.

Are there any user-facing changes?

No.

  • GitHub Issue: #38369

sgilmore10 avatar Jun 25 '25 17:06 sgilmore10