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

Method execute

datafusion/physical-plan/src/work_table.rs:196–224  ·  view source on GitHub ↗

Stream the batches that were written to the work table.

(
        &self,
        partition: usize,
        _context: Arc<TaskContext>,
    )

Source from the content-addressed store, hash-verified

194
195 /// Stream the batches that were written to the work table.
196 fn execute(
197 &self,
198 partition: usize,
199 _context: Arc<TaskContext>,
200 ) -> Result<SendableRecordBatchStream> {
201 // WorkTable streams must be the plan base.
202 assert_eq_or_internal_err!(
203 partition,
204 0,
205 "WorkTableExec got an invalid partition {partition} (expected 0)"
206 );
207 let ReservedBatches {
208 mut batches,
209 reservation,
210 } = self.work_table.take()?;
211 if let Some(projection) = &self.projection {
212 // We apply the projection
213 // TODO: it would be better to apply it as soon as possible and not only here
214 // TODO: an aggressive projection makes the memory reservation smaller, even if we do not edit it
215 batches = batches
216 .into_iter()
217 .map(|b| b.project(projection))
218 .collect::<Result<Vec<_>, _>>()?;
219 }
220
221 let stream = MemoryStream::try_new(batches, Arc::clone(&self.schema), None)?
222 .with_reservation(reservation);
223 Ok(Box::pin(cooperative(stream)))
224 }
225
226 fn metrics(&self) -> Option<MetricsSet> {
227 Some(self.metrics.clone_inner())

Callers 1

test_work_table_execFunction · 0.45

Calls 6

cooperativeFunction · 0.85
takeMethod · 0.45
mapMethod · 0.45
into_iterMethod · 0.45
projectMethod · 0.45
with_reservationMethod · 0.45

Tested by 1

test_work_table_execFunction · 0.36