-
Notifications
You must be signed in to change notification settings - Fork 141
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
Add bitshuffle #986
Add bitshuffle #986
Conversation
Great. Could you add some tests? |
Will do. |
I think you are missing an implementation of |
Yes, working on it now. Having to write tests meant I discovered that I'd ignored the writing part of the filter... |
See HDF5.jl/filters/H5Zblosc/src/H5Zblosc.jl Line 19 in ccdb3e9
Also, we could just compile the C code for the plugin, probably as a separate Yggrassil recipe. We could then just use the |
It turns out that I put the lower compat limit of |
OK, I'm informed (see JuliaPackaging/Yggdrasil#5111) that the lower compatibility limit for |
These tests should only run with 1.6 then. Just use a |
I have used |
Co-authored-by: Mark Kittisopikul <[email protected]>
Co-authored-by: Mark Kittisopikul <[email protected]>
I'm happy to merge this if you are. Thanks again. |
Yes, I'm happy to merge. Thanks for your review and help. |
I'm pausing for a few days to give others the chance to review. I'm also going to do some further testing with plugins from other sources and via different APIs. |
Can the license correctly be categorized as a MIT license? |
Yes, it was meant to be a MIT license copied from the original bitshuffle distribution. Thanks for merging this. |
@jamesrhester , I'm seeing a sporadic CI failure on 64-bit Windows: We may need to review |
Looks like nightly is OK, but Julia 1.7 has a problem. I'll see if I can spin up a Windows 64 VM here and run the test repeatedly. |
I'm suspecting it could be because of a lack of |
The original code allocates 11 You also do not bump nelements by 3. |
I see now that you added three extra values to the struct similar to how we implemented the Blosc filter. |
Hmm, you never initialize |
The way this works, as I understand it, is that the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other things I noticed were:
- The values are zero initialized.
- We probably should integer division.
/
in Julia will produce a Float64.
nbytes_uncomp = ccall((:bshuf_read_uint64_BE,libbitshuffle),Cuint,(Ptr{Cvoid},),in_buf) | ||
# Next 4 bytes are the block size | ||
|
||
block_size = ccall((:bshuf_read_uint32_BE,libbitshuffle),Cuint,(Ptr{Cvoid},),in_buf+8)/elem_size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should ÷
here rather than /
. block_size
should be an integer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense.
nbytes_uncomp = nbytes | ||
if compress_flag == BSHUF_H5_COMPRESS_LZ4 | ||
buf_size_out = ccall((:bshuf_compress_lz4_bound,libbitshuffle),Cuint,(Cuint,Cuint,Cuint), | ||
nbytes_uncomp/elem_size,elem_size,block_size) + 12 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use ÷
here rather than /
, though Julia might take care of translating this back for us here.
nbytes_uncomp/elem_size,elem_size,block_size) + 12 | ||
elseif compress_flag == BSHUF_H5_COMPRESS_ZSTD | ||
buf_size_out = ccall((:bshuf_compress_zstd_bound,libbitshuffle),Cuint,(Cuint,Cuint,Cuint), | ||
nbytes_uncomp/elem_size,elem_size,block_size)+12 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use ÷
here rather than /
, though Julia might take care of translating this back for us here.
error("bitshuffle_h5plugin: Uncompressed size $nbytes_uncomp is not a multiple of $elem_size") | ||
end | ||
|
||
size = nbytes_uncomp/elem_size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use ÷
here rather than /
One issue I encountered that relates to This was due a specific change on the development branch of Julia though. What happens if I have a Windows box, and so far I am not able to reproduce the error reliably. |
I'm going to try to focus testing here: |
I read through that but couldn't see how it applies here. Weird bug though.
Well, as |
The problem is that you allocate it via The question is if |
|
Aha, I found something. The C function signature is: int64_t bshuf_decompress_lz4(const void* in, void* out, const size_t size,
const size_t elem_size, size_t block_size) { The err = ccall((:bshuf_decompress_lz4,libbitshuffle),Cint,
(Ptr{Cvoid},Ptr{Cvoid},Cuint,Cuint,Cuint),
in_buf,out_buf,size,elem_size,block_size) This should be err = ccall((:bshuf_decompress_lz4,libbitshuffle),Int64,
(Ptr{Cvoid},Ptr{Cvoid},Csize_t,Csize_t,Csize_t),
in_buf,out_buf,size,elem_size,block_size) julia> Csize_t
UInt64
julia> Cuint
UInt32 |
This adds the bitshuffle filter for HDF5. Closes #981.