koraktor / rbzip2 Goto Github PK
View Code? Open in Web Editor NEWbzip2 for Ruby
License: BSD 3-Clause "New" or "Revised" License
bzip2 for Ruby
License: BSD 3-Clause "New" or "Revised" License
The most recently released version of this gem on Rubygems is 0.2.0
. I'd like to use this gem as a dependency in BrickAndMortar but I can't get 0.2.0
to work. The current commit, f8ab1ea, seems to work just fine for me (decompression only).
Is someone working on making a new release soon, or could I help to accomplish this?
If you're concerned about the gem not being stable enough yet, how about a release candidate version like 0.3.0-rc1
?
I am trying to use this gem under JRuby 1.7.4 for decompressing file compressed in bzip2.
The size of compressed file is 422Kb. The decompressed file have 7.9M. Decompression by bzip2 in Linux take less than 1s.
When I am using the gem, the part of code RBzip2::Decompressor.new file take around 30s and the read part take more than 30mins ( yes minutes ). During the decompression Jruby process is taking 100% of one core on my PC. I am running it on Fedora 16. Java version 1.7.0.
BZip2's public API functions use the stdcall calling convention on Windows, but rbzip2 tries to load them using the default cdecl convention. This leads to the functions not being found by FFI:
C:/Ruby225/lib/ruby/gems/2.2.0/gems/ffi-1.9.18-x86-mingw32/lib/ffi/library.rb:275:in `attach_function': Function 'BZ2_bzRead' not found in [bz2] (FFI::NotFoundError)
from C:/Ruby225/lib/ruby/gems/2.2.0/gems/rbzip2-0.3.0/lib/rbzip2/ffi/decompressor.rb:20:in `<class:Decompressor>'
from C:/Ruby225/lib/ruby/gems/2.2.0/gems/rbzip2-0.3.0/lib/rbzip2/ffi/decompressor.rb:7:in `<top (required)>'
from C:/my_script.rb:45:in `<main>'
I am switching from MRI to JRuby and as such, I was replacing bzip2-ruby with rbzip2. Unfortunately this didn't work out because I am passing the resulting IO object to fastest-csv, which uses gets. bzip2-ruby implements this but rbzip2 doesn't. It's possibly less than trivial to implement and I may not have time right now.
When calling the write method more than once is ignoring new data:
def bz2_read_file(file_name)
File.open(file_name) do |file|
io = RBzip2.default_adapter::Decompressor.new(file)
data = io.read
io.close
data
end
end
File.open("test3.bz2", "wb") do |file|
writer = RBzip2.default_adapter::Compressor.new(file)
writer.write("line1\n")
writer.write("line2\n")
writer.write("line3\n")
writer.close
end
bz2_read_file("test3.bz2")
Only the first line is returned from the output file:
"line1\n"
Even for a moderately large file, RBzip2::Decompressor.new never returns, because it seems to sit endlessly in get_and_move_to_front_decode
.
Code snippet that reproduces the problem (on linux)
#!/usr/bin/env ruby
`dd if=/dev/urandom of=output.dat bs=1M count=10`
`tar cjvf bigTar.tar.bz2 output.dat`
require 'rbzip2'
dc = RBzip2::Decompressor.new(File.new('bigTar.tar.bz2'))
Examples appear to be out of date. Did you mean RBzip2.default_adapter::Decompressor
?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.