findepi commented on code in PR #17442: URL: https://github.com/apache/datafusion/pull/17442#discussion_r2330208915
########## datafusion/physical-expr-common/src/sort_expr.rs: ########## @@ -367,8 +367,21 @@ impl LexOrdering { /// Creates a new [`LexOrdering`] from the given vector of sort expressions. /// If the vector is empty, returns `None`. pub fn new(exprs: impl IntoIterator<Item = PhysicalSortExpr>) -> Option<Self> { - let (non_empty, ordering) = Self::construct(exprs); - non_empty.then_some(ordering) + let exprs = exprs.into_iter(); Review Comment: > I personally suggest avoiding the Vec::with_capacity call unless we are sure it is better I added it only because a test complained. There is a test checking exact allocated memory and without pre-sizing, the test was reporting a slightly higher value then the old code. Will it be OK to drop `with_capacity`, and thus increase code readability and just update that test? That would be the following changes ```diff diff --git datafusion/physical-expr-common/src/sort_expr.rs datafusion/physical-expr-common/src/sort_expr.rs index f7ce8fda7..d19d7024a 100644 --- datafusion/physical-expr-common/src/sort_expr.rs +++ datafusion/physical-expr-common/src/sort_expr.rs @@ -368,10 +368,9 @@ impl LexOrdering { /// If the vector is empty, returns `None`. pub fn new(exprs: impl IntoIterator<Item = PhysicalSortExpr>) -> Option<Self> { let exprs = exprs.into_iter(); - let (items_min, items_max) = exprs.size_hint(); let mut candidate = Self { // not valid yet; valid publicly-returned instance must be non-empty - exprs: Vec::with_capacity(items_max.unwrap_or(items_min)), + exprs: Vec::new(), set: HashSet::new(), }; for expr in exprs { diff --git datafusion/functions-aggregate/src/array_agg.rs datafusion/functions-aggregate/src/array_agg.rs index 321deb0d2..268349ecf 100644 --- datafusion/functions-aggregate/src/array_agg.rs +++ datafusion/functions-aggregate/src/array_agg.rs @@ -1105,7 +1105,7 @@ mod tests { ])])?; // without compaction, the size is 17112 - assert_eq!(acc.size(), 2112); + assert_eq!(acc.size(), 2184); Ok(()) } ``` -- 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