Skip to content

Commit 71903e1

Browse files
authored
Minor: use ready! macro to simplify FilterExec poll loop (#11649)
1 parent 7db4213 commit 71903e1

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

datafusion/physical-plan/src/filter.rs

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use std::any::Any;
1919
use std::pin::Pin;
2020
use std::sync::Arc;
21-
use std::task::{Context, Poll};
21+
use std::task::{ready, Context, Poll};
2222

2323
use super::{
2424
ColumnStatistics, DisplayAs, ExecutionPlanProperties, PlanProperties,
@@ -59,6 +59,7 @@ pub struct FilterExec {
5959
metrics: ExecutionPlanMetricsSet,
6060
/// Selectivity for statistics. 0 = no rows, 100 = all rows
6161
default_selectivity: u8,
62+
/// Properties equivalence properties, partitioning, etc.
6263
cache: PlanProperties,
6364
}
6465

@@ -375,26 +376,20 @@ impl Stream for FilterExecStream {
375376
) -> Poll<Option<Self::Item>> {
376377
let poll;
377378
loop {
378-
match self.input.poll_next_unpin(cx) {
379-
Poll::Ready(value) => match value {
380-
Some(Ok(batch)) => {
381-
let timer = self.baseline_metrics.elapsed_compute().timer();
382-
let filtered_batch = batch_filter(&batch, &self.predicate)?;
383-
// skip entirely filtered batches
384-
if filtered_batch.num_rows() == 0 {
385-
continue;
386-
}
387-
timer.done();
388-
poll = Poll::Ready(Some(Ok(filtered_batch)));
389-
break;
379+
match ready!(self.input.poll_next_unpin(cx)) {
380+
Some(Ok(batch)) => {
381+
let timer = self.baseline_metrics.elapsed_compute().timer();
382+
let filtered_batch = batch_filter(&batch, &self.predicate)?;
383+
// skip entirely filtered batches
384+
if filtered_batch.num_rows() == 0 {
385+
continue;
390386
}
391-
_ => {
392-
poll = Poll::Ready(value);
393-
break;
394-
}
395-
},
396-
Poll::Pending => {
397-
poll = Poll::Pending;
387+
timer.done();
388+
poll = Poll::Ready(Some(Ok(filtered_batch)));
389+
break;
390+
}
391+
value => {
392+
poll = Poll::Ready(value);
398393
break;
399394
}
400395
}

0 commit comments

Comments
 (0)