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

Method run

datafusion/datasource/src/file_stream/mod.rs:1441–1551  ·  view source on GitHub ↗

Runs the test and returns combined stream output and scheduler trace text.

(self)

Source from the content-addressed store, hash-verified

1439 /// Runs the test and returns combined stream output and scheduler
1440 /// trace text.
1441 async fn run(self) -> Result<String> {
1442 let observer = self.morselizer.observer().clone();
1443 observer.clear();
1444
1445 let metrics_set = ExecutionPlanMetricsSet::new();
1446 let partition_count = self.num_partitions();
1447
1448 let mut partitions = (0..partition_count)
1449 .map(|_| PartitionState::new())
1450 .collect::<Vec<_>>();
1451
1452 let mut build_order = Vec::new();
1453 for partition in self.reads.iter().map(|partition| partition.0) {
1454 if !build_order.contains(&partition) {
1455 build_order.push(partition);
1456 }
1457 }
1458 for partition in 0..partition_count {
1459 if !build_order.contains(&partition) {
1460 build_order.push(partition);
1461 }
1462 }
1463
1464 let config = self.test_config();
1465 // `DataSourceExec::execute` creates one execution-local shared
1466 // state object via `create_sibling_state()` and then passes it
1467 // to `open_with_sibling_state(...)`. These tests build
1468 // `FileStream`s directly, bypassing `DataSourceExec`, so they must
1469 // perform the same setup explicitly when exercising sibling-stream
1470 // work stealing.
1471 let shared_work_source = config.create_sibling_state().and_then(|state| {
1472 state.as_ref().downcast_ref::<SharedWorkSource>().cloned()
1473 });
1474 if !self.build_streams_on_first_read {
1475 for partition in build_order {
1476 let stream = FileStreamBuilder::new(&config)
1477 .with_partition(partition)
1478 .with_shared_work_source(shared_work_source.clone())
1479 .with_morselizer(Box::new(self.morselizer.clone()))
1480 .with_metrics(&metrics_set)
1481 .build()?;
1482 partitions[partition].set_stream(stream);
1483 }
1484 }
1485
1486 let mut initial_reads: VecDeque<_> = self.reads.into();
1487 let mut next_round_robin = 0;
1488
1489 while !initial_reads.is_empty()
1490 || partitions.iter().any(PartitionState::is_active)
1491 {
1492 let partition = if let Some(partition) = initial_reads.pop_front() {
1493 partition.0
1494 } else {
1495 let partition = next_round_robin;
1496 next_round_robin = (next_round_robin + 1) % partition_count.max(1);
1497 partition
1498 };

Callers

nothing calls this directly

Calls 15

newFunction · 0.85
format_resultFunction · 0.85
observerMethod · 0.80
test_configMethod · 0.80
with_morselizerMethod · 0.80
set_streamMethod · 0.80
pop_frontMethod · 0.80
push_outputMethod · 0.80
format_eventsMethod · 0.80
cloneMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected