arrow
arrow copied to clipboard
GH-38369: [MATLAB] Create utility functions for simplifying management of `Proxy` instances for `Array`s
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?
- Added a new utility function that wraps a
std::shared_ptr<arrow::Array>in astd::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);`
- Added a new utility function that wraps a
std::shared_ptr<arrow::Array>in astd::shared_ptr<arrow::matlab::array::proxy::Array>and adds the proxy to thelibmexclass::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);
- Added a new utility function that wraps a
std::shared_ptr<arrow::DataType>in astd::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);
- Added a new utility function that wraps a
std::shared_ptr<arrow::DataType>in astd::shared_ptr<arrow::matlab::type::proxy::DataType>and adds the proxy to thelibmexclass::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);
- Deleted
arrow::matlab::array::proxy::wrapandarrow::matlab::type::proxy::wrapfunctions.
Are these changes tested?
Tested via the existing MATLAB test classes.
Are there any user-facing changes?
No.
- GitHub Issue: #38369