Commit b82fb4f7 authored by Nick Terrell's avatar Nick Terrell Committed by Facebook Github Bot

Support old LZ4 versions

Summary: D4194834 broke the OSS build.  Ubuntu 14.4 has r114 in its repo, so support it.

Reviewed By: yfeldblum

Differential Revision: D4224129

fbshipit-source-id: c85e95716ee1a08b33455bfe6fc9f7712d226edf
parent 82e1b579
...@@ -259,20 +259,22 @@ std::unique_ptr<IOBuf> LZ4Codec::doCompress(const IOBuf* data) { ...@@ -259,20 +259,22 @@ std::unique_ptr<IOBuf> LZ4Codec::doCompress(const IOBuf* data) {
} }
int n; int n;
auto input = reinterpret_cast<const char*>(data->data());
auto output = reinterpret_cast<char*>(out->writableTail());
const auto inputLength = data->length();
#if LZ4_VERSION_NUMBER >= 10700
if (highCompression_) { if (highCompression_) {
n = LZ4_compress_HC( n = LZ4_compress_HC(input, output, inputLength, out->tailroom(), 0);
reinterpret_cast<const char*>(data->data()),
reinterpret_cast<char*>(out->writableTail()),
data->length(),
out->tailroom(),
0);
} else { } else {
n = LZ4_compress_default( n = LZ4_compress_default(input, output, inputLength, out->tailroom());
reinterpret_cast<const char*>(data->data()),
reinterpret_cast<char*>(out->writableTail()),
data->length(),
out->tailroom());
} }
#else
if (highCompression_) {
n = LZ4_compressHC(input, output, inputLength);
} else {
n = LZ4_compress(input, output, inputLength);
}
#endif
CHECK_GE(n, 0); CHECK_GE(n, 0);
CHECK_LE(n, out->capacity()); CHECK_LE(n, out->capacity());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment