1515// specific language governing permissions and limitations
1616// under the License.
1717
18- #include " arrow/matlab/buffer/matlab_buffer.h"
1918#include " arrow/matlab/io/ipc/proxy/record_batch_stream_reader.h"
2019#include " arrow/io/file.h"
2120#include " arrow/io/memory.h"
21+ #include " arrow/matlab/buffer/matlab_buffer.h"
2222#include " arrow/matlab/error/error.h"
2323#include " arrow/matlab/tabular/proxy/record_batch.h"
2424#include " arrow/matlab/tabular/proxy/schema.h"
@@ -38,58 +38,63 @@ RecordBatchStreamReader::RecordBatchStreamReader(
3838 REGISTER_METHOD (RecordBatchStreamReader, readTable);
3939}
4040
41- libmexclass::proxy::MakeResult RecordBatchStreamReader::fromFile (const libmexclass::proxy::FunctionArguments& constructor_arguments) {
42- namespace mda = ::matlab::data;
43- using RecordBatchStreamReaderProxy =
41+ libmexclass::proxy::MakeResult RecordBatchStreamReader::fromFile (
42+ const libmexclass::proxy::FunctionArguments& constructor_arguments) {
43+ namespace mda = ::matlab::data;
44+ using RecordBatchStreamReaderProxy =
4445 arrow::matlab::io::ipc::proxy::RecordBatchStreamReader;
4546
46- const mda::StructArray opts = constructor_arguments[0 ];
47- const mda::StringArray filename_mda = opts[0 ][" Filename" ];
48- const auto filename_utf16 = std::u16string (filename_mda[0 ]);
49- MATLAB_ASSIGN_OR_ERROR (const auto filename_utf8,
50- arrow::util::UTF16StringToUTF8 (filename_utf16),
51- error::UNICODE_CONVERSION_ERROR_ID);
47+ const mda::StructArray opts = constructor_arguments[0 ];
48+ const mda::StringArray filename_mda = opts[0 ][" Filename" ];
49+ const auto filename_utf16 = std::u16string (filename_mda[0 ]);
50+ MATLAB_ASSIGN_OR_ERROR (const auto filename_utf8,
51+ arrow::util::UTF16StringToUTF8 (filename_utf16),
52+ error::UNICODE_CONVERSION_ERROR_ID);
5253
53- MATLAB_ASSIGN_OR_ERROR (auto input_stream, arrow::io::ReadableFile::Open (filename_utf8),
54- error::FAILED_TO_OPEN_FILE_FOR_READ);
54+ MATLAB_ASSIGN_OR_ERROR (auto input_stream, arrow::io::ReadableFile::Open (filename_utf8),
55+ error::FAILED_TO_OPEN_FILE_FOR_READ);
5556
56- MATLAB_ASSIGN_OR_ERROR (auto reader,
57- arrow::ipc::RecordBatchStreamReader::Open (input_stream),
58- error::IPC_RECORD_BATCH_READER_OPEN_FAILED);
57+ MATLAB_ASSIGN_OR_ERROR (auto reader,
58+ arrow::ipc::RecordBatchStreamReader::Open (input_stream),
59+ error::IPC_RECORD_BATCH_READER_OPEN_FAILED);
5960
60- return std::make_shared<RecordBatchStreamReaderProxy>(std::move (reader));
61+ return std::make_shared<RecordBatchStreamReaderProxy>(std::move (reader));
6162}
6263
63- libmexclass::proxy::MakeResult RecordBatchStreamReader::fromBytes (const libmexclass::proxy::FunctionArguments& constructor_arguments) {
64- namespace mda = ::matlab::data;
65- using RecordBatchStreamReaderProxy =
66- arrow::matlab::io::ipc::proxy::RecordBatchStreamReader;
67-
68- const mda::StructArray opts = constructor_arguments[0 ];
69- const ::matlab::data::TypedArray<uint8_t > bytes_mda = opts[0 ][" Bytes" ];
70- const auto matlab_buffer = std::make_shared<arrow::matlab::buffer::MatlabBuffer>(bytes_mda);
71- auto buffer_reader = std::make_shared<arrow::io::BufferReader>(matlab_buffer);
72- MATLAB_ASSIGN_OR_ERROR (auto reader,
73- arrow::ipc::RecordBatchStreamReader::Open (buffer_reader),
74- error::IPC_RECORD_BATCH_READER_OPEN_FAILED);
75- return std::make_shared<RecordBatchStreamReaderProxy>(std::move (reader));
64+ libmexclass::proxy::MakeResult RecordBatchStreamReader::fromBytes (
65+ const libmexclass::proxy::FunctionArguments& constructor_arguments) {
66+ namespace mda = ::matlab::data;
67+ using RecordBatchStreamReaderProxy =
68+ arrow::matlab::io::ipc::proxy::RecordBatchStreamReader;
69+
70+ const mda::StructArray opts = constructor_arguments[0 ];
71+ const ::matlab::data::TypedArray<uint8_t > bytes_mda = opts[0 ][" Bytes" ];
72+ const auto matlab_buffer =
73+ std::make_shared<arrow::matlab::buffer::MatlabBuffer>(bytes_mda);
74+ auto buffer_reader = std::make_shared<arrow::io::BufferReader>(matlab_buffer);
75+ MATLAB_ASSIGN_OR_ERROR (auto reader,
76+ arrow::ipc::RecordBatchStreamReader::Open (buffer_reader),
77+ error::IPC_RECORD_BATCH_READER_OPEN_FAILED);
78+ return std::make_shared<RecordBatchStreamReaderProxy>(std::move (reader));
7679}
7780
7881libmexclass::proxy::MakeResult RecordBatchStreamReader::make (
7982 const libmexclass::proxy::FunctionArguments& constructor_arguments) {
80- namespace mda = ::matlab::data;
83+ namespace mda = ::matlab::data;
8184 const mda::StructArray opts = constructor_arguments[0 ];
8285
8386 // Dispatch to the appropriate static "make" method depending
8487 // on the input type.
8588 const mda::StringArray type_mda = opts[0 ][" Type" ];
8689 const auto type_utf16 = std::u16string (type_mda[0 ]);
8790 if (type_utf16 == u" Bytes" ) {
88- return RecordBatchStreamReader::fromBytes (constructor_arguments);
91+ return RecordBatchStreamReader::fromBytes (constructor_arguments);
8992 } else if (type_utf16 == u" File" ) {
90- return RecordBatchStreamReader::fromFile (constructor_arguments);
93+ return RecordBatchStreamReader::fromFile (constructor_arguments);
9194 } else {
92- return libmexclass::error::Error{" arrow:io:ipc:InvalidConstructionType" , " Invalid construction type for RecordBatchStreamReader." };
95+ return libmexclass::error::Error{
96+ " arrow:io:ipc:InvalidConstructionType" ,
97+ " Invalid construction type for RecordBatchStreamReader." };
9398 }
9499}
95100
0 commit comments