paleolimbot commented on code in PR #608:
URL: https://github.com/apache/arrow-nanoarrow/pull/608#discussion_r1762257415
##########
r/src/ipc.c:
##########
@@ -159,3 +261,40 @@ SEXP nanoarrow_c_ipc_array_reader_connection(SEXP con) {
UNPROTECT(2);
return array_stream_xptr;
}
+
+SEXP nanoarrow_c_ipc_writer_connection(SEXP con) {
+ SEXP output_stream_xptr = PROTECT(output_stream_owning_xptr());
+ struct ArrowIpcOutputStream* output_stream =
+ (struct ArrowIpcOutputStream*)R_ExternalPtrAddr(output_stream_xptr);
+
+ output_stream->write = &write_con_output_stream;
+ output_stream->release = &release_con_output_stream;
+ output_stream->private_data = (SEXP)con;
+ nanoarrow_preserve_sexp(con);
+
+ SEXP writer_xptr = PROTECT(writer_owning_xptr());
+ struct ArrowIpcWriter* writer = (struct
ArrowIpcWriter*)R_ExternalPtrAddr(writer_xptr);
+
+ int code = ArrowIpcWriterInit(writer, output_stream);
+ if (code != NANOARROW_OK) {
+ Rf_error("ArrowIpcWriterInit() failed");
Review Comment:
I added the errno value! Pretty much all that can happen here is a failure
to allocate (rare, since it's a few bytes). I never quite got to adding a macro
like `ERROR_NOT_OK()` to help with this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]