Version 1.6.5
Compressors

This section explains how to configure WiredTiger's builtin support for the bzip2 and snappy compression engines.

Using bzip2 compression

To use the builtin support for Julian Seward's bzip2 compression, first check that bzip2 is installed in include and library directories searched by the compiler. Once bzip2 is installed, you can enable bzip2 using the –enable-bzip2 option to configure.

If bzip2 is installed in a location not normally searched by the compiler toolchain, you'll need to modify the CPPFLAGS and LDFLAGS to indicate these locations. For example, with the bzip2 includes and libraries installed in /usr/local/include and /usr/local/lib, you should run configure as follows:

cd build_posix
../configure --enable-bzip2 CPPFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/include"

When opening the WiredTiger database, load the bzip2 shared library as an extension. For example, with the bzip2 library installed in /usr/local/lib, you would use the following extension:

ret = wiredtiger_open(home, NULL,
"create,"
"extensions=[/usr/local/lib/wiredtiger_bzip2.so]", &conn);

Finally, when creating the WiredTiger object, set block_compressor to bzip2:

ret = session->create(session,
"table:mytable",
"block_compressor=bzip2,key_format=S,value_format=S");

If necessary, you can confirm the compressor is working by running the compression part of the test suite:

cd build_posix
python ../test/suite/run.py compress

Review the test output to verify the bzip2 part of the test passes and was not skipped.

Using snappy compression

To use the builtin support for Google's snappy compression, first check that snappy is installed in include and library directories searched by the compiler. Once snappy is installed, you can enable snappy using the –enable-snappy option to configure.

If snappy is installed in a location not normally searched by the compiler toolchain, you'll need to modify the CPPFLAGS and LDFLAGS to indicate these locations. For example, with the snappy includes and libraries installed in /usr/local/include and /usr/local/lib, you should run configure as follows:

cd build_posix
../configure --enable-snappy CPPFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/include"

When opening the WiredTiger database, load the snappy shared library as an extension. For example, with the snappy library installed in /usr/local/lib, you would use the following extension:

ret = wiredtiger_open(home, NULL,
"create,"
"extensions=[/usr/local/lib/wiredtiger_snappy.so]", &conn);

Finally, when creating the WiredTiger object, set block_compressor to snappy:

ret = session->create(session,
"table:mytable",
"block_compressor=snappy,key_format=S,value_format=S");

If necessary, you can confirm the compressor is working by running the compression part of the test suite:

cd build_posix
python ../test/suite/run.py compress

Review the test output to verify the snappy part of the test passes and was not skipped.

Upgrading compression engines

WiredTiger does not store information with file blocks to identify the compression engine used to compressed the block. Applications wanting to upgrade to some future compression engine (without requiring a file dump and re-load), should ensure each compressed block includes enough information to identify the compression engine used, so its compression code can correctly decompress old and new blocks.

Custom compression engines

WiredTiger may be extended by adding custom compression engines; see WT_COMPRESSOR for more information.