20
20
#include " arrow/matlab/io/ipc/proxy/record_batch_file_writer.h"
21
21
#include " arrow/matlab/tabular/proxy/record_batch.h"
22
22
#include " arrow/matlab/tabular/proxy/schema.h"
23
+ #include " arrow/matlab/tabular/proxy/table.h"
23
24
#include " arrow/util/utf8.h"
24
25
25
26
#include " libmexclass/proxy/ProxyManager.h"
@@ -30,6 +31,7 @@ namespace arrow::matlab::io::ipc::proxy {
30
31
RecordBatchFileWriter::RecordBatchFileWriter (const std::shared_ptr<arrow::ipc::RecordBatchWriter> writer)
31
32
: writer{std::move (writer)} {
32
33
REGISTER_METHOD (RecordBatchFileWriter, writeRecordBatch);
34
+ REGISTER_METHOD (RecordBatchFileWriter, writeTable);
33
35
}
34
36
35
37
libmexclass::proxy::MakeResult RecordBatchFileWriter::make (const libmexclass::proxy::FunctionArguments& constructor_arguments) {
@@ -77,4 +79,20 @@ void RecordBatchFileWriter::writeRecordBatch(libmexclass::proxy::method::Context
77
79
context, error::IPC_RECORD_BATCH_WRITE_FAILED);
78
80
}
79
81
82
+ void RecordBatchFileWriter::writeTable (libmexclass::proxy::method::Context& context) {
83
+ namespace mda = ::matlab::data;
84
+ using TableProxy = ::arrow::matlab::tabular::proxy::Table;
85
+
86
+ mda::StructArray opts = context.inputs [0 ];
87
+ const mda::TypedArray<uint64_t > table_proxy_id_mda = opts[0 ][" TableProxyID" ];
88
+ const uint64_t table_proxy_id = table_proxy_id_mda[0 ];
89
+
90
+ auto proxy = libmexclass::proxy::ProxyManager::getProxy (table_proxy_id);
91
+ auto table_proxy = std::static_pointer_cast<TableProxy>(proxy);
92
+ auto table = table_proxy->unwrap ();
93
+
94
+ MATLAB_ERROR_IF_NOT_OK_WITH_CONTEXT (writer->WriteTable (*table),
95
+ context, error::IPC_RECORD_BATCH_WRITE_FAILED);
96
+ }
97
+
80
98
} // namespace arrow::matlab::io::ipc::proxy
0 commit comments