Build a per-row peer-group index array for a partition. Two rows are in the same peer group when they share the same order-by value. The returned vec has the same length as the partition; each element is the zero-based group index of that row.
(order_values: &[serde_json::Value])
| 49 | /// value. The returned vec has the same length as the partition; each element |
| 50 | /// is the zero-based group index of that row. |
| 51 | pub(super) fn build_peer_groups(order_values: &[serde_json::Value]) -> Vec<usize> { |
| 52 | let mut groups = Vec::with_capacity(order_values.len()); |
| 53 | let mut current_group = 0usize; |
| 54 | for (i, val) in order_values.iter().enumerate() { |
| 55 | if i > 0 && val != &order_values[i - 1] { |
| 56 | current_group += 1; |
| 57 | } |
| 58 | groups.push(current_group); |
| 59 | } |
| 60 | groups |
| 61 | } |
| 62 | |
| 63 | // ── ROWS ───────────────────────────────────────────────────────────────────── |
| 64 |