Skip to content

Commit

Permalink
Make update_elements_with_matching_indices take iterators for proj_…
Browse files Browse the repository at this point in the history
…indices
  • Loading branch information
gokselk committed Jan 16, 2025
1 parent 5f9980a commit d136860
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions datafusion/common/src/functional_dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,13 +600,20 @@ pub fn get_required_group_by_exprs_indices(

/// Updates entries inside the `entries` vector with their corresponding
/// indices inside the `proj_indices` vector.
fn update_elements_with_matching_indices(
fn update_elements_with_matching_indices<'a>(
entries: &[usize],
proj_indices: &[usize],
proj_indices: impl IntoIterator<Item = &'a usize>,
) -> Vec<usize> {
entries
.iter()
.filter_map(|val| proj_indices.iter().position(|proj_idx| proj_idx == val))
proj_indices
.into_iter()
.enumerate()
.filter_map(|(pos, proj_idx)| {
if entries.contains(proj_idx) {
Some(pos)
} else {
None
}
})
.collect()
}

Expand Down

0 comments on commit d136860

Please sign in to comment.