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

Method write_all

datafusion/catalog/src/stream.rs:407–435  ·  view source on GitHub ↗
(
        &self,
        mut data: SendableRecordBatchStream,
        _context: &Arc<TaskContext>,
    )

Source from the content-addressed store, hash-verified

405 }
406
407 async fn write_all(
408 &self,
409 mut data: SendableRecordBatchStream,
410 _context: &Arc<TaskContext>,
411 ) -> Result<u64> {
412 let config = Arc::clone(&self.0);
413 let (sender, mut receiver) = tokio::sync::mpsc::channel::<RecordBatch>(2);
414 // Note: FIFO Files support poll so this could use AsyncFd
415 let write_task = SpawnedTask::spawn_blocking(move || {
416 let mut count = 0_u64;
417 let mut writer = config.writer()?;
418 while let Some(batch) = receiver.blocking_recv() {
419 count += batch.num_rows() as u64;
420 writer.write(&batch)?;
421 }
422 Ok(count)
423 });
424
425 while let Some(b) = data.next().await.transpose()? {
426 if sender.send(b).await.is_err() {
427 break;
428 }
429 }
430 drop(sender);
431 write_task
432 .join_unwind()
433 .await
434 .map_err(|e| DataFusionError::ExecutionJoin(Box::new(e)))?
435 }
436}

Callers 15

read_csvFunction · 0.45
create_contextFunction · 0.45
prepare_example_dataFunction · 0.45
serializeMethod · 0.45
write_to_fifoFunction · 0.45
populate_csv_partitionsFunction · 0.45
populate_csv_partitionsFunction · 0.45
partitioned_file_groupsFunction · 0.45
populate_csv_partitionsFunction · 0.45
populate_csv_partitionsFunction · 0.45

Calls 7

newFunction · 0.85
is_errMethod · 0.80
join_unwindMethod · 0.80
writerMethod · 0.45
writeMethod · 0.45
nextMethod · 0.45
sendMethod · 0.45