tustvold commented on code in PR #4319:
URL: https://github.com/apache/arrow-rs/pull/4319#discussion_r1212317953


##########
parquet/src/column/reader/decoder.rs:
##########
@@ -473,17 +485,39 @@ mod tests {
     }
 
     #[test]
-    fn test_skip() {
-        let mut rng = thread_rng();
-        let total_len = 10000;
-        let encoded: Vec<i16> = (0..total_len).map(|_| 
rng.gen_range(0..5)).collect();
-        let mut encoder = RleEncoder::new(3, 1024);
-        for v in &encoded {
-            encoder.put(*v as _)
-        }
+    fn test_skip_padding() {
+        let mut encoder = RleEncoder::new(1, 1024);
+        encoder.put(0);
+        (0..3).for_each(|_| encoder.put(1));
         let data = ByteBufferPtr::new(encoder.consume());
 
+        let mut decoder = ColumnLevelDecoderImpl::new(1);
+        decoder.set_data(Encoding::RLE, data.clone());
+        let (records, levels) = decoder.skip_rep_levels(100, 4).unwrap();
+        assert_eq!(records, 1);
+        assert_eq!(levels, 4);
+
+        // The length of the final bit packed run is ambiguous, so without the 
correct
+        // levels limit, it will decode zero padding
+        let mut decoder = ColumnLevelDecoderImpl::new(1);
+        decoder.set_data(Encoding::RLE, data);
+        let (records, levels) = decoder.skip_rep_levels(100, 6).unwrap();
+        assert_eq!(records, 3);
+        assert_eq!(levels, 6);
+    }
+
+    #[test]
+    fn test_skip() {
         for _ in 0..10 {
+            let mut rng = thread_rng();

Review Comment:
   Moving this into the for loop makes it more likely to encounter issues 
inherent to the RLE data, as opposed to the selection of it



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