This is an automated email from the ASF dual-hosted git repository.
paleolimbot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-nanoarrow.git
The following commit(s) were added to refs/heads/main by this push:
new 373744c fix(extensions/nanoarrow_ipc): Don't release input stream
automatically on end of input (#168)
373744c is described below
commit 373744c299d4df8a38cfe745724cbfe4f062d9c5
Author: Dewey Dunnington <[email protected]>
AuthorDate: Mon Mar 27 14:16:20 2023 -0400
fix(extensions/nanoarrow_ipc): Don't release input stream automatically on
end of input (#168)
Before this PR, the input was released from within `get_next()` in the
`ArrowArrayStream` implementation. This is unnecessary and prevented the
reader from being useful in the context of streams that have
non-standard layouts (e.g., if several streams are concatenated
together, one could continue calling `get_next()` to "try again"). Also,
there is a much better chance that `get_next()` is going to get called
on another thread and it's easier to reason about lifecycles if the
stream gets closed on `release()` instead.
---
extensions/nanoarrow_ipc/src/nanoarrow/nanoarrow_ipc_reader.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/extensions/nanoarrow_ipc/src/nanoarrow/nanoarrow_ipc_reader.c
b/extensions/nanoarrow_ipc/src/nanoarrow/nanoarrow_ipc_reader.c
index 58d7da9..1b2ad87 100644
--- a/extensions/nanoarrow_ipc/src/nanoarrow/nanoarrow_ipc_reader.c
+++ b/extensions/nanoarrow_ipc/src/nanoarrow/nanoarrow_ipc_reader.c
@@ -343,12 +343,6 @@ static int ArrowIpcArrayStreamReaderGetNext(struct
ArrowArrayStream* stream,
struct ArrowArray* out) {
struct ArrowIpcArrayStreamReaderPrivate* private_data =
(struct ArrowIpcArrayStreamReaderPrivate*)stream->private_data;
- // Check if we are all done
- if (private_data->input.release == NULL) {
- out->release = NULL;
- return NANOARROW_OK;
- }
-
private_data->error.message[0] = '\0';
NANOARROW_RETURN_NOT_OK(ArrowIpcArrayStreamReaderReadSchemaIfNeeded(private_data));
@@ -356,8 +350,8 @@ static int ArrowIpcArrayStreamReaderGetNext(struct
ArrowArrayStream* stream,
int result = ArrowIpcArrayStreamReaderNextHeader(
private_data, NANOARROW_IPC_MESSAGE_TYPE_RECORD_BATCH);
if (result == ENODATA) {
- // If the stream is finished, release the input
- private_data->input.release(&private_data->input);
+ // Stream is finished either because there is no input or because
+ // end of stream bytes were read.
out->release = NULL;
return NANOARROW_OK;
}