(
array: &FixedSizeListArray,
field: &FieldRef,
)
| 262 | } |
| 263 | |
| 264 | fn fixed_size_array_reverse( |
| 265 | array: &FixedSizeListArray, |
| 266 | field: &FieldRef, |
| 267 | ) -> Result<ArrayRef> { |
| 268 | let values: &Arc<dyn Array> = array.values(); |
| 269 | |
| 270 | // Since each fixed size list in the physical array is the same size and we keep the order |
| 271 | // of the fixed size lists, we can reverse the indices for each fixed size list. |
| 272 | let mut indices: Vec<u64> = (0..values.len() as u64).collect(); |
| 273 | for chunk in indices.chunks_mut(array.value_length() as usize) { |
| 274 | chunk.reverse(); |
| 275 | } |
| 276 | |
| 277 | // Materialize values from underlying array with take |
| 278 | let indices_array: ArrayRef = Arc::new(UInt64Array::from(indices)); |
| 279 | let values = take(&values, &indices_array, None)?; |
| 280 | |
| 281 | Ok(Arc::new(FixedSizeListArray::try_new( |
| 282 | Arc::clone(field), |
| 283 | array.value_length(), |
| 284 | values, |
| 285 | array.nulls().cloned(), |
| 286 | )?)) |
| 287 | } |
| 288 | |
| 289 | #[cfg(test)] |
| 290 | mod tests { |
searching dependent graphs…