Skip to content

Commit 808de49

Browse files
committed
Implement RecordBatchFileWriter::writeTable(...)
1 parent bab0f9a commit 808de49

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

matlab/src/cpp/arrow/matlab/io/ipc/proxy/record_batch_file_writer.cc

+18
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "arrow/matlab/io/ipc/proxy/record_batch_file_writer.h"
2121
#include "arrow/matlab/tabular/proxy/record_batch.h"
2222
#include "arrow/matlab/tabular/proxy/schema.h"
23+
#include "arrow/matlab/tabular/proxy/table.h"
2324
#include "arrow/util/utf8.h"
2425

2526
#include "libmexclass/proxy/ProxyManager.h"
@@ -30,6 +31,7 @@ namespace arrow::matlab::io::ipc::proxy {
3031
RecordBatchFileWriter::RecordBatchFileWriter(const std::shared_ptr<arrow::ipc::RecordBatchWriter> writer)
3132
: writer{std::move(writer)} {
3233
REGISTER_METHOD(RecordBatchFileWriter, writeRecordBatch);
34+
REGISTER_METHOD(RecordBatchFileWriter, writeTable);
3335
}
3436

3537
libmexclass::proxy::MakeResult RecordBatchFileWriter::make(const libmexclass::proxy::FunctionArguments& constructor_arguments) {
@@ -77,4 +79,20 @@ void RecordBatchFileWriter::writeRecordBatch(libmexclass::proxy::method::Context
7779
context, error::IPC_RECORD_BATCH_WRITE_FAILED);
7880
}
7981

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+
8098
} // namespace arrow::matlab::io::ipc::proxy

matlab/src/cpp/arrow/matlab/io/ipc/proxy/record_batch_file_writer.h

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class RecordBatchFileWriter : public libmexclass::proxy::Proxy {
3333

3434
void writeRecordBatch(libmexclass::proxy::method::Context& context);
3535

36+
void writeTable(libmexclass::proxy::method::Context& context);
37+
3638
};
3739

3840
} // namespace arrow::matlab::io::ipc::proxy

0 commit comments

Comments
 (0)