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

compression level support #23

Closed
dmitrip opened this issue Apr 1, 2020 · 2 comments
Closed

compression level support #23

dmitrip opened this issue Apr 1, 2020 · 2 comments

Comments

@dmitrip
Copy link

dmitrip commented Apr 1, 2020

It seems that different compression levels are not supported (although level is passed to the ccall of ZSTD_initCStream in libzstd.jl):

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.4.0 (2020-03-21)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using Pkg; Pkg.status("CodecZstd")
Status `~/.julia/environments/v1.4/Project.toml`
  [6b39b394] CodecZstd v0.7.0

julia> using CodecZstd

julia> data = rand(0xa:0xb, 10^6); # something compressible

julia> unique(length(transcode(ZstdCompressor(level=level), data)) for level in 1:22)
# returns a 1-element array, so the compressed length is independent of level

Tips for debugging or understanding this?

@dmitrip dmitrip changed the title compression level support? compression level support Apr 1, 2020
@milankl
Copy link

milankl commented Aug 20, 2020

Maybe the initialization is not properly set up? If I do

julia> using TranscodingStreams, CodecZstd
julia> A = sort(rand(UInt8,1000));

julia> ZstdCompressorL3 = ZstdCompressor(level=3)
julia> ZstdCompressorL22 = ZstdCompressor(level=22)
julia> TranscodingStreams.initialize(ZstdCompressorL3)
julia> TranscodingStreams.initialize(ZstdCompressorL22)

julia> sizeof(A)/sizeof(transcode(ZstdCompressorL3,A))
1.6207455429497568

julia> sizeof(A)/sizeof(transcode(ZstdCompressorL22,A))
1.9083969465648856

choosing the level does indeed have an effect.

@dmitrip
Copy link
Author

dmitrip commented Aug 21, 2020

You're right that the initialize call fixes this, and I now realize that this is intended behavior as documented in the transcode(codec::Codec, data::Vector{UInt8}) method in TranscodingStreams.jl.

@dmitrip dmitrip closed this as completed Aug 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants