Compress-Bzip2

 view release on metacpan or  search on metacpan

ANNOUNCE  view on Meta::CPAN

  size (100k to 900k).  The 2.x series uses the logical eof rollover
  method described in the bzip2 docs.

What is Bzip2 ?
===============

Bzip2 is a portable lossless data compression library written in ANSI
C.  It offers pretty fast compression and fast decompression.  Bzip2
has very good results, if you want to compress ASCII Documents.

Bzip2 is probably not great for streaming compression.  It fills it's
internal buffer, which depending of parameters is between 100k and
900k in size, before it outputs ANY compressed data.  It works best
compressing an entire document.

Streaming decompression on the other hand, gives a steady torrent of
bytes.

Changes  view on Meta::CPAN

   - bzlib-src/Makefile.PL had a stupid mistake in it that shows up for
     win32 nmake.  I can't test that stuff out.  Plus, got some new
     info from Sisyphus, so tossed my scribble and put in something
     known to work.

   - implemented Compress::Bzip2 1.03 compatibility layer to encompass
     the post-1.00 development thread taken by Marco Carnut and David
     Robins.  Made an effort to include the three .t test files asis.

   - Why?  Cause I found that PerlIO::via::Bzip2, by Arjen Laarhoven,
     is built on the streaming interface of 1.03.  From looking over
     it, I gather it redirects a 1.03 compression/decompression stream
     to/from a file.  It doesn't do the extra bit of fiddling with the
     trailers to make the resultant file usable by the bzip2 commands.
     Additionally, the 1.03 decompress stream doesn't handle the pause
     when an embedded EOF marker is found, which is an issue for files
     larger than the buffer size (900k by default).
     
     So, I figured it would be easy to provide a compatibility layer
     for packages that use 1.03.  By using my stuff, the headers and
     trailers would be automatically taken care of, as would the EOF

README.md  view on Meta::CPAN

This module provides a Compress::Zlib like Perl interface to the bzip2
library.  It uses the low level interface to the bzip2 algorithm, and
reimplements all high level routines.

### What is Bzip2 ?

bzip2 is a portable lossless data compression library written in ANSI C.
It offers pretty fast compression and fast decompression.
bzip2 has very good results, if you want to compress ASCII Documents.

bzip2 is probably not great for streaming compression.  It fills it's
internal buffer, which depending of parameters is between 100k and 900k
in size, before it outputs ANY compressed data.  It works best compressing
an entire document.

Streaming decompression on the other hand, gives a steady torrent of bytes.

### What is Compress::Bzip2 ?

Compress::Bzip2 provided early bzip2 bindings for Perl5 compatible to
the old Compress::Zlib library. See Compress::Raw::Bzip2 for the new API

lib/Compress/Bzip2.pm  view on Meta::CPAN

buffers all data until the buffer is full, then it flushes all the
data out.  Use -blockSize100k to specify the size of the buffer.

Valid settings are 1 through 9, representing a blocking in multiples
of 100k.

Note that each such block has an overhead of leading and trailing
synchronization bytes.  bzip2 recovery uses this information to
pull useable data out of a corrupted file.

A streaming application would probably want to set the blocking low.

=item B<-workFactor>

For bzip object opened for stream deflation or write.

The workFactor setting tells the deflation algorithm how much work
to invest to compensate for repetitive data.

workFactor may be a number from 0 to 250 inclusive.  The default setting
is 30.

lib/Compress/Bzip2.pm  view on Meta::CPAN

=head2 $bz-E<gt>is_write()
=head2 $bz-E<gt>total_in()
=head2 $bz-E<gt>total_out()
=head2 version()

=head1 Compress::Bzip2 1.03 COMPATIBILITY

While the 2.x thread forked off of 1.00, another line of development
came to a head at 1.03.  The 1.03 version worked with bzlib 1.0.2, had
improvements to the error handling, single buffer inflate/deflate, a
streaming interface to inflate/deflate, and a cpan style test suite.

=head2 B<$dest = compress( $string, [$level] )>

Alias to L<memBzip>, this compresses string, using the optional
compression level, 1 through 9, the default being 6.  Returns a string
containing the compressed data.

On error I<undef> is returned.

=head2 B<$dest = decompress($string, [$level])>

lib/Compress/Bzip2.pm  view on Meta::CPAN

buffers all data until the buffer is full, then it flushes all the
data out.  Use -blockSize100k to specify the size of the buffer.

Valid settings are 1 through 9, representing a blocking in multiples
of 100k.

Note that each such block has an overhead of leading and trailing
synchronization bytes.  bzip2 recovery uses this information to
pull useable data out of a corrupted file.

A streaming application would probably want to set the blocking low.

=item B<-workFactor>

The workFactor setting tells the deflation algorithm how much work
to invest to compensate for repetitive data.

workFactor may be a number from 0 to 250 inclusive.  The default setting
is 30.

See the bzip documentation for more information.

lib/Compress/Bzip2.pm  view on Meta::CPAN

F<azemgi@rupert.informatik.uni-stuttgart.de>.

The first I<Compress::Bzip2> module was written by Gawdi Azem
F<azemgi@rupert.informatik.uni-stuttgart.de>.  It provided an
interface to the in memory inflate and deflate routines.

I<Compress::Bzip2> was subsequently passed on to Marco Carnut
F<kiko@tempest.com.br> who shepherded it through to version 1.03, a
set of changes which included upgrades to handle bzlib 1.0.2, and
improvements to the in memory inflate and deflate routines.  The
streaming interface and error information were added by David Robins
F<dbrobins@davidrobins.net>.

Version 2 of I<Compress::Bzip2> is due to Rob Janes, of
arjay@cpan.org.  This release is intended to give an interface
close to that of Compress::Zlib.  It's development forks from 1.00,
not 1.03, so the streaming interface is not the same as that in 1.03,
although apparently compatible as it passes the 1.03 test suite.

Minor subsequent fixes and releases were done by Reini Urban,
rurban@cpan.org.

=head1 MODIFICATION HISTORY

See the Changes file.

2.00 Second public release of I<Compress::Bzip2>.

t/082-stream.t  view on Meta::CPAN

# -*- mode: perl -*-

##
## this is the 03stream.t test from Compress::Bzip2 1.03 with no changes
## (except for comments)
##
## - seems to run a lot slower than the 1.03 test, probably because the add
## routine is now perl, not perlxs.
##

# streaming test

use strict;
use Test::More tests => 208;

use Compress::Bzip2 qw(compress_init decompress_init decompress);

# globals

my $Level = 1;
my @AlNum = ('A'..'Z','a'..'z','0'..'9',' ');



( run in 0.296 second using v1.01-cache-2.11-cpan-4d50c553e7e )