Dandandan commented on code in PR #3464:
URL: https://github.com/apache/arrow-rs/pull/3464#discussion_r1090846079


##########
arrow-flight/src/client.rs:
##########
@@ -531,3 +549,142 @@ impl FlightClient {
         request
     }
 }
+
+// splits the input stream  into an invallable flight data stream and errors 
errors
+//
+// TODO generify
+fn split_stream(
+    input_stream: BoxStream<'static, Result<FlightData>>,
+) -> (SplitStreamOk, SplitStreamErr) {
+    let inner = SplitStream {
+        input_stream,
+        next_ok: None,
+        next_err: None,
+        done: false,
+    };
+    let inner = Arc::new(Mutex::new(inner));
+
+    let ok_stream = SplitStreamOk {
+        inner: Arc::clone(&inner),
+    };
+
+    let err_stream = SplitStreamErr {
+        inner: Arc::clone(&inner),
+    };
+
+    (ok_stream, err_stream)
+}
+
+struct SplitStream {
+    input_stream: BoxStream<'static, Result<FlightData>>,
+    next_ok: Option<FlightData>,
+    next_err: Option<FlightError>,
+    done: bool,
+}
+
+impl SplitStream {

Review Comment:
   Instead of splitting - this iterator can stop whenever the first error 
appears and keep that first error if any, so it can be retrieved.



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