| PZIP(3) | C LIBRARY FUNCTIONS | PZIP(3) |
|---|
#include <pzip.h>
Pz_t; Pzpart_t; Pzdisc_t; int (*Pzerror_f)(Pz_t*, Pzdisc_t*, int, const char*, ...); int (*Pzcheck_f)(Pz_t*, unsigned char*, Pzdisc_t*);
PZ_VERSION PZ_WINDOW PZ_MAGIC_1 PZ_MAGIC_2 PZ_TEST
PZ_READ PZ_WRITE PZ_FORCE PZ_STAT PZ_STREAM PZ_CRC PZ_DUMP PZ_VERBOSE PZ_TEST_1 PZ_TEST_2 PZ_TEST_3 PZ_TEST_4 SFPZ_VERIFY SFPZ_CRC
Pz_t* pzopen(Pzdisc_t* disc, const char* path, int flags); int pzclose(Pz_t* pz);
int pzdeflate(Pz_t* pz, Sfio_t* out); int pzinflate(Pz_t* pz, Sfio_t* out); int pzgethdr(Pz_t* pz); int pzputhdr(Pz_t* pz, Sfio_t* out);
Pzpart_t* pzgetpart(Pz_t* pz, const char* name); Pzpart_t* pzsetpart(Pz_t* pz, Pzpart_t* part); void pzdump(Pz_t* pz, Sfio_t* out);
int sfdcpzip(Sfio_t* stream, const char* options, int flags);
pzip
is a library of functions that support compression/decompression
of data files of fixed length rows (records) and columns (fields).
Each
pzip
stream represents a file of compressed or decompressed data
that may be decompressed or compressed to an
pzip format performs better than gzip in space/time on data that has many (> 50%) columns that change at a low rate (columns with a low rate of change are low frequency; columns with a high rate of change are high frequency.)
The pzip compress format is itself gzipped using the sfdcgzip() sfio discipline. Decompressed data is reorganized according to the user-specified partition-file (see Pzdisc_t.partition below) before being passed to gzip. Low frequency columns are run-length encoded and high frequency column groups are transposed to column-major order. The gzip tables are flushed, via the sfsync() discipline function, between each column partition group. This has a positive space/time effect on the gzip string match and huffman tables.
pzip format files self-idenfify by encoding partition information in a header.
Pzpart_t defines one partition. The fields are:
Pzdisc_t defines a stream discipline structure to the pzopen() function. The discipline fields are:
disc.errorf = (Pzerror_f)errorf;
A number of bit flags control stream operations. They are set by the flags argument to pzopen(). The flags are:
Pz_t* pzopen(Pzdisc_t* disc, const char* path, int flags);
This function opens a stream on file. It returns a new stream handle on success and NULL on error. disc and flags are described above. If flags contains PZ_READ then pzinflate() may be called to decompress file, otherwise if flags contains PZ_WRITE pzdeflate() may be called to compress file.
int pzclose(Pz_t* pz);This functions close the stream handle pz returned by a previous call to pzopen(). It returns 0 on success and -1 on error. All resources allocated on behalf of the stream are released.
int pzdeflate(Pz_t* pz, Sfio_t* out);This function compresses the entire PZ_WRITE pzip stream pz to the output sfio stream out. It returns 0 on success and -1 on error.
int pzinflate(Pz_t* pz, Sfio_t* out);This function decompresses the entire PZ_READ pzip stream pz to the output sfio stream out. It returns 0 on success and -1 on error.
int pzgethdr(Pz_t* pz);This function reads the header from the PZ_READ pzip stream pz and fills in the appropriate fields in pz. It returns 0 on success and -1 on error.
int pzputhdr(Pz_t* pz, Sfio_t* out);This function writes the header from the PZ_WRITE pzip stream pz to the sfio output stream out. It returns 0 on success and -1 on error.
Pzpart_t* pzgetpart(Pz_t* pz, const char* name);This function returns a partition given its name. 0 is returned if the partition is not found. The default partition name is the empty string ("").
Pzpart_t* pzsetpart(Pz_t* pz, Pzpart_t* part);This function sets the current active partition to part. The previous active partition is returned. The current active partition is initialized to the default parition ("").
void pzdump(Pz_t* pz, Sfio_t* out);This function writes the header header information from the pzip stream pz to the sfio output stream out in partition file format. A file containing this information is suitable for the Pzdisc_t.partition field. It returns 0 on success and -1 on error.
int sfdcpzip(Sfio_t* sp, const char* options, int flags);This function pushes a pzip decompress sfio discipline on the sfio stream sp by calling pzopen() with PZ_READ|PZ_STREAM on sp and setting Pzdisc_t.options to options. Because of the extra information involved, pzip compression is not supported by the discipline. This is better handled by the
| 1998-08-11 | November 07, 2006 |