Resolve the frame for row at position `pos` in a partition of `len` rows. Returns `(start_idx, end_idx)` — both are inclusive indices into the sorted partition slice. Guaranteed: `start_idx <= end_idx`, both within `0..len`. Arguments: - `frame`: the `WindowFrame` from the spec. - `pos`: current row's position within the partition (0-based). - `len`: total number of rows in the partition. - `ord
(
frame: &WindowFrame,
pos: usize,
len: usize,
order_values: &[serde_json::Value],
peer_groups: &[usize],
)
| 27 | /// GROUPS mode). Computed once per partition by `build_peer_groups`. |
| 28 | /// Empty slice is fine when mode != "groups". |
| 29 | pub(super) fn evaluate_frame_bounds( |
| 30 | frame: &WindowFrame, |
| 31 | pos: usize, |
| 32 | len: usize, |
| 33 | order_values: &[serde_json::Value], |
| 34 | peer_groups: &[usize], |
| 35 | ) -> (usize, usize) { |
| 36 | match frame.mode.as_str() { |
| 37 | "rows" => rows_bounds(&frame.start, &frame.end, pos, len), |
| 38 | "range" => range_bounds(&frame.start, &frame.end, pos, len, order_values), |
| 39 | "groups" => groups_bounds(&frame.start, &frame.end, pos, len, peer_groups), |
| 40 | // Unrecognised mode treated as full-partition — the planner must have |
| 41 | // validated the mode; reaching here with an unknown value is a bug. |
| 42 | _ => (0, len.saturating_sub(1)), |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | /// Build a per-row peer-group index array for a partition. |
| 47 | /// |