MCPcopy Create free account
hub / github.com/apache/datafusion / fixed_size_array_reverse

Function fixed_size_array_reverse

datafusion/functions-nested/src/reverse.rs:264–287  ·  view source on GitHub ↗
(
    array: &FixedSizeListArray,
    field: &FieldRef,
)

Source from the content-addressed store, hash-verified

262}
263
264fn 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)]
290mod tests {

Callers 3

array_reverse_innerFunction · 0.85

Calls 7

newFunction · 0.85
collectMethod · 0.80
valuesMethod · 0.45
lenMethod · 0.45
reverseMethod · 0.45
clonedMethod · 0.45
nullsMethod · 0.45

Tested by 2

Used in the wild real call sites across dependent graphs

searching dependent graphs…