lidavidm commented on code in PR #164:
URL: https://github.com/apache/arrow-nanoarrow/pull/164#discussion_r1145303497


##########
extensions/nanoarrow_ipc/src/nanoarrow/nanoarrow_ipc_reader.c:
##########
@@ -0,0 +1,424 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "nanoarrow.h"
+#include "nanoarrow_ipc.h"
+
+void ArrowIpcInputStreamMove(struct ArrowIpcInputStream* src,
+                             struct ArrowIpcInputStream* dst) {
+  memcpy(dst, src, sizeof(struct ArrowIpcInputStream));
+  src->release = NULL;
+}
+
+struct ArrowIpcInputStreamBufferPrivate {
+  struct ArrowBuffer input;
+  int64_t cursor_bytes;
+};
+
+static ArrowErrorCode ArrowIpcInputStreamBufferRead(struct 
ArrowIpcInputStream* stream,
+                                                    void* buf, int64_t 
buf_size_bytes,
+                                                    int64_t* size_read_out,
+                                                    struct ArrowError* error) {
+  if (buf_size_bytes == 0) {
+    return NANOARROW_OK;

Review Comment:
   nit: possibly assign to `size_read_out` anyways?



##########
extensions/nanoarrow_ipc/src/nanoarrow/nanoarrow_ipc.h:
##########
@@ -219,6 +227,60 @@ ArrowErrorCode ArrowIpcDecoderDecodeArray(struct 
ArrowIpcDecoder* decoder,
                                           struct ArrowArray* out,
                                           struct ArrowError* error);
 
+/// \brief An user-extensible input data source
+struct ArrowIpcInputStream {
+  /// \brief Read up to buf_size_bytes from stream into buf
+  ///
+  /// The actual number of bytes read is placed in the value pointed to by
+  /// size_read_out. Returns NANOARROW_OK on success.
+  ArrowErrorCode (*read)(struct ArrowIpcInputStream* stream, void* buf,

Review Comment:
   I suppose:
   
   - Perhaps consider a concrete type (char*, uint8_t*) for buf so it's harder 
to accidentally pass an arbitrary pointer to it?
   - What do you think about `char** buf` (i.e., letting the stream do the 
allocation)? That would let you do things like read an in-memory buffer by 
slicing instead of copying (though I suppose lifetimes may get confusing there).



-- 
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]

Reply via email to