sgilmore10 commented on code in PR #37315: URL: https://github.com/apache/arrow/pull/37315#discussion_r1302132211
########## matlab/src/cpp/arrow/matlab/array/proxy/time32_array.cc: ########## @@ -0,0 +1,62 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "arrow/matlab/array/proxy/time32_array.h" + +#include "arrow/matlab/type/time_unit.h" +#include "arrow/util/utf8.h" + +namespace arrow::matlab::array::proxy { + + // Specialization of NumericArray::Make for arrow::Time32Type + template <> + libmexclass::proxy::MakeResult Time32Array::make(const libmexclass::proxy::FunctionArguments& constructor_arguments) { + namespace mda = ::matlab::data; + using MatlabBuffer = arrow::matlab::buffer::MatlabBuffer; + using Time32Array = arrow::Time32Array; + using Time32ArrayProxy = arrow::matlab::array::proxy::NumericArray<arrow::Time32Type>; + + mda::StructArray opts = constructor_arguments[0]; + + // Get the mxArray from constructor arguments + const mda::TypedArray<int32_t> timestamp_mda = opts[0]["MatlabArray"]; + const mda::TypedArray<bool> validity_bitmap_mda = opts[0]["Valid"]; + + const mda::TypedArray<mda::MATLABString> units_mda = opts[0]["TimeUnit"]; + + // extract the time unit + const std::u16string& u16_timeunit = units_mda[0]; + MATLAB_ASSIGN_OR_ERROR(const auto time_unit, + arrow::matlab::type::timeUnitFromString(u16_timeunit), + error::UKNOWN_TIME_UNIT_ERROR_ID) + + // create the timestamp_type + auto data_type = arrow::time32(time_unit); + auto array_length = static_cast<int32_t>(timestamp_mda.getNumberOfElements()); // cast size_t to int64_t + + auto data_buffer = std::make_shared<MatlabBuffer>(timestamp_mda); Review Comment: Good catch! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
