Commit 339ce0bf authored by Philip Pronin's avatar Philip Pronin Committed by Facebook Github Bot

ZSTDCodec should properly handle non-shortcut levels

Summary:
Currently only shortcut levels are properly handled, others result in
using level 1.

Reviewed By: yfeldblum

Differential Revision: D4008123

fbshipit-source-id: 37845eeec139007738f99e72ecfb969c6a2e5652
parent fec7b1bc
......@@ -960,7 +960,7 @@ class ZSTDCodec final : public Codec {
const IOBuf* data,
uint64_t uncompressedLength) override;
int level_{1};
int level_;
};
std::unique_ptr<Codec> ZSTDCodec::create(int level, CodecType type) {
......@@ -971,15 +971,20 @@ ZSTDCodec::ZSTDCodec(int level, CodecType type) : Codec(type) {
DCHECK(type == CodecType::ZSTD);
switch (level) {
case COMPRESSION_LEVEL_FASTEST:
level_ = 1;
level = 1;
break;
case COMPRESSION_LEVEL_DEFAULT:
level_ = 1;
level = 1;
break;
case COMPRESSION_LEVEL_BEST:
level_ = 19;
level = 19;
break;
}
if (level < 1 || level > ZSTD_maxCLevel()) {
throw std::invalid_argument(
to<std::string>("ZSTD: invalid level: ", level));
}
level_ = level;
}
bool ZSTDCodec::doNeedsUncompressedLength() const {
......
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