Abdallah-Afifi commented on code in PR #11539:
URL: https://github.com/apache/arrow-rs/pull/11539#discussion_r4710481664
##########
parquet/src/encodings/encoding/alp_encoder.rs:
##########
@@ -1125,4 +1167,55 @@ mod tests {
"a leading empty page must not affect encoding of the first
nonempty page"
);
}
+ /// Every `log_vector_size` the format permits must round-trip, including
the
+ /// 3 and 15 bounds, and across both the buffered first page and the
streaming path.
+ #[test]
+ fn test_roundtrip_all_vector_sizes() {
+ let values: Vec<f64> = (0..5000).map(|i| (i as f64) * 0.01 -
7.5).collect();
+ for log_vector_size in 3u8..=15 {
+ let out = roundtrip_with_log_vector_size::<DoubleType>(&values,
log_vector_size);
+ assert_bits_eq(&out, &values);
+ }
+ }
+
+ /// A non-default vector size must survive the streaming path, where the
size
+ /// governs the carry across `put` boundaries.
+ #[test]
+ fn test_streaming_with_non_default_vector_size() {
+ let page1: Vec<f64> = (0..3000).map(|i| (i as f64) * 0.01).collect();
+ let page2: Vec<f64> = (0..3000).map(|i| (i as f64) * 0.03 -
7.0).collect();
+ let options = AlpEncoderOptions::try_new(13).unwrap();
+ let vector_size = options.vector_size();
+
+ let mut encoder = AlpEncoder::<DoubleType>::new_with_options(options);
+ encoder.put(&page1).unwrap();
+ let _ = encoder.flush_buffer().unwrap();
+
+ // Feed page 2 in chunks that straddle vector boundaries.
+ for chunk in page2.chunks(997) {
+ encoder.put(chunk).unwrap();
+ }
+ let streamed = encoder.flush_buffer().unwrap();
+
+ // Same values, same preset, encoded in one pass.
+ let preset = build_preset(&page1, vector_size);
+ let mut scratch = Scratch::<f64>::new();
+ let reference = encode_page(&page2, &preset, vector_size, &mut
scratch).unwrap();
+ assert_eq!(streamed.as_ref(), reference.as_slice());
+ }
Review Comment:
Removed. You're right that 3000 values never fill an 8192 vector, so it
never ran the loop or the split. It did catch a hardcoded 1024 in the carry
split, since that sends it down the split path, but the new round-trip test
catches that too, so nothing is lost.
--
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]