Skip to content

Commit c60191a

Browse files
sundy-lidantengsky
authored andcommitted
relace lz4 with lz4_flex in flight ipc
1 parent 964a086 commit c60191a

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/common/arrow/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ itertools = { workspace = true, optional = true }
110110
lexical-core = { version = "0.8", optional = true }
111111
log = { workspace = true }
112112
lz4 = { version = "1.24" }
113+
lz4_flex = { version = "0.11.3" }
113114
num = { version = "0.4", default-features = false, features = ["std"] }
114115
num-traits = "0.2"
115116
opendal = { workspace = true }

src/common/arrow/src/arrow/io/ipc/compression.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use crate::arrow::error::Result;
1919
#[cfg_attr(docsrs, doc(cfg(feature = "io_ipc_compression")))]
2020
pub fn decompress_lz4(input_buf: &[u8], output_buf: &mut [u8]) -> Result<()> {
2121
use std::io::Read;
22-
let mut decoder = lz4::Decoder::new(input_buf)?;
23-
decoder.read_exact(output_buf).map_err(|e| e.into())
22+
let _ = lz4_flex::frame::FrameDecoder::new(input_buf).read(output_buf)?;
23+
Ok(())
2424
}
2525

2626
#[cfg(feature = "io_ipc_compression")]
@@ -49,11 +49,13 @@ pub fn compress_lz4(input_buf: &[u8], output_buf: &mut Vec<u8>) -> Result<()> {
4949
use std::io::Write;
5050

5151
use crate::arrow::error::Error;
52-
let mut encoder = lz4::EncoderBuilder::new()
53-
.build(output_buf)
54-
.map_err(Error::from)?;
52+
53+
let mut encoder = lz4_flex::frame::FrameEncoder::new(output_buf);
5554
encoder.write_all(input_buf)?;
56-
encoder.finish().1.map_err(|e| e.into())
55+
encoder
56+
.finish()
57+
.map_err(|e| Error::External("lz4_compress".to_string(), Box::new(e)))?;
58+
Ok(())
5759
}
5860

5961
#[cfg(feature = "io_ipc_compression")]

0 commit comments

Comments
 (0)