Rich-T-kid commented on code in PR #9959:
URL: https://github.com/apache/arrow-rs/pull/9959#discussion_r3295227060


##########
arrow-array/src/array/run_array.rs:
##########
@@ -781,6 +789,37 @@ where
         RunArrayIter::new(self)
     }
 }
+/// An array that can be downcast to a [`RunArray`] of any run end type and 
any value type.
+///
+/// This can be used to efficiently implement kernels for all possible run end
+/// types without needing to create specialized implementations for each key 
type.
+pub trait AnyRunEndArray: Array {
+    /// Returns the run ends of this array as a primitive array.
+    fn run_ends(&self) -> ArrayRef;
+
+    /// Returns the values of this array.
+    fn values(&self) -> &Arc<dyn Array>;
+
+    /// Returns a new run-end encoded array with the given values, preserving 
the
+    /// existing run ends.
+    fn with_values(&self, values: ArrayRef) -> ArrayRef;
+}

Review Comment:
   looking at the example you provided, shouldn't  `let array_sliced = 
array.slice(3, 3);` ideally be represented as `run_ends:[3],values:[2]` instead 
of  
   `{run_ends: [3, 6, 9], values: PrimitiveArray<Int32>
   [
     1,
     2,
     3,
   ]}`
    which is currently what `array.slice()` produces. due to `REE.slice()` 
copying the values arrays.
   
    I think the best approach for now would be to remove the `run_ends()` 
function and add it in later if there is a need. 
   Im not sure how we would avoid the extra work for `with_values()` without 
updating the `.slice()` method. But this would require looking at all the 
CallSites for slice first to make sure this doesn't cause breaking changes. In 
theory this shouldn't causes regressions though it should be an implementation 
detail.
   



-- 
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]

Reply via email to