1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

MCOL-4814 Add a cmake build option to enable LZ4 compression.

This patch adds an option for cmake flags to enable lz4 compression.
This commit is contained in:
Denis Khalikov
2021-07-15 21:40:20 +03:00
parent a5135f11b7
commit fa8dc815a7
6 changed files with 46 additions and 7 deletions

View File

@ -29,7 +29,14 @@ using namespace std;
#include "logger.h"
#include "snappy.h"
#include "hasher.h"
#include "mcsconfig.h"
#ifdef HAVE_LZ4
#include "lz4.h"
#else
// Taken from lz4.h.
#define LZ4_MAX_INPUT_SIZE 0x7E000000 /* 2 113 929 216 bytes */
#define LZ4_COMPRESSBOUND(isize) ((unsigned)(isize) > (unsigned)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16)
#endif
#define IDBCOMP_DLLEXPORT
#include "idbcompress.h"
@ -590,6 +597,7 @@ CompressInterfaceLZ4::CompressInterfaceLZ4(uint32_t numUserPaddingBytes)
int32_t CompressInterfaceLZ4::compress(const char* in, size_t inLen, char* out,
size_t* outLen) const
{
#ifdef HAVE_LZ4
auto compressedLen = LZ4_compress_default(in, out, inLen, *outLen);
if (!compressedLen)
@ -606,11 +614,15 @@ int32_t CompressInterfaceLZ4::compress(const char* in, size_t inLen, char* out,
*outLen = compressedLen;
return ERR_OK;
#else
return ERR_COMPRESS;
#endif
}
int32_t CompressInterfaceLZ4::uncompress(const char* in, size_t inLen,
char* out, size_t* outLen) const
{
#ifdef HAVE_LZ4
auto decompressedLen = LZ4_decompress_safe(in, out, inLen, *outLen);
if (decompressedLen < 0)
@ -629,6 +641,9 @@ int32_t CompressInterfaceLZ4::uncompress(const char* in, size_t inLen,
#endif
return ERR_OK;
#else
return ERR_DECOMPRESS;
#endif
}
size_t CompressInterfaceLZ4::maxCompressedSize(size_t uncompSize) const