You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2023/06/01 12:01:12 UTC
[GitHub] [arrow-rs] alamb commented on a diff in pull request #4319: Handle trailing padding when skipping repetition levels (#3911)
alamb commented on code in PR #4319:
URL: https://github.com/apache/arrow-rs/pull/4319#discussion_r1213042654
##########
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:
it might make sense to add a note to the test giving the rationale for the loop (and maybe name the test 'test_ski-_fuzz` or something
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org