diff --git a/src/io/ipc/compression.rs b/src/io/ipc/compression.rs index a26a95b450c..b98d670b799 100644 --- a/src/io/ipc/compression.rs +++ b/src/io/ipc/compression.rs @@ -33,7 +33,8 @@ pub fn decompress_zstd(_input_buf: &[u8], _output_buf: &mut [u8]) -> Result<()> pub fn compress_lz4(input_buf: &[u8], output_buf: &mut Vec) -> Result<()> { use std::io::Write; let mut encoder = lz4::EncoderBuilder::new().build(output_buf).unwrap(); - encoder.write_all(input_buf).map_err(|e| e.into()) + encoder.write_all(input_buf)?; + encoder.finish().1.map_err(|e| e.into()) } #[cfg(feature = "io_ipc_compression")] @@ -62,7 +63,7 @@ mod tests { #[cfg(feature = "io_ipc_compression")] #[test] - fn round_trip() { + fn round_trip_zstd() { let data: Vec = (0..200u8).map(|x| x % 10).collect(); let mut buffer = vec![]; compress_zstd(&data, &mut buffer).unwrap(); @@ -71,4 +72,16 @@ mod tests { decompress_zstd(&buffer, &mut result).unwrap(); assert_eq!(data, result); } + + #[cfg(feature = "io_ipc_compression")] + #[test] + fn round_trip_lz4() { + let data: Vec = (0..200u8).map(|x| x % 10).collect(); + let mut buffer = vec![]; + compress_lz4(&data, &mut buffer).unwrap(); + + let mut result = vec![0; 200]; + decompress_lz4(&buffer, &mut result).unwrap(); + assert_eq!(data, result); + } }