(
rows: &mut [Vec<Value>],
indices: &[usize],
column_index: &HashMap<String, usize>,
spec: &WindowFuncSpec,
write_col: usize,
)
| 109 | } |
| 110 | |
| 111 | fn apply_v_per_row_aggregate( |
| 112 | rows: &mut [Vec<Value>], |
| 113 | indices: &[usize], |
| 114 | column_index: &HashMap<String, usize>, |
| 115 | spec: &WindowFuncSpec, |
| 116 | write_col: usize, |
| 117 | ) { |
| 118 | let len = indices.len(); |
| 119 | if len == 0 { |
| 120 | return; |
| 121 | } |
| 122 | |
| 123 | let order_expr = spec.order_by.first().map(|(expr, _)| expr); |
| 124 | let order_values: Vec<Value> = indices |
| 125 | .iter() |
| 126 | .map(|&i| { |
| 127 | order_expr |
| 128 | .and_then(|expr| { |
| 129 | rows.get(i) |
| 130 | .map(|row| eval_arg_for_row(expr, row, column_index)) |
| 131 | }) |
| 132 | .unwrap_or(Value::Null) |
| 133 | }) |
| 134 | .collect(); |
| 135 | |
| 136 | let peer_groups: Vec<usize> = if spec.frame.mode == "groups" { |
| 137 | build_v_peer_groups(&order_values) |
| 138 | } else { |
| 139 | Vec::new() |
| 140 | }; |
| 141 | |
| 142 | let all_vals: Vec<Option<f64>> = indices |
| 143 | .iter() |
| 144 | .map(|&i| { |
| 145 | rows.get(i) |
| 146 | .map(|row| eval_arg(spec, row, column_index).as_f64()) |
| 147 | .unwrap_or(None) |
| 148 | }) |
| 149 | .collect(); |
| 150 | |
| 151 | let results: Vec<Value> = (0..len) |
| 152 | .map(|pos| { |
| 153 | let (start_idx, end_idx) = |
| 154 | evaluate_v_frame_bounds(&spec.frame, pos, len, &order_values, &peer_groups); |
| 155 | aggregate_v_slice( |
| 156 | &all_vals, |
| 157 | indices, |
| 158 | rows, |
| 159 | column_index, |
| 160 | spec, |
| 161 | start_idx, |
| 162 | end_idx, |
| 163 | ) |
| 164 | }) |
| 165 | .collect(); |
| 166 | |
| 167 | for (pos, result) in results.into_iter().enumerate() { |
| 168 | set_cell(rows, indices[pos], write_col, result); |
no test coverage detected