Dandandan commented on code in PR #16433:
URL: https://github.com/apache/datafusion/pull/16433#discussion_r2156133514


##########
datafusion/physical-plan/src/topk/mod.rs:
##########
@@ -319,13 +341,87 @@ impl TopK {
     /// (a > 2 OR (a = 2 AND b < 3))
     /// ```
     fn update_filter(&mut self) -> Result<()> {
-        let Some(filter) = &self.filter else {
-            return Ok(());
-        };
         let Some(thresholds) = self.heap.get_threshold_values(&self.expr)? 
else {
             return Ok(());
         };
 
+        // Are the new thresholds more selective than our existing ones?
+        let should_update = {
+            let mut current = self.filter.thresholds.write();

Review Comment:
   Perhaps this lock takes too long + overhead of doing this for all updates + 
all partitions quite often?
   We could also store a `Row` instead of  `thresholds` to make comparison much 
quicker (should also be able to avoid allocations)?



-- 
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-unsubscr...@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to