1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-13 01:00:23 +02:00

Add Zstandard compression support.

Zstandard is a fast lossless compression algorithm targeting real-time compression scenarios at zlib-level and better compression ratios. It's backed by a very fast entropy stage, provided by Huff0 and FSE library.

Zstandard version >= 1.0 is required, which is generally only available on newer distributions.
This commit is contained in:
David Steele
2020-05-04 15:25:27 -04:00
parent 1aaaa94253
commit 47aa765375
37 changed files with 779 additions and 53 deletions

View File

@ -154,7 +154,7 @@ testSuite(CompressType type, const char *decompressCmd)
bufUsedSet(decompressed, bufSize(decompressed));
TEST_ASSIGN(
compressed, testCompress(compressFilter(type, 3), decompressed, bufSize(decompressed), 1024),
compressed, testCompress(compressFilter(type, 3), decompressed, bufSize(decompressed), 32),
"zero data - compress large in/small out buffer");
TEST_RESULT_BOOL(
@ -241,6 +241,45 @@ testRun(void)
#endif // HAVE_LIBLZ4
}
// *****************************************************************************************************************************
if (testBegin("zst"))
{
#ifdef HAVE_LIBZST
// Run standard test suite
testSuite(compressTypeZst, "zstd -dc");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("zstError()");
TEST_RESULT_UINT(zstError(0), 0, "check success");
TEST_ERROR(zstError((size_t)-12), FormatError, "zst error: [-12] Version not supported");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("zstDecompressToLog() and zstCompressToLog()");
ZstCompress *compress = (ZstCompress *)ioFilterDriver(zstCompressNew(14));
compress->inputSame = true;
compress->inputOffset = 49;
compress->flushing = true;
TEST_RESULT_STR_Z(
zstCompressToLog(compress), "{level: 14, inputSame: true, inputOffset: 49, flushing: true}", "format object");
ZstDecompress *decompress = (ZstDecompress *)ioFilterDriver(zstDecompressNew());
decompress->inputSame = true;
decompress->done = true;
decompress->inputOffset = 999;
TEST_RESULT_STR_Z(
zstDecompressToLog(decompress), "{inputSame: true, inputOffset: 999, frameDone false, done: true}",
"format object");
#else
TEST_ERROR(compressTypePresent(compressTypeZst), OptionInvalidValueError, "pgBackRest not compiled with zst support");
#endif // HAVE_LIBZST
}
// Test everything in the helper that is not tested in the individual compression type tests
// *****************************************************************************************************************************
if (testBegin("helper"))
@ -255,7 +294,7 @@ testRun(void)
TEST_TITLE("compressTypePresent()");
TEST_RESULT_VOID(compressTypePresent(compressTypeNone), "type none always present");
TEST_ERROR(compressTypePresent(compressTypeZst), OptionInvalidValueError, "pgBackRest not compiled with zst support");
TEST_ERROR(compressTypePresent(compressTypeXz), OptionInvalidValueError, "pgBackRest not compiled with xz support");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("compressTypeFromName()");