vegarsti commented on code in PR #18424:
URL: https://github.com/apache/datafusion/pull/18424#discussion_r2483162083


##########
datafusion/functions-nested/src/reverse.rs:
##########
@@ -183,6 +196,50 @@ fn general_array_reverse<O: OffsetSizeTrait + 
TryFrom<i64>>(
     )?))
 }
 
+fn list_view_reverse<O: OffsetSizeTrait + TryFrom<i64>>(
+    array: &GenericListViewArray<O>,
+    field: &FieldRef,
+) -> Result<ArrayRef> {
+    let (_, offsets, sizes, values, nulls) = array.clone().into_parts();
+
+    // Construct indices corresponding to the reversed arrays
+    let mut indices: Vec<O> = Vec::with_capacity(values.len());
+    for (i, offset) in offsets.iter().enumerate().take(offsets.len()) {
+        // Each array is located at [offset, offset + size), so we collect 
indices in the reverse order
+        let array_start = offset.as_usize();
+        let array_end = array_start + sizes[i].as_usize();
+        for idx in (array_start..array_end).rev() {
+            indices.push(O::usize_as(idx));
+        }
+    }
+
+    // Take values from underlying array in the reversed order
+    let indices_array: ArrayRef = match size_of::<O>() {

Review Comment:
   I'm not sure about this, but I wanted to 1) avoid unwraps 2) don't use 64 if 
32 was sufficient.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to