| 60 | } |
| 61 | |
| 62 | libmexclass::proxy::MakeResult ChunkedArray::make( |
| 63 | const libmexclass::proxy::FunctionArguments& constructor_arguments) { |
| 64 | namespace mda = ::matlab::data; |
| 65 | |
| 66 | mda::StructArray opts = constructor_arguments[0]; |
| 67 | const mda::TypedArray<uint64_t> array_proxy_ids = opts[0]["ArrayProxyIDs"]; |
| 68 | const mda::TypedArray<uint64_t> type_proxy_id = opts[0]["TypeProxyID"]; |
| 69 | |
| 70 | std::vector<std::shared_ptr<arrow::Array>> arrays; |
| 71 | // Retrieve all of the Array Proxy instances from the libmexclass ProxyManager. |
| 72 | for (const auto& array_proxy_id : array_proxy_ids) { |
| 73 | auto proxy = libmexclass::proxy::ProxyManager::getProxy(array_proxy_id); |
| 74 | auto array_proxy = std::static_pointer_cast<proxy::Array>(proxy); |
| 75 | auto array = array_proxy->unwrap(); |
| 76 | arrays.push_back(array); |
| 77 | } |
| 78 | |
| 79 | auto proxy = libmexclass::proxy::ProxyManager::getProxy(type_proxy_id[0]); |
| 80 | auto type_proxy = std::static_pointer_cast<type::proxy::Type>(proxy); |
| 81 | auto type = type_proxy->unwrap(); |
| 82 | |
| 83 | MATLAB_ASSIGN_OR_ERROR(auto chunked_array, arrow::ChunkedArray::Make(arrays, type), |
| 84 | error::CHUNKED_ARRAY_MAKE_FAILED); |
| 85 | |
| 86 | return std::make_unique<proxy::ChunkedArray>(std::move(chunked_array)); |
| 87 | } |
| 88 | |
| 89 | std::shared_ptr<arrow::ChunkedArray> ChunkedArray::unwrap() { return chunked_array; } |
| 90 | |