You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/11/29 10:22:37 UTC

[GitHub] [arrow-datafusion] xudong963 opened a new pull request, #4421: Optimzie filter executor in pull-based executor

xudong963 opened a new pull request, #4421:
URL: https://github.com/apache/arrow-datafusion/pull/4421

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   No
   
   # Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   If **Selection operator** doesn't produce any rows, we can just pull next `RecordBatch`es from it.
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   Add loop for filter executor.
   
   # Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   Covered by existing tests
   
   # Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->
   
   No


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] xudong963 commented on pull request #4421: Optimzie filter executor in pull-based executor

Posted by GitBox <gi...@apache.org>.
xudong963 commented on PR #4421:
URL: https://github.com/apache/arrow-datafusion/pull/4421#issuecomment-1330411212

   I think the more elegant way is to directly **Skip** current iterator to the next iterator.
   
   For example:
   
   ```rust
   trait A {
       fn execute() -> Result<Stream>;
   }
   
   
   Struct B {
       input: C,
   }
   
   Struct C {
       input: D
   }
   
   Struct D {
       
   }
   
   // All D, B, C have implemented trait A and trait Stream
   // Each execute method will call its input's execute method
   
   
   fn main {
       let b = B::new();
       let data_stream = b.execute();
       while let Some(stream) = data_stream.next().await {
           ...
       }
   }
   
   impl Stream for C {
       type Item = ..;
   
       fn poll_next(
           mut self: std::pin::Pin<&mut Self>,
           cx: &mut Context<'_>,
       ) -> Poll<Option<Self::Item>> {
           ...
           if !predicate(value) {
               // Skip current iteration
           }
       }
   }
   ```
   But I don't find a proper way to implement it, `Stream` crate seems not to provide related API. Any thoughts? @tustvold 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] xudong963 merged pull request #4421: Optimize filter executor in pull-based executor

Posted by GitBox <gi...@apache.org>.
xudong963 merged PR #4421:
URL: https://github.com/apache/arrow-datafusion/pull/4421


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] xudong963 commented on pull request #4421: Optimize filter executor in pull-based executor

Posted by GitBox <gi...@apache.org>.
xudong963 commented on PR #4421:
URL: https://github.com/apache/arrow-datafusion/pull/4421#issuecomment-1332018214

   Thanks for your review!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #4421: Optimize filter executor in pull-based executor

Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #4421:
URL: https://github.com/apache/arrow-datafusion/pull/4421#discussion_r1034939706


##########
datafusion/core/src/physical_plan/filter.rs:
##########
@@ -238,15 +238,31 @@ impl Stream for FilterExecStream {
         mut self: Pin<&mut Self>,
         cx: &mut Context<'_>,
     ) -> Poll<Option<Self::Item>> {
-        let poll = self.input.poll_next_unpin(cx).map(|x| match x {
-            Some(Ok(batch)) => {
-                let timer = self.baseline_metrics.elapsed_compute().timer();
-                let filtered_batch = batch_filter(&batch, &self.predicate);
-                timer.done();
-                Some(filtered_batch)
+        let poll;
+        loop {
+            match self.input.poll_next_unpin(cx) {
+                Poll::Ready(value) => match value {
+                    Some(Ok(batch)) => {
+                        let timer = self.baseline_metrics.elapsed_compute().timer();
+                        let filtered_batch = batch_filter(&batch, &self.predicate)?;
+                        if filtered_batch.num_rows() == 0 {

Review Comment:
   ```suggestion
                           // skip entirely filtered batches
                           if filtered_batch.num_rows() == 0 {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] ursabot commented on pull request #4421: Optimize filter executor in pull-based executor

Posted by GitBox <gi...@apache.org>.
ursabot commented on PR #4421:
URL: https://github.com/apache/arrow-datafusion/pull/4421#issuecomment-1332021400

   Benchmark runs are scheduled for baseline = fdc83e8524df30ac5d0ae097572b7c48dc686ba9 and contender = 522a2a4adea48777f330cac074db94a4da3ea66b. 522a2a4adea48777f330cac074db94a4da3ea66b is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/14d6d0978d0d49059a99568a8e2de4d6...4504a773120047c3bba8a0d82cc7b60b/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/3d4efcfc95c44cda8b398997fcd9a7e0...a1c91d14ffc54f8d9663675d20400b9d/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/1353381eb2bd42058db5692685edbf29...a98dc8f7bf65471d9faf2d3cee177e17/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/ea7d7b7ffa9848d1a6fd2908afe2a8bc...67aca4017ca7465ab272ced1ae7b680f/)
   Buildkite builds:
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
   test-mac-arm: Supported benchmark langs: C++, Python, R
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org