| 31 | } |
| 32 | |
| 33 | libmexclass::proxy::MakeResult ListArray::make( |
| 34 | const libmexclass::proxy::FunctionArguments& constructor_arguments) { |
| 35 | namespace mda = ::matlab::data; |
| 36 | using libmexclass::proxy::ProxyManager; |
| 37 | using Int32ArrayProxy = arrow::matlab::array::proxy::NumericArray<arrow::Int32Type>; |
| 38 | using ListArrayProxy = arrow::matlab::array::proxy::ListArray; |
| 39 | using ArrayProxy = arrow::matlab::array::proxy::Array; |
| 40 | |
| 41 | mda::StructArray opts = constructor_arguments[0]; |
| 42 | const mda::TypedArray<uint64_t> offsets_proxy_id_mda = opts[0]["OffsetsProxyID"]; |
| 43 | const mda::TypedArray<uint64_t> values_proxy_id_mda = opts[0]["ValuesProxyID"]; |
| 44 | const mda::TypedArray<bool> validity_bitmap_mda = opts[0]["Valid"]; |
| 45 | |
| 46 | const auto offsets_proxy_id = offsets_proxy_id_mda[0]; |
| 47 | const auto values_proxy_id = values_proxy_id_mda[0]; |
| 48 | |
| 49 | const auto offsets_proxy = |
| 50 | std::static_pointer_cast<Int32ArrayProxy>(ProxyManager::getProxy(offsets_proxy_id)); |
| 51 | const auto values_proxy = |
| 52 | std::static_pointer_cast<ArrayProxy>(ProxyManager::getProxy(values_proxy_id)); |
| 53 | |
| 54 | const auto offsets = offsets_proxy->unwrap(); |
| 55 | const auto values = values_proxy->unwrap(); |
| 56 | |
| 57 | // Pack the validity bitmap values. |
| 58 | MATLAB_ASSIGN_OR_ERROR(auto validity_bitmap_buffer, bit::packValid(validity_bitmap_mda), |
| 59 | error::BITPACK_VALIDITY_BITMAP_ERROR_ID); |
| 60 | |
| 61 | // Create a ListArray from values and offsets. |
| 62 | MATLAB_ASSIGN_OR_ERROR( |
| 63 | auto array, |
| 64 | arrow::ListArray::FromArrays(*offsets, *values, arrow::default_memory_pool(), |
| 65 | validity_bitmap_buffer), |
| 66 | error::LIST_ARRAY_FROM_ARRAYS_FAILED); |
| 67 | |
| 68 | // Return a ListArray Proxy. |
| 69 | auto list_array = std::static_pointer_cast<arrow::ListArray>(array); |
| 70 | return std::make_shared<ListArrayProxy>(std::move(list_array)); |
| 71 | } |
| 72 | |
| 73 | void ListArray::getValues(libmexclass::proxy::method::Context& context) { |
| 74 | namespace mda = ::matlab::data; |