Commit 623cc983 authored by Chip Turner's avatar Chip Turner Committed by facebook-github-bot-4

Update zstd to 0.4.2

Summary: New version.

Reviewed By: cyan

Differential Revision: D2730844

fb-gh-sync-id: 4305bdfba2e8d25eba295bbf3f13a140c0d04a1c
parent 7fc28369
...@@ -939,6 +939,8 @@ class ZSTDCodec final : public Codec { ...@@ -939,6 +939,8 @@ class ZSTDCodec final : public Codec {
std::unique_ptr<IOBuf> doUncompress( std::unique_ptr<IOBuf> doUncompress(
const IOBuf* data, const IOBuf* data,
uint64_t uncompressedLength) override; uint64_t uncompressedLength) override;
int level_{1};
}; };
std::unique_ptr<Codec> ZSTDCodec::create(int level, CodecType type) { std::unique_ptr<Codec> ZSTDCodec::create(int level, CodecType type) {
...@@ -947,6 +949,17 @@ std::unique_ptr<Codec> ZSTDCodec::create(int level, CodecType type) { ...@@ -947,6 +949,17 @@ std::unique_ptr<Codec> ZSTDCodec::create(int level, CodecType type) {
ZSTDCodec::ZSTDCodec(int level, CodecType type) : Codec(type) { ZSTDCodec::ZSTDCodec(int level, CodecType type) : Codec(type) {
DCHECK(type == CodecType::ZSTD_BETA); 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 { bool ZSTDCodec::doNeedsUncompressedLength() const {
...@@ -960,8 +973,11 @@ std::unique_ptr<IOBuf> ZSTDCodec::doCompress(const IOBuf* data) { ...@@ -960,8 +973,11 @@ std::unique_ptr<IOBuf> ZSTDCodec::doCompress(const IOBuf* data) {
CHECK_EQ(out->length(), 0); CHECK_EQ(out->length(), 0);
rc = ZSTD_compress( rc = ZSTD_compress(out->writableTail(),
out->writableTail(), out->capacity(), data->data(), data->length()); out->capacity(),
data->data(),
data->length(),
level_);
if (ZSTD_isError(rc)) { if (ZSTD_isError(rc)) {
throw std::runtime_error(to<std::string>( throw std::runtime_error(to<std::string>(
......
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