LiaCastaneda commented on code in PR #18938:
URL: https://github.com/apache/datafusion/pull/18938#discussion_r2564502734


##########
datafusion/physical-expr/src/expressions/dynamic_filters.rs:
##########
@@ -294,6 +294,16 @@ impl DynamicFilterPhysicalExpr {
             .await;
     }
 
+    /// Check if this dynamic filter is being actively used by any consumers.
+    ///
+    /// Returns `true` if there are references beyond the producer (e.g., the 
HashJoinExec
+    /// that created the filter). This is useful to avoid computing expensive 
filter
+    /// expressions when no consumer will actually use them.
+    pub fn is_used(self: &Arc<Self>) -> bool {
+        // Strong count > 1 means at least one consumer is holding a reference 
beyond the producer.
+        Arc::strong_count(self) > 1
+    }

Review Comment:
   I'm not really sure how to test a condition where is_used() returns false 
without adding too much machinery or making the `dynamic_filter` attribute from 
HashJoin public which would make it easy to mess with the Arc reference count. 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to