BZ2

Synopsis

HELP:   Read BZIP2 compressed data
TYPE:   OBJECT
SYNTAX: BZ2(MEMBER='str',BUFSIZ=num,SMLSPC,SKPORG)

Description

The BZIP2 converter can be used to compress or decompress data streams compatible with the BZIP2 utility on UNIX systems.

The result of a compression is a binary block. The result of a decompression can be text, XML, a base encoding or binary data. Record boundaries are lost. Please use delimiters, length fields or fixed length data if records must be exchanged.

There is no header to store meta information about the data, so all metadata is lost.

The compression level of BZIP2 is the block size in units of 100 KiB: level 1 is a 100 KiB block, level 9 a 900 KiB block. BZIP2 has no store mode, so level 1 is the cheapest setting there is.

AUTO is level 6 (600 KiB) and is also what is used if no level is given. A higher level is not slower, it only asks the library for more work memory: about 400 KiB plus eight times the block size, so 5 MiB at level 6 and 7.6 MiB at level 9.

Because this converter compresses a stream, the block size is not limited by the size of the I/O buffer - the library collects across calls until its block is full.

Decompression of concatenated BZIP2 files is also possible. All concatenated files will be decompressed into one file. It is also possible to decompress one specific member of this concatenation by specifying the member index of the file to be decompressed:

   filename/:memberindex
   filename/#memberindex

   test.bz/#3
   test.bz/:2

BZIP2 data is written to ZIP archives as compression mode 12. The BZIP2 header and trailer are replaced by a ZIP local file header. If a BZIP2 file (compression mode 12) is read from a ZIP archive, it is converted to a BZIP2 data stream and can be decompressed with this component.

Arguments