Derive supporting logic to support transforming rows to (key, val) pairs, and back again. We are given as input a list of mappings from columns to key indices, a key length, and an input arity. (The produced key should be the application of the key expressions.) To produce the `val` output, we will identify those input columns not found in the key expressions, and name all other columns. To reco
(
key: &[impl Columns],
unthinned_arity: usize,
)
| 1514 | /// `compute_types::plan::AvailableCollections`; see the |
| 1515 | /// documentation there for more details. |
| 1516 | pub fn permutation_for_arrangement( |
| 1517 | key: &[impl Columns], |
| 1518 | unthinned_arity: usize, |
| 1519 | ) -> (Vec<usize>, Vec<usize>) { |
| 1520 | let columns_in_key: BTreeMap<_, _> = key |
| 1521 | .iter() |
| 1522 | .enumerate() |
| 1523 | .filter_map(|(i, key_col)| key_col.as_column().map(|c| (c, i))) |
| 1524 | .collect(); |
| 1525 | |
| 1526 | let mut input_cursor = key.len(); |
| 1527 | let permutation = (0..unthinned_arity) |
| 1528 | .map(|c| { |
| 1529 | if let Some(c) = columns_in_key.get(&c) { |
| 1530 | // Column is in key (and thus gone from the value |
| 1531 | // of the thinned representation) |
| 1532 | *c |
| 1533 | } else { |
| 1534 | // Column remains in value of the thinned representation |
| 1535 | input_cursor += 1; |
| 1536 | input_cursor - 1 |
| 1537 | } |
| 1538 | }) |
| 1539 | .collect(); |
| 1540 | let thinning = (0..unthinned_arity) |
| 1541 | .filter(|c| !columns_in_key.contains_key(c)) |
| 1542 | .collect(); |
| 1543 | (permutation, thinning) |
| 1544 | } |
| 1545 | |
| 1546 | /// Given the permutations (see [`permutation_for_arrangement`] and |
| 1547 | /// (`dataflow::plan::AvailableCollections`) corresponding to two |
no test coverage detected