zeroshade commented on code in PR #169:
URL: https://github.com/apache/arrow-go/pull/169#discussion_r1821330703
##########
arrow/cdata/exports.go:
##########
@@ -155,3 +190,229 @@ func exportStream(rdr array.RecordReader, out
*CArrowArrayStream) {
h := cgo.NewHandle(cRecordReader{rdr: rdr, err: nil})
out.private_data = createHandle(h)
}
+
+type cAsyncState struct {
+ ch chan AsyncRecordBatchStream
+ queueSize uint64
+ ctx context.Context
+}
+
+type taskState struct {
+ task CArrowAsyncTask
+ meta arrow.Metadata
+ err error
+}
+
+//export asyncStreamOnSchema
+func asyncStreamOnSchema(self *CArrowAsyncDeviceStreamHandler, schema
*CArrowSchema, addlMetadata *C.char) C.int {
+ h := getHandle(self.private_data)
+ handler := h.Value().(cAsyncState)
+ defer close(handler.ch)
+
+ if self.producer.device_type != C.ARROW_DEVICE_CPU {
+ handler.ch <- AsyncRecordBatchStream{Err:
fmt.Errorf("unsupported device type")}
+ return C.EINVAL
+ }
+
+ sc, err := ImportCArrowSchema(schema)
+ if err != nil {
+ handler.ch <- AsyncRecordBatchStream{Err: err}
+ return C.EINVAL
+ }
+
+ var meta arrow.Metadata
+ if addlMetadata != nil {
+ meta = decodeCMetadata(addlMetadata)
+ }
+
+ recordStream := make(chan RecordMessage, handler.queueSize)
+ taskQueue := make(chan taskState, handler.queueSize)
+ handler.ch <- AsyncRecordBatchStream{Schema: sc,
+ AdditionalMetadata: meta, Stream: recordStream}
Review Comment:
yup
--
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]