-
Notifications
You must be signed in to change notification settings - Fork 3
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
Compatibility with bzip2 when decompressing multiple bzip2 streams/chunks in a single file #1
Comments
We can see the following All these repositories are abandoned and doesn't include library with clear api. I won't recommend anyone to use Personally I will use regular |
We are not actually using
This is because |
# Very simple example with small data to show the concept:
require "bzip2/ffi"
io = StringIO.new
# Write first stream
Bzip2::FFI::Writer.open(io) { |writer| writer.write("Hello World\n") }
# Write second stream (usually in a separate thread or on another machine)
Bzip2::FFI::Writer.open(io) { |writer| writer.write("Hello World2\n") }
# Write combined chunks into a single file
File.open("multiple.bz2", "wb") { |writer| writer.write(io.string) } Reading the file produced above using
Using Bzip2::FFI::Reader.open("multiple.bz2") { |reader| reader.read }
"Hello World\n" |
Thanks for the report. I've committed a fix and will put a new release together soon. |
The fix has now been released in v1.1.0. |
@philr I forget how thankless it is to make changes for random use-cases. |
When using pbzip2 it uses multiple threads to create compressed bzip2 files in parallel. The challenge is that to do so it breaks the input up into chunks and compresses each separately. The regular
bzip2
orbunzip2
command line interface handles this scenario and automatically decompresses the next chunk as the next bzip2 stream.For more details on the data format, please see item
4. PBZIP2 DATA FORMAT
at https://github.com/ruanhuabin/pbzip2Thank you for publishing your FFI interface into bzip2, it is now the required implementation for dealing with bzip2 in IOStreams.
The text was updated successfully, but these errors were encountered: