peterxcli commented on code in PR #23854:
URL: https://github.com/apache/datafusion/pull/23854#discussion_r3647630313
##########
datafusion/physical-plan/src/ordering.rs:
##########
@@ -52,3 +59,95 @@ pub enum InputOrderMode {
/// existing ordering.
Sorted,
}
+
+/// Build the filter expression with the given thresholds.
+/// This is now called outside of any locks to reduce critical section time.
+pub(crate) fn build_lexicographic_filter(
+ sort_exprs: &[PhysicalSortExpr],
+ thresholds: &[ScalarValue],
+) -> Result<Arc<dyn PhysicalExpr>> {
+ assert_or_internal_err!(!sort_exprs.is_empty(), "Sort expressions must not
be empty");
+ assert_or_internal_err!(
+ sort_exprs.len() == thresholds.len(),
+ "Sort expressions and thresholds must have the same length"
+ );
+
+ // Create filter expressions for each threshold
+ let mut filters: Vec<Arc<dyn PhysicalExpr>> =
Vec::with_capacity(thresholds.len());
+
+ let mut prev_sort_expr: Option<Arc<dyn PhysicalExpr>> = None;
+ for (sort_expr, value) in sort_exprs.iter().zip(thresholds.iter()) {
Review Comment:
actually I just move the `TopK::build_filter_expression` to here, so this
can be shared to build the comparison expression.
--
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]