(
rows: &[Vec<Value>],
column_index: &HashMap<String, usize>,
spec: &WindowFuncSpec,
)
| 91 | // ── Partition building ──────────────────────────────────────────────────────── |
| 92 | |
| 93 | fn build_value_partitions( |
| 94 | rows: &[Vec<Value>], |
| 95 | column_index: &HashMap<String, usize>, |
| 96 | spec: &WindowFuncSpec, |
| 97 | ) -> Result<Vec<Vec<usize>>, WindowError> { |
| 98 | if spec.partition_by.is_empty() { |
| 99 | return Ok(vec![(0..rows.len()).collect()]); |
| 100 | } |
| 101 | |
| 102 | let mut groups: HashMap<String, Vec<usize>> = HashMap::new(); |
| 103 | let mut order: Vec<String> = Vec::new(); |
| 104 | |
| 105 | for (i, row) in rows.iter().enumerate() { |
| 106 | let key = partition_key(row, column_index, &spec.partition_by); |
| 107 | let entry = groups.entry(key.clone()).or_default(); |
| 108 | if entry.is_empty() { |
| 109 | order.push(key); |
| 110 | } |
| 111 | entry.push(i); |
| 112 | } |
| 113 | |
| 114 | Ok(order.iter().filter_map(|k| groups.remove(k)).collect()) |
| 115 | } |
| 116 | |
| 117 | fn partition_key( |
| 118 | row: &[Value], |
no test coverage detected