LantaoJin commented on code in PR #51:
URL: https://github.com/apache/datafusion-java/pull/51#discussion_r3256649533


##########
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:
   Done. The body is now wrapped in `catch_unwind` and any panic is surfaced as 
`ArrowError::ExternalError` so Java sees a normal exception. Or do you think we 
should call `process::abort()` here? @andygrove 



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

Reply via email to