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

Method poll_next

arrow-flight/src/decode.rs:157–191  ·  view source on GitHub ↗

Returns the next [`RecordBatch`] available in this stream, or `None` if there are no further results available.

(
        mut self: Pin<&mut Self>,
        cx: &mut std::task::Context<'_>,
    )

Source from the content-addressed store, hash-verified

155 /// Returns the next [`RecordBatch`] available in this stream, or `None` if
156 /// there are no further results available.
157 fn poll_next(
158 mut self: Pin<&mut Self>,
159 cx: &mut std::task::Context<'_>,
160 ) -> Poll<Option<Result<RecordBatch>>> {
161 loop {
162 let had_schema = self.schema().is_some();
163 let res = ready!(self.inner.poll_next_unpin(cx));
164 match res {
165 // Inner exhausted
166 None => {
167 return Poll::Ready(None);
168 }
169 Some(Err(e)) => {
170 return Poll::Ready(Some(Err(e)));
171 }
172 // translate data
173 Some(Ok(data)) => match data.payload {
174 DecodedPayload::Schema(_) if had_schema => {
175 return Poll::Ready(Some(Err(FlightError::protocol(
176 "Unexpectedly saw multiple Schema messages in FlightData stream",
177 ))));
178 }
179 DecodedPayload::Schema(_) => {
180 // Need next message, poll inner again
181 }
182 DecodedPayload::RecordBatch(batch) => {
183 return Poll::Ready(Some(Ok(batch)));
184 }
185 DecodedPayload::None => {
186 // Need next message
187 }
188 },
189 }
190 }
191 }
192}
193
194/// Wrapper around a stream of [`FlightData`] that handles the details

Callers

nothing calls this directly

Calls 2

extract_messageMethod · 0.80
schemaMethod · 0.45

Tested by

no test coverage detected