Separate implementation function that unpins the [`UnnestStream`] so that partial borrows work correctly
(
&mut self,
cx: &mut std::task::Context<'_>,
)
| 346 | /// Separate implementation function that unpins the [`UnnestStream`] so |
| 347 | /// that partial borrows work correctly |
| 348 | fn poll_next_impl( |
| 349 | &mut self, |
| 350 | cx: &mut std::task::Context<'_>, |
| 351 | ) -> Poll<Option<Result<RecordBatch>>> { |
| 352 | loop { |
| 353 | return Poll::Ready(match ready!(self.input.poll_next_unpin(cx)) { |
| 354 | Some(Ok(batch)) => { |
| 355 | let elapsed_compute = |
| 356 | self.metrics.baseline_metrics.elapsed_compute().clone(); |
| 357 | let timer = elapsed_compute.timer(); |
| 358 | self.metrics.input_batches.add(1); |
| 359 | self.metrics.input_rows.add(batch.num_rows()); |
| 360 | let result = build_batch( |
| 361 | &batch, |
| 362 | &self.schema, |
| 363 | &self.list_type_columns, |
| 364 | &self.struct_column_indices, |
| 365 | &self.options, |
| 366 | )?; |
| 367 | timer.done(); |
| 368 | let Some(result_batch) = result else { |
| 369 | continue; |
| 370 | }; |
| 371 | (&result_batch).record_output(&self.metrics.baseline_metrics); |
| 372 | |
| 373 | // Empty record batches should not be emitted. |
| 374 | // They need to be treated as [`Option<RecordBatch>`]es and handled separately |
| 375 | debug_assert!(result_batch.num_rows() > 0); |
| 376 | Some(Ok(result_batch)) |
| 377 | } |
| 378 | // If the stream is depleted or returned an error, log the finish message: |
| 379 | other => { |
| 380 | trace!( |
| 381 | "Processed {} probe-side input batches containing {} rows and \ |
| 382 | produced {} output batches containing {} rows in {}", |
| 383 | self.metrics.input_batches, |
| 384 | self.metrics.input_rows, |
| 385 | self.metrics.baseline_metrics.output_batches(), |
| 386 | self.metrics.baseline_metrics.output_rows(), |
| 387 | self.metrics.baseline_metrics.elapsed_compute(), |
| 388 | ); |
| 389 | |
| 390 | // In the non-error case, i.e., input is simply depleted: |
| 391 | if other.is_none() { |
| 392 | // Release the input pipeline's resources. |
| 393 | let input_schema = self.input.schema(); |
| 394 | self.input = Box::pin(EmptyRecordBatchStream::new(input_schema)); |
| 395 | } |
| 396 | |
| 397 | other |
| 398 | } |
| 399 | }); |
| 400 | } |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | /// Given a set of struct column indices to flatten |
no test coverage detected