From: Chip Turner Date: Tue, 8 Dec 2015 15:52:02 +0000 (-0800) Subject: Update zstd to 0.4.2 X-Git-Tag: deprecate-dynamic-initializer~202 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=623cc983933b9509aa41d36018fb2fa69aa5ceb0;p=folly.git Update zstd to 0.4.2 Summary: New version. Reviewed By: cyan Differential Revision: D2730844 fb-gh-sync-id: 4305bdfba2e8d25eba295bbf3f13a140c0d04a1c --- diff --git a/folly/io/Compression.cpp b/folly/io/Compression.cpp index 53d36c5f..11fb8e3c 100644 --- a/folly/io/Compression.cpp +++ b/folly/io/Compression.cpp @@ -939,6 +939,8 @@ class ZSTDCodec final : public Codec { std::unique_ptr doUncompress( const IOBuf* data, uint64_t uncompressedLength) override; + + int level_{1}; }; std::unique_ptr ZSTDCodec::create(int level, CodecType type) { @@ -947,6 +949,17 @@ std::unique_ptr ZSTDCodec::create(int level, CodecType type) { ZSTDCodec::ZSTDCodec(int level, CodecType type) : Codec(type) { DCHECK(type == CodecType::ZSTD_BETA); + switch (level) { + case COMPRESSION_LEVEL_FASTEST: + level_ = 1; + break; + case COMPRESSION_LEVEL_DEFAULT: + level_ = 1; + break; + case COMPRESSION_LEVEL_BEST: + level_ = 19; + break; + } } bool ZSTDCodec::doNeedsUncompressedLength() const { @@ -960,8 +973,11 @@ std::unique_ptr ZSTDCodec::doCompress(const IOBuf* data) { CHECK_EQ(out->length(), 0); - rc = ZSTD_compress( - out->writableTail(), out->capacity(), data->data(), data->length()); + rc = ZSTD_compress(out->writableTail(), + out->capacity(), + data->data(), + data->length(), + level_); if (ZSTD_isError(rc)) { throw std::runtime_error(to(