kou commented on code in PR #41737:
URL: https://github.com/apache/arrow/pull/41737#discussion_r1606926531


##########
matlab/src/cpp/arrow/matlab/c/proxy/array_importer.cc:
##########
@@ -0,0 +1,71 @@
+// 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/array.h"
+#include "arrow/c/bridge.h"
+
+#include "arrow/matlab/array/proxy/wrap.h"
+#include "arrow/matlab/c/proxy/array_importer.h"
+#include "arrow/matlab/error/error.h"
+
+#include "libmexclass/proxy/ProxyManager.h"
+
+namespace arrow::matlab::c::proxy {
+
+ArrayImporter::ArrayImporter() { REGISTER_METHOD(ArrayImporter, import); }
+
+libmexclass::proxy::MakeResult ArrayImporter::make(
+    const libmexclass::proxy::FunctionArguments& constructor_arguments) {
+  return std::make_shared<ArrayImporter>();
+}
+
+void ArrayImporter::import(libmexclass::proxy::method::Context& context) {
+  namespace mda = ::matlab::data;
+  using namespace libmexclass::proxy;
+
+  mda::StructArray args = context.inputs[0];
+  const mda::TypedArray<uint64_t> arrow_array_address_mda = 
args[0]["ArrowArrayAddress"];
+  const mda::TypedArray<uint64_t> arrow_schema_address_mda =
+      args[0]["ArrowSchemaAddress"];
+
+  const auto arrow_array_address = uint64_t(arrow_array_address_mda[0]);
+  const auto arrow_schema_address = uint64_t(arrow_schema_address_mda[0]);
+
+  struct ArrowArray* arrow_array =
+      reinterpret_cast<struct ArrowArray*>(arrow_array_address);
+  struct ArrowSchema* arrow_schema =
+      reinterpret_cast<struct ArrowSchema*>(arrow_schema_address);
+
+  MATLAB_ASSIGN_OR_ERROR_WITH_CONTEXT(std::shared_ptr<arrow::Array> array,

Review Comment:
   ```suggestion
     MATLAB_ASSIGN_OR_ERROR_WITH_CONTEXT(auto array,
   ```



##########
matlab/src/cpp/arrow/matlab/c/proxy/array_importer.cc:
##########
@@ -0,0 +1,71 @@
+// 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/array.h"
+#include "arrow/c/bridge.h"
+
+#include "arrow/matlab/array/proxy/wrap.h"
+#include "arrow/matlab/c/proxy/array_importer.h"
+#include "arrow/matlab/error/error.h"
+
+#include "libmexclass/proxy/ProxyManager.h"
+
+namespace arrow::matlab::c::proxy {
+
+ArrayImporter::ArrayImporter() { REGISTER_METHOD(ArrayImporter, import); }
+
+libmexclass::proxy::MakeResult ArrayImporter::make(
+    const libmexclass::proxy::FunctionArguments& constructor_arguments) {
+  return std::make_shared<ArrayImporter>();
+}
+
+void ArrayImporter::import(libmexclass::proxy::method::Context& context) {
+  namespace mda = ::matlab::data;
+  using namespace libmexclass::proxy;
+
+  mda::StructArray args = context.inputs[0];
+  const mda::TypedArray<uint64_t> arrow_array_address_mda = 
args[0]["ArrowArrayAddress"];
+  const mda::TypedArray<uint64_t> arrow_schema_address_mda =
+      args[0]["ArrowSchemaAddress"];
+
+  const auto arrow_array_address = uint64_t(arrow_array_address_mda[0]);
+  const auto arrow_schema_address = uint64_t(arrow_schema_address_mda[0]);
+
+  struct ArrowArray* arrow_array =
+      reinterpret_cast<struct ArrowArray*>(arrow_array_address);
+  struct ArrowSchema* arrow_schema =

Review Comment:
   ```suggestion
     auto arrow_schema =
   ```



##########
matlab/src/cpp/arrow/matlab/c/proxy/array_importer.cc:
##########
@@ -0,0 +1,71 @@
+// 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/array.h"
+#include "arrow/c/bridge.h"
+
+#include "arrow/matlab/array/proxy/wrap.h"
+#include "arrow/matlab/c/proxy/array_importer.h"
+#include "arrow/matlab/error/error.h"
+
+#include "libmexclass/proxy/ProxyManager.h"
+
+namespace arrow::matlab::c::proxy {
+
+ArrayImporter::ArrayImporter() { REGISTER_METHOD(ArrayImporter, import); }
+
+libmexclass::proxy::MakeResult ArrayImporter::make(
+    const libmexclass::proxy::FunctionArguments& constructor_arguments) {
+  return std::make_shared<ArrayImporter>();
+}
+
+void ArrayImporter::import(libmexclass::proxy::method::Context& context) {
+  namespace mda = ::matlab::data;
+  using namespace libmexclass::proxy;
+
+  mda::StructArray args = context.inputs[0];
+  const mda::TypedArray<uint64_t> arrow_array_address_mda = 
args[0]["ArrowArrayAddress"];
+  const mda::TypedArray<uint64_t> arrow_schema_address_mda =
+      args[0]["ArrowSchemaAddress"];
+
+  const auto arrow_array_address = uint64_t(arrow_array_address_mda[0]);
+  const auto arrow_schema_address = uint64_t(arrow_schema_address_mda[0]);
+
+  struct ArrowArray* arrow_array =

Review Comment:
   ```suggestion
     auto arrow_array =
   ```



##########
matlab/src/cpp/arrow/matlab/array/proxy/array.cc:
##########
@@ -178,4 +180,21 @@ void Array::slice(libmexclass::proxy::method::Context& 
context) {
   output[0]["TypeID"] = factory.createScalar(type_id);
   context.outputs[0] = output;
 }
+
+void Array::exportToC(libmexclass::proxy::method::Context& context) {
+  namespace mda = ::matlab::data;
+  mda::StructArray opts = context.inputs[0];
+  const mda::TypedArray<uint64_t> array_address_mda = 
opts[0]["ArrowArrayAddress"];
+  const mda::TypedArray<uint64_t> schema_address_mda = 
opts[0]["ArrowSchemaAddress"];
+
+  struct ArrowArray* arrow_array =
+      reinterpret_cast<struct ArrowArray*>(uint64_t(array_address_mda[0]));
+  struct ArrowSchema* arrow_schema =

Review Comment:
   ```suggestion
     auto arrow_schema =
   ```



##########
matlab/src/cpp/arrow/matlab/array/proxy/array.cc:
##########
@@ -178,4 +180,21 @@ void Array::slice(libmexclass::proxy::method::Context& 
context) {
   output[0]["TypeID"] = factory.createScalar(type_id);
   context.outputs[0] = output;
 }
+
+void Array::exportToC(libmexclass::proxy::method::Context& context) {
+  namespace mda = ::matlab::data;
+  mda::StructArray opts = context.inputs[0];
+  const mda::TypedArray<uint64_t> array_address_mda = 
opts[0]["ArrowArrayAddress"];
+  const mda::TypedArray<uint64_t> schema_address_mda = 
opts[0]["ArrowSchemaAddress"];
+
+  struct ArrowArray* arrow_array =

Review Comment:
   ```suggestion
     auto arrow_array =
   ```



-- 
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-unsubscr...@arrow.apache.org

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

Reply via email to