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 2021/01/05 15:35:27 UTC

[GitHub] [arrow] andygrove commented on a change in pull request #9086: [Rust] [DataFusion] [Experiment] Blocking threads filter

andygrove commented on a change in pull request #9086:
URL: https://github.com/apache/arrow/pull/9086#discussion_r552008306



##########
File path: rust/datafusion/src/physical_plan/filter.rs
##########
@@ -103,25 +103,23 @@ impl ExecutionPlan for FilterExec {
     }
 
     async fn execute(&self, partition: usize) -> Result<SendableRecordBatchStream> {
-        Ok(Box::pin(FilterExecStream {
-            schema: self.input.schema().clone(),
-            predicate: self.predicate.clone(),
-            input: self.input.execute(partition).await?,
-        }))
+        let predicate = self.predicate.clone();
+
+        let stream = self.input.execute(partition).await?;
+        let stream = stream.then(move |batch| {
+            let predicate = predicate.clone();
+            async move {
+                // Filtering batches is CPU-bounded and therefore justifies a dedicated thread pool
+                task::spawn_blocking(move || batch_filter(&batch?, &predicate))
+                    .await
+                    .unwrap()
+            }
+        });
+
+        Ok(Box::pin(SizedRecordBatchStream::new(stream, self.schema())))

Review comment:
       Thanks @jorgecarleitao this seems to make a lot of sense.
   
   @alamb Was your comment a response to @Dandandan or an objection to using `spawn_blocking`? I wasn't sure.




----------------------------------------------------------------
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.

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