MCPcopy Create free account
hub / github.com/apache/arrow-rs / poll_next

Method poll_next

arrow-flight/src/encode.rs:396–437  ·  view source on GitHub ↗
(
        mut self: Pin<&mut Self>,
        cx: &mut std::task::Context<'_>,
    )

Source from the content-addressed store, hash-verified

394 type Item = Result<FlightData>;
395
396 fn poll_next(
397 mut self: Pin<&mut Self>,
398 cx: &mut std::task::Context<'_>,
399 ) -> Poll<Option<Self::Item>> {
400 loop {
401 if self.done && self.queue.is_empty() {
402 return Poll::Ready(None);
403 }
404
405 // Any messages queued to send?
406 if let Some(data) = self.queue.pop_front() {
407 return Poll::Ready(Some(Ok(data)));
408 }
409
410 // Get next batch
411 let batch = ready!(self.inner.poll_next_unpin(cx));
412
413 match batch {
414 None => {
415 // inner is done
416 self.done = true;
417 // queue must also be empty so we are done
418 assert!(self.queue.is_empty());
419 return Poll::Ready(None);
420 }
421 Some(Err(e)) => {
422 // error from inner
423 self.done = true;
424 self.queue.clear();
425 return Poll::Ready(Some(Err(e)));
426 }
427 Some(Ok(batch)) => {
428 // had data, encode into the queue
429 if let Err(e) = self.encode_batch(batch) {
430 self.done = true;
431 self.queue.clear();
432 return Poll::Ready(Some(Err(e)));
433 }
434 }
435 }
436 }
437 }
438}
439
440/// Defines how a [`FlightDataEncoder`] encodes [`DictionaryArray`]s

Callers

nothing calls this directly

Calls 3

encode_batchMethod · 0.80
is_emptyMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected