You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "kevingurney (via GitHub)" <gi...@apache.org> on 2023/06/13 13:27:58 UTC

[GitHub] [arrow] kevingurney commented on a diff in pull request #36041: GH-36040: [MATLAB] Add `arrow.array.BooleanArray` class

kevingurney commented on code in PR #36041:
URL: https://github.com/apache/arrow/pull/36041#discussion_r1228134308


##########
matlab/src/cpp/arrow/matlab/array/proxy/boolean_array.cc:
##########
@@ -0,0 +1,55 @@
+// 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/boolean_array.h"
+
+#include "arrow/matlab/error/error.h"
+#include "arrow/matlab/bit/bit_pack_matlab_logical_array.h"
+#include "arrow/matlab/bit/bit_unpack_arrow_buffer.h"
+
+namespace arrow::matlab::array::proxy {
+
+        libmexclass::proxy::MakeResult BooleanArray::make(const libmexclass::proxy::FunctionArguments& constructor_arguments) {
+            // Get the mxArray from constructor arguments
+            const ::matlab::data::TypedArray<bool> logical_mda = constructor_arguments[0];
+            const ::matlab::data::TypedArray<bool> validity_bitmap_mda = constructor_arguments[1];
+
+            // Pack the logical data values.
+            auto maybe_packed_logical_buffer = arrow::matlab::bit::bitPackMatlabLogicalArray(logical_mda);
+            MATLAB_ERROR_IF_NOT_OK(maybe_packed_logical_buffer.status(), error::BITPACK_VALIDITY_BITMAP_ERROR_ID);
+
+            // Pack the validity bitmap values.
+            auto maybe_validity_bitmap_buffer = arrow::matlab::bit::bitPackMatlabLogicalArray(validity_bitmap_mda);
+            MATLAB_ERROR_IF_NOT_OK(maybe_validity_bitmap_buffer.status(), error::BITPACK_VALIDITY_BITMAP_ERROR_ID);
+
+            const auto data_type = arrow::boolean();
+            const auto array_length = logical_mda.getNumberOfElements();
+            const auto validity_bitmap_buffer = std::move(maybe_validity_bitmap_buffer).ValueUnsafe();
+            const auto data_buffer = std::move(maybe_packed_logical_buffer).ValueUnsafe();

Review Comment:
   Thanks for making me aware of this! It's very helpful!



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org