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

Method poll_next

datafusion/physical-plan/src/memory.rs:93–122  ·  view source on GitHub ↗
(
        mut self: std::pin::Pin<&mut Self>,
        _: &mut Context<'_>,
    )

Source from the content-addressed store, hash-verified

91 type Item = Result<RecordBatch>;
92
93 fn poll_next(
94 mut self: std::pin::Pin<&mut Self>,
95 _: &mut Context<'_>,
96 ) -> Poll<Option<Self::Item>> {
97 if self.index >= self.data.len() {
98 return Poll::Ready(None);
99 }
100 self.index += 1;
101 let batch = &self.data[self.index - 1];
102 // return just the columns requested
103 let batch = match self.projection.as_ref() {
104 Some(columns) => batch.project(columns)?,
105 None => batch.clone(),
106 };
107
108 let Some(&fetch) = self.fetch.as_ref() else {
109 return Poll::Ready(Some(Ok(batch)));
110 };
111 if fetch == 0 {
112 return Poll::Ready(None);
113 }
114
115 let batch = if batch.num_rows() > fetch {
116 batch.slice(0, fetch)
117 } else {
118 batch
119 };
120 self.fetch = Some(fetch - batch.num_rows());
121 Poll::Ready(Some(Ok(batch)))
122 }
123
124 fn size_hint(&self) -> (usize, Option<usize>) {
125 (self.data.len(), Some(self.data.len()))

Callers

nothing calls this directly

Calls 10

sliceMethod · 0.80
timerMethod · 0.80
record_pollMethod · 0.80
lenMethod · 0.45
as_refMethod · 0.45
projectMethod · 0.45
cloneMethod · 0.45
elapsed_computeMethod · 0.45
generate_next_batchMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected