(
a: Datum,
dim: i32,
)
| 3109 | } |
| 3110 | |
| 3111 | fn generate_subscripts_array( |
| 3112 | a: Datum, |
| 3113 | dim: i32, |
| 3114 | ) -> Result<Box<dyn Iterator<Item = (Row, Diff)>>, EvalError> { |
| 3115 | if dim <= 0 { |
| 3116 | return Ok(Box::new(iter::empty())); |
| 3117 | } |
| 3118 | |
| 3119 | match a.unwrap_array().dims().into_iter().nth( |
| 3120 | (dim - 1) |
| 3121 | .try_into() |
| 3122 | .map_err(|_| EvalError::Int32OutOfRange((dim - 1).to_string().into()))?, |
| 3123 | ) { |
| 3124 | Some(requested_dim) => { |
| 3125 | let lower_bound: i32 = requested_dim.lower_bound.try_into().map_err(|_| { |
| 3126 | EvalError::Int32OutOfRange(requested_dim.lower_bound.to_string().into()) |
| 3127 | })?; |
| 3128 | // The subscripts run from the lower bound to the upper bound, |
| 3129 | // inclusive. The upper bound is `lower_bound + length - 1`. |
| 3130 | let length: i32 = requested_dim |
| 3131 | .length |
| 3132 | .try_into() |
| 3133 | .map_err(|_| EvalError::Int32OutOfRange(requested_dim.length.to_string().into()))?; |
| 3134 | let upper_bound = lower_bound.checked_add(length - 1).ok_or_else(|| { |
| 3135 | EvalError::Int32OutOfRange(requested_dim.length.to_string().into()) |
| 3136 | })?; |
| 3137 | Ok(Box::new(generate_series::<i32>( |
| 3138 | lower_bound, |
| 3139 | upper_bound, |
| 3140 | 1, |
| 3141 | )?)) |
| 3142 | } |
| 3143 | None => Ok(Box::new(iter::empty())), |
| 3144 | } |
| 3145 | } |
| 3146 | |
| 3147 | fn unnest_array<'a>(a: Datum<'a>) -> impl Iterator<Item = (Row, Diff)> + 'a { |
| 3148 | a.unwrap_array() |
no test coverage detected