Deserializes a stream of bytes into a stream of [`RecordBatch`] objects using the provided deserializer. Returns a boxed stream of `Result `. The stream yields [`RecordBatch`] objects as they are produced by the deserializer, or an [`ArrowError`] if an error occurs while polling the input or deserializing.
(
mut input: impl Stream<Item = Result<Bytes>> + Unpin + Send + 'a,
mut deserializer: impl BatchDeserializer<Bytes> + 'a,
)
| 172 | /// objects as they are produced by the deserializer, or an [`ArrowError`] if an error |
| 173 | /// occurs while polling the input or deserializing. |
| 174 | pub fn deserialize_stream<'a>( |
| 175 | mut input: impl Stream<Item = Result<Bytes>> + Unpin + Send + 'a, |
| 176 | mut deserializer: impl BatchDeserializer<Bytes> + 'a, |
| 177 | ) -> BoxStream<'a, Result<RecordBatch, ArrowError>> { |
| 178 | futures::stream::poll_fn(move |cx| { |
| 179 | loop { |
| 180 | match ready!(input.poll_next_unpin(cx)).transpose()? { |
| 181 | Some(b) => _ = deserializer.digest(b), |
| 182 | None => deserializer.finish(), |
| 183 | }; |
| 184 | |
| 185 | return match deserializer.next()? { |
| 186 | DeserializerOutput::RecordBatch(rb) => Poll::Ready(Some(Ok(rb))), |
| 187 | DeserializerOutput::InputExhausted => Poll::Ready(None), |
| 188 | DeserializerOutput::RequiresMoreData => continue, |
| 189 | }; |
| 190 | } |
| 191 | }) |
| 192 | .boxed() |
| 193 | } |