andygrove commented on code in PR #51:
URL: https://github.com/apache/datafusion-java/pull/51#discussion_r3262785555
##########
native/src/lib.rs:
##########
@@ -152,6 +156,62 @@ pub extern "system" fn
Java_org_apache_datafusion_DataFrame_collectDataFrame<'lo
})
}
+/// Bridges DataFusion's async [`SendableRecordBatchStream`] to the synchronous
+/// [`RecordBatchReader`] interface that `FFI_ArrowArrayStream` (and therefore
+/// the Java `ArrowReader`) consumes. Each call to `next()` drives one
+/// `runtime().block_on(stream.next())`, so memory pressure stays bounded by
the
+/// executor pipeline plus a single in-flight batch.
+struct StreamingReader {
+ schema: SchemaRef,
+ stream: SendableRecordBatchStream,
+}
+
+impl Iterator for StreamingReader {
+ type Item = Result<RecordBatch, ArrowError>;
+
+ fn next(&mut self) -> Option<Self::Item> {
+ runtime()
+ .block_on(self.stream.next())
Review Comment:
Thanks @LantaoJin. I am actually not sure of the best approach. Let's go
ahead and merge this and we can keep iterating.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]