All Projects → koraktor → rbzip2

koraktor / rbzip2

Licence: BSD-3-Clause license
bzip2 for Ruby

Programming Languages

ruby
36898 projects - #4 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to rbzip2

pyrus-cramjam
Thin Python wrapper to de/compression algorithms in Rust - lightweight & no dependencies
Stars: ✭ 40 (+2.56%)
Mutual labels:  compression, bzip2, decompression
Compressonator
Tool suite for Texture and 3D Model Compression, Optimization and Analysis using CPUs, GPUs and APUs
Stars: ✭ 785 (+1912.82%)
Mutual labels:  compression, decompression
Fflate
High performance (de)compression in an 8kB package
Stars: ✭ 547 (+1302.56%)
Mutual labels:  compression, decompression
Libmspack
A library for some loosely related Microsoft compression formats, CAB, CHM, HLP, LIT, KWAJ and SZDD.
Stars: ✭ 104 (+166.67%)
Mutual labels:  compression, decompression
Xz
Pure golang package for reading and writing xz-compressed files
Stars: ✭ 330 (+746.15%)
Mutual labels:  compression, decompression
Rust Brotli
Brotli compressor and decompressor written in rust that optionally avoids the stdlib
Stars: ✭ 504 (+1192.31%)
Mutual labels:  compression, decompression
zstd-rs
zstd-decoder in pure rust
Stars: ✭ 148 (+279.49%)
Mutual labels:  compression, decompression
EasyCompressor
⚡ A compression library that implements many compression algorithms such as LZ4, Zstd, LZMA, Snappy, Brotli, GZip, and Deflate. It helps you to improve performance by reducing Memory Usage and Network Traffic for caching.
Stars: ✭ 167 (+328.21%)
Mutual labels:  compression, decompression
Util
A collection of useful utility functions
Stars: ✭ 201 (+415.38%)
Mutual labels:  compression, decompression
power-gzip
POWER9 gzip engine documentation and code samples
Stars: ✭ 16 (-58.97%)
Mutual labels:  compression, decompression
go7z
A native Go 7z archive reader.
Stars: ✭ 46 (+17.95%)
Mutual labels:  compression, bzip2
Compress
Optimized Go Compression Packages
Stars: ✭ 2,478 (+6253.85%)
Mutual labels:  compression, decompression
decompress
Pure OCaml implementation of Zlib.
Stars: ✭ 103 (+164.1%)
Mutual labels:  compression, decompression
Lepton
Lepton is a tool and file format for losslessly compressing JPEGs by an average of 22%.
Stars: ✭ 4,918 (+12510.26%)
Mutual labels:  compression, decompression
huffman-coding
A C++ compression and decompression program based on Huffman Coding.
Stars: ✭ 31 (-20.51%)
Mutual labels:  compression, decompression
Numcompress
Python package to compress numerical series & numpy arrays into strings
Stars: ✭ 68 (+74.36%)
Mutual labels:  compression, decompression
Huffman-Coding
A C++ compression program based on Huffman's lossless compression algorithm and decoder.
Stars: ✭ 81 (+107.69%)
Mutual labels:  compression, decompression
bzip2-rs
Pure Rust bzip2 decoder
Stars: ✭ 28 (-28.21%)
Mutual labels:  compression, bzip2
Sdefl
Small inflate/deflate implementation in ~300 LoC of ANSI C
Stars: ✭ 120 (+207.69%)
Mutual labels:  compression, decompression
Minlzma
The Minimal LZMA (minlzma) project aims to provide a minimalistic, cross-platform, highly commented, standards-compliant C library (minlzlib) for decompressing LZMA2-encapsulated compressed data in LZMA format within an XZ container, as can be generated with Python 3.6, 7-zip, and xzutils
Stars: ✭ 236 (+505.13%)
Mutual labels:  compression, decompression

RBzip2

RBzip2 is a gem providing various implementations of the bzip2 algorithm used for compression and decompression. Currently, it includes a FFI-based implementation and a pure Ruby implementation that's slower but works on any Ruby VM. Additionally, there's a JRuby specific implementation that's based on Commons Compress.

The pure Ruby implementations is based on the code of the Apache Commons Compress project and adds a straight Ruby-like API. There are no external dependencies like other gems or libraries. Therefore it will run on any Ruby implementation and the respective operating systems supported by those implementations.

The FFI implementation is using libbz2 and provides fast performance on platforms where both libbz2 and FFI are available. It is derived from this Gist by Brian Lopez.

The Java-based implementation can use the Commons Compress Java library if it is available in the classpath.

Features

  • Compression of raw data into bzip2 compressed IOs (like File or StringIO)
  • Decompression of bzip2 compressed IOs (like File or StringIO)

Usage

require 'rbzip2'

Compression

data = some_data
file = File.new 'somefile.bz2'      # open the target file
bz2  = RBzip2.default_adapter::Compressor.new file  # wrap the file into the compressor
bz2.write data                      # write the raw data to the compressor
bz2.close                           # finish compression (important!)

Decompression

file = File.new 'somefile.bz2'        # open a compressed file
bz2  = RBzip2.default_adapter::Decompressor.new file  # wrap the file into the decompressor
data = io.read                        # read data into a string

Future plans

  • Simple decompression of strings
  • Simple creation of compressed files
  • Two-way compressed IO that will (de)compress as you read/write

Installation

To install RBzip2 as a Ruby gem use the following command:

$ gem install rbzip2

To use it as a dependency managed by Bundler add the following to your Gemfile:

gem 'rbzip2'

If you want to use the FFI implementation on any non-JRuby VM, be sure to also install the ffi gem.

Performance

The bzip2-ruby gem is a Ruby binding to libbz2 and offers best performance, but it is only available for MRI < 2.0.0 and Rubinius.

The FFI implementation binds to libbz2 as well and has almost the same performance as bzip2-ruby.

The Java implementation uses a native Java library and is slower by a factor of about 2/10 while compressing/decompressing.

The pure Ruby implementation of RBzip2 is inherently slower than bzip2-ruby. Currently, this is a plain port of Apache Commons' Java code to Ruby and no effort has been made to optimize it. That's why the Ruby implementation of RBzip2 is slower by a factor of about 130/100 while compressing/decompressing (on Ruby 1.9.3). Ruby 1.8.7 is even slower.

License

This code is free software; you can redistribute it and/or modify it under the terms of the new BSD License. A copy of this license can be found in the included LICENSE file.

Credits

  • Sebastian Staudt -- koraktor(at)gmail.com
  • Brian Lopez -- seniorlopez(at)gmail.com

See Also

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].