18
18
#include " arrow/io/file.h"
19
19
#include " arrow/matlab/error/error.h"
20
20
#include " arrow/matlab/io/ipc/proxy/record_batch_file_reader.h"
21
+ #include " arrow/matlab/tabular/proxy/schema.h"
21
22
#include " arrow/util/utf8.h"
22
23
24
+ #include " libmexclass/proxy/ProxyManager.h"
25
+
23
26
namespace arrow ::matlab::io::ipc::proxy {
24
27
25
28
RecordBatchFileReader::RecordBatchFileReader (const std::shared_ptr<arrow::ipc::RecordBatchFileReader> reader)
26
29
: reader{std::move (reader)} {
27
30
REGISTER_METHOD (RecordBatchFileReader, getNumRecordBatches);
31
+ REGISTER_METHOD (RecordBatchFileReader, getSchema);
32
+
28
33
}
29
34
30
35
libmexclass::proxy::MakeResult RecordBatchFileReader::make (const libmexclass::proxy::FunctionArguments& constructor_arguments) {
@@ -58,6 +63,22 @@ void RecordBatchFileReader::getNumRecordBatches(libmexclass::proxy::method::Cont
58
63
context.outputs [0 ] = factory.createScalar (num_batches);
59
64
}
60
65
66
+ void RecordBatchFileReader::getSchema (libmexclass::proxy::method::Context& context) {
67
+ namespace mda = ::matlab::data;
68
+ using SchemaProxy = arrow::matlab::tabular::proxy::Schema;
69
+
70
+ auto schema = reader->schema ();
71
+
72
+ auto schema_proxy = std::make_shared<SchemaProxy>(std::move (schema));
73
+ const auto schema_proxy_id = libmexclass::proxy::ProxyManager::manageProxy (schema_proxy);
74
+
75
+ mda::ArrayFactory factory;
76
+ const auto schema_proxy_id_mda = factory.createScalar (schema_proxy_id);
77
+ context.outputs [0 ] = schema_proxy_id_mda;
78
+
79
+ }
80
+
81
+
61
82
62
83
63
84
} // namespace arrow::matlab::io::ipc::proxy
0 commit comments