Jefffrey commented on code in PR #10292:
URL: https://github.com/apache/arrow-rs/pull/10292#discussion_r3529589129


##########
arrow-buffer/src/buffer/run.rs:
##########
@@ -421,4 +432,53 @@ mod tests {
         let sliced_values: Vec<i32> = sliced.sliced_values().collect();
         assert_eq!(sliced_values, &[2]);
     }
+
+    #[test]
+    fn test_compact_slicing() {
+        // {} represents a logical slice within physically expanded []
+        // [{A, A, A, A, B, B, B, B, C, C, C, C}]
+        let buffer = RunEndBuffer::<i32>::new(vec![4, 8, 12].into(), 0, 12);
+
+        // zero slice
+        let slice = buffer.slice(0, 0);
+        assert_eq!(slice.len(), 0);
+        assert_eq!(slice.offset(), 0);
+        assert_eq!(slice.values(), &[4]);
+
+        // compact start only
+        // [B, B, B, B, B, B, {B, B, C, C, C, C}]
+        let slice = buffer.slice(6, 6);
+        assert_eq!(slice.len(), 6);
+        assert_eq!(slice.offset(), 6);

Review Comment:
   i realized my initial version of the PR incorrectly adjusted the offset when 
that wasnt needed; by removing the first physical value its as if the first run 
was consumed by the following run since we always list run lengths; that is
   
   ```
   [4, 8] -> AAAABBBB
   [8] -> {BBBB}BBBB
   ```
   
   - where `{BBBB}` used to be a separate run but is now folded into the first 
run; this shouldnt matter as our logical offset points beyond it anyway



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