Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip attempt to use lz4-flex #3

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions parquet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ thrift = "0.13"
snap = { version = "1.0", optional = true }
brotli = { version = "3.3", optional = true }
flate2 = { version = "1.0", optional = true }
lz4 = { version = "1.23", optional = true }
lz4_flex = { version = "0.9.2", optional = true }
zstd = { version = "0.10", optional = true }
chrono = { version = "0.4", default-features = false }
num = "0.4"
Expand All @@ -56,12 +56,13 @@ snap = "1.0"
tempfile = "3.0"
brotli = "3.3"
flate2 = "1.0"
lz4 = "1.23"
lz4_flex = { version = "0.9.2" }
serde_json = { version = "1.0", features = ["preserve_order"] }
arrow = { path = "../arrow", version = "9.1.0", default-features = false, features = ["test_utils", "prettyprint"] }

[features]
default = ["arrow", "snap", "brotli", "flate2", "lz4", "zstd", "base64"]
lz4 = ["lz4_flex"]
cli = ["serde_json", "base64", "clap"]
test_common = []
# Experimental, unstable functionality primarily used for testing
Expand Down
10 changes: 6 additions & 4 deletions parquet/src/compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,12 @@ mod lz4_codec {
input_buf: &[u8],
output_buf: &mut Vec<u8>,
) -> Result<usize> {
let mut decoder = lz4::Decoder::new(input_buf)?;
let mut decoder = lz4_flex::frame::FrameDecoder::new(input_buf);
let mut buffer: [u8; LZ4_BUFFER_SIZE] = [0; LZ4_BUFFER_SIZE];
let mut total_len = 0;
loop {
let len = decoder.read(&mut buffer)?;
let len = decoder.read(&mut buffer).unwrap();
// let len = decoder.read_exact(&mut buffer)?;
if len == 0 {
break;
}
Expand All @@ -260,7 +261,7 @@ mod lz4_codec {
}

fn compress(&mut self, input_buf: &[u8], output_buf: &mut Vec<u8>) -> Result<()> {
let mut encoder = lz4::EncoderBuilder::new().build(output_buf)?;
let mut encoder = lz4_flex::frame::FrameEncoder::new(output_buf);
let mut from = 0;
loop {
let to = std::cmp::min(from + LZ4_BUFFER_SIZE, input_buf.len());
Expand All @@ -270,7 +271,8 @@ mod lz4_codec {
break;
}
}
encoder.finish().1.map_err(|e| e.into())
encoder.finish().unwrap();
Ok(())
}
}
}
Expand Down