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

Method stream_limit

datafusion/physical-plan/src/limit.rs:469–489  ·  view source on GitHub ↗

Fetches from the batch

(&mut self, batch: RecordBatch)

Source from the content-addressed store, hash-verified

467
468 /// Fetches from the batch
469 fn stream_limit(&mut self, batch: RecordBatch) -> Option<RecordBatch> {
470 // records time on drop
471 let _timer = self.baseline_metrics.elapsed_compute().timer();
472 if self.fetch == 0 {
473 self.input = None; // Clear input so it can be dropped early
474 None
475 } else if batch.num_rows() < self.fetch {
476 //
477 self.fetch -= batch.num_rows();
478 Some(batch)
479 } else if batch.num_rows() >= self.fetch {
480 let batch_rows = self.fetch;
481 self.fetch = 0;
482 self.input = None; // Clear input so it can be dropped early
483
484 // It is guaranteed that batch_rows is <= batch.num_rows
485 Some(batch.slice(0, batch_rows))
486 } else {
487 unreachable!()
488 }
489 }
490}
491
492impl Stream for LimitStream {

Callers 1

poll_nextMethod · 0.80

Calls 3

timerMethod · 0.80
sliceMethod · 0.80
elapsed_computeMethod · 0.45

Tested by

no test coverage detected