MCPcopy Create free account
hub / github.com/apache/datafusion / deserialize_stream

Function deserialize_stream

datafusion/datasource/src/decoder.rs:174–193  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

172/// objects as they are produced by the deserializer, or an [`ArrowError`] if an error
173/// occurs while polling the input or deserializing.
174pub 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}

Callers 2

openMethod · 0.85
openMethod · 0.85

Calls 3

digestMethod · 0.80
finishMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…