Skip to content

Commit

Permalink
rust-ext: upgrade zstd-safe and zstd-bytes to latest using zstd 1.5.2
Browse files Browse the repository at this point in the history
There were some API changes in newer versions of the crate that
forced minor code changes to get things to compile.
  • Loading branch information
indygreg committed Feb 19, 2023
1 parent 344af94 commit 42e25d0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
15 changes: 11 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ num_cpus = "1.15.0"
rayon = "1.6.1"

[dependencies.zstd-safe]
version = "5.0.2+zstd.1.5.2"
version = "=6.0.3+zstd.1.5.2"
features = ["experimental", "legacy", "zstdmt"]

[dependencies.zstd-sys]
version = "2.0.1+zstd.1.5.2"
version = "=2.0.6+zstd.1.5.2"
features = ["experimental", "legacy", "zstdmt"]

[dependencies.pyo3]
Expand Down
4 changes: 3 additions & 1 deletion rust-ext/src/compression_dict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ impl ZstdCompressionDict {
}

fn dict_id(&self) -> u32 {
zstd_safe::get_dict_id(&self.data).unwrap_or(0)
zstd_safe::get_dict_id(&self.data)
.map(u32::from)
.unwrap_or(0)
}

#[args(level = "None", compression_params = "None")]
Expand Down
18 changes: 11 additions & 7 deletions rust-ext/src/decompressor_multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,17 @@ fn decompress_from_datasources(
};

let decompressed_size = if source.decompressed_size == 0 {
let frame_size = zstd_safe::get_frame_content_size(source.data);

if frame_size == zstd_safe::CONTENTSIZE_ERROR
|| frame_size == zstd_safe::CONTENTSIZE_UNKNOWN
{
result.error = WorkerError::NoSize;
}
let frame_size = match zstd_safe::get_frame_content_size(source.data) {
Err(zstd_safe::ContentSizeError) => {
result.error = WorkerError::NoSize;
zstd_safe::CONTENTSIZE_ERROR
}
Ok(None) => {
result.error = WorkerError::NoSize;
zstd_safe::CONTENTSIZE_UNKNOWN
}
Ok(Some(frame_size)) => frame_size,
};

frame_size as _
} else {
Expand Down

0 comments on commit 42e25d0

Please sign in to comment.