|
15 | 15 | // specific language governing permissions and limitations
|
16 | 16 | // under the License.
|
17 | 17 |
|
18 |
| -#include "libmexclass/proxy/ProxyManager.h" |
19 |
| - |
| 18 | +#include "arrow/c/bridge.h" |
20 | 19 | #include "arrow/matlab/array/proxy/array.h"
|
21 | 20 | #include "arrow/matlab/array/proxy/wrap.h"
|
22 | 21 |
|
@@ -66,6 +65,7 @@ RecordBatch::RecordBatch(std::shared_ptr<arrow::RecordBatch> record_batch)
|
66 | 65 | REGISTER_METHOD(RecordBatch, getColumnByName);
|
67 | 66 | REGISTER_METHOD(RecordBatch, getSchema);
|
68 | 67 | REGISTER_METHOD(RecordBatch, getRowAsString);
|
| 68 | + REGISTER_METHOD(RecordBatch, exportToC); |
69 | 69 | }
|
70 | 70 |
|
71 | 71 | std::shared_ptr<arrow::RecordBatch> RecordBatch::unwrap() { return record_batch; }
|
@@ -259,4 +259,19 @@ void RecordBatch::getRowAsString(libmexclass::proxy::method::Context& context) {
|
259 | 259 | context.outputs[0] = factory.createScalar(row_str_utf16);
|
260 | 260 | }
|
261 | 261 |
|
| 262 | +void RecordBatch::exportToC(libmexclass::proxy::method::Context& context) { |
| 263 | + namespace mda = ::matlab::data; |
| 264 | + mda::StructArray opts = context.inputs[0]; |
| 265 | + const mda::TypedArray<uint64_t> array_address_mda = opts[0]["ArrowArrayAddress"]; |
| 266 | + const mda::TypedArray<uint64_t> schema_address_mda = opts[0]["ArrowSchemaAddress"]; |
| 267 | + |
| 268 | + auto arrow_array = reinterpret_cast<struct ArrowArray*>(uint64_t(array_address_mda[0])); |
| 269 | + auto arrow_schema = |
| 270 | + reinterpret_cast<struct ArrowSchema*>(uint64_t(schema_address_mda[0])); |
| 271 | + |
| 272 | + MATLAB_ERROR_IF_NOT_OK_WITH_CONTEXT( |
| 273 | + arrow::ExportRecordBatch(*record_batch, arrow_array, arrow_schema), context, |
| 274 | + error::C_EXPORT_FAILED); |
| 275 | +} |
| 276 | + |
262 | 277 | } // namespace arrow::matlab::tabular::proxy
|
0 commit comments