| 44 | } |
| 45 | |
| 46 | static libmexclass::proxy::MakeResult make( |
| 47 | const libmexclass::proxy::FunctionArguments& constructor_arguments) { |
| 48 | using MatlabBuffer = arrow::matlab::buffer::MatlabBuffer; |
| 49 | using CType = typename arrow::TypeTraits<ArrowType>::CType; |
| 50 | using NumericArray = arrow::NumericArray<ArrowType>; |
| 51 | using NumericArrayProxy = typename proxy::NumericArray<ArrowType>; |
| 52 | |
| 53 | ::matlab::data::StructArray opts = constructor_arguments[0]; |
| 54 | |
| 55 | // Get the mxArray from constructor arguments |
| 56 | const ::matlab::data::TypedArray<CType> numeric_mda = opts[0]["MatlabArray"]; |
| 57 | const ::matlab::data::TypedArray<bool> valid_mda = opts[0]["Valid"]; |
| 58 | |
| 59 | auto data_buffer = std::make_shared<MatlabBuffer>(numeric_mda); |
| 60 | |
| 61 | const auto data_type = arrow::TypeTraits<ArrowType>::type_singleton(); |
| 62 | const auto length = static_cast<int64_t>( |
| 63 | numeric_mda.getNumberOfElements()); // cast size_t to int64_t |
| 64 | |
| 65 | // Pack the validity bitmap values. |
| 66 | MATLAB_ASSIGN_OR_ERROR(auto packed_validity_bitmap, bit::packValid(valid_mda), |
| 67 | error::BITPACK_VALIDITY_BITMAP_ERROR_ID); |
| 68 | auto array_data = |
| 69 | arrow::ArrayData::Make(data_type, length, {packed_validity_bitmap, data_buffer}); |
| 70 | auto numeric_array = |
| 71 | std::static_pointer_cast<NumericArray>(arrow::MakeArray(array_data)); |
| 72 | return std::make_shared<NumericArrayProxy>(std::move(numeric_array)); |
| 73 | } |
| 74 | |
| 75 | protected: |
| 76 | void toMATLAB(libmexclass::proxy::method::Context& context) { |
nothing calls this directly
no test coverage detected