Skip to content

Commit

Permalink
Add close method
Browse files Browse the repository at this point in the history
  • Loading branch information
sgilmore10 committed Jun 12, 2024
1 parent fed62c3 commit 52c7ded
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ namespace arrow::matlab::io::ipc::proxy {

RecordBatchFileWriter::RecordBatchFileWriter(std::shared_ptr<arrow::ipc::RecordBatchWriter> writer) : writer{std::move(writer)} {
REGISTER_METHOD(RecordBatchFileWriter, writeBatch);
REGISTER_METHOD(RecordBatchFileWriter, close);

}

libmexclass::proxy::MakeResult RecordBatchFileWriter::make(
Expand Down Expand Up @@ -79,4 +81,12 @@ libmexclass::proxy::MakeResult RecordBatchFileWriter::make(

MATLAB_ERROR_IF_NOT_OK_WITH_CONTEXT(writer->WriteRecordBatch(*record_batch), context, "arrow:matlab:writefailed");
}

void RecordBatchFileWriter::close(libmexclass::proxy::method::Context& context) {
namespace mda = ::matlab::data;
using RecordBatchProxy = ::arrow::matlab::tabular::proxy::RecordBatch;

MATLAB_ERROR_IF_NOT_OK_WITH_CONTEXT(writer->Close(), context, "arrow:matlab:ipc:close");

}
} // namespace arrow::matlab::io::ipc::proxy
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ class RecordBatchFileWriter : public libmexclass::proxy::Proxy {
protected:

void writeBatch(libmexclass::proxy::method::Context& context);


void close(libmexclass::proxy::method::Context& context);

std::shared_ptr<arrow::ipc::RecordBatchWriter> writer;

};

} // namespace arrow::matlab::io::ipc::proxy
7 changes: 7 additions & 0 deletions matlab/src/matlab/+arrow/+io/+ipc/RecordBatchFileWriter.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ function write(obj, recordBatch)
obj.Proxy.writeBatch(args);
end

function close(obj)
arguments
obj(1, 1) arrow.io.ipc.RecordBatchFileWriter
end
obj.Proxy.close();
end

end

end

0 comments on commit 52c7ded

Please sign in to comment.