findepi commented on code in PR #12177:
URL: https://github.com/apache/datafusion/pull/12177#discussion_r1734146078
##########
datafusion/optimizer/src/eliminate_duplicated_expr.rs:
##########
@@ -79,14 +51,15 @@ impl OptimizerRule for EliminateDuplicatedExpr {
match plan {
LogicalPlan::Sort(sort) => {
let len = sort.expr.len();
- let unique_exprs: Vec<_> = sort
- .expr
- .into_iter()
- .map(|e| SortExprWrapper { expr: e })
- .collect::<IndexSet<_>>()
- .into_iter()
- .map(|wrapper| wrapper.expr)
- .collect();
+ let mut first_sort_by_expr: IndexMap<Expr, SortExpr> =
+ IndexMap::default();
+ for s in &sort.expr {
Review Comment:
i wasn't able to fully eliminate clone here.
see `reduce cloning in EliminateDuplicatedExpr` commit -- this is how far i
got.
can you please advise on how to improve it?
i though also about using `IndexMap<&Expr, usize>` to gather indexes of
surviving sort expressions, and then using that to filter the `Vec<Sort>`. This
would require hashing twice (first expressions, then surviving positions) and
still would involve copying for the output vec. so not sure this would help
overall, without measuring
--
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]