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

Add zstd streaming interface

Summary:
* Add streaming interface to the `ZstdCodec`
* Implement `ZstdCodec::doCompress()` and `ZstdCodec::doUncompress()` using the streaming interface.
  [fbgs CodecType::ZSTD](https://fburl.com/pr8chg64) and check that no caller requires thread-safety.

Reviewed By: yfeldblum

Differential Revision: D5026558

fbshipit-source-id: 61faa25c71f5aef06ca2d7e0700f43214353c650
parent 74560278
This diff is collapsed.
......@@ -34,6 +34,10 @@
#include <folly/io/IOBufQueue.h>
#include <folly/portability/GTest.h>
#if FOLLY_HAVE_LIBZSTD
#include <zstd.h>
#endif
namespace folly { namespace io { namespace test {
class DataHolder : private boost::noncopyable {
......@@ -1084,6 +1088,31 @@ TEST(CheckCompatibleTest, ZlibIsPrefix) {
EXPECT_THROW_IF_DEBUG(
getAutoUncompressionCodec(std::move(codecs)), std::invalid_argument);
}
#if FOLLY_HAVE_LIBZSTD
TEST(ZstdTest, BackwardCompatible) {
auto codec = getCodec(CodecType::ZSTD);
{
auto const data = IOBuf::wrapBuffer(randomDataHolder.data(size_t(1) << 20));
auto compressed = codec->compress(data.get());
compressed->coalesce();
EXPECT_EQ(
data->length(),
ZSTD_getDecompressedSize(compressed->data(), compressed->length()));
}
{
auto const data =
IOBuf::wrapBuffer(randomDataHolder.data(size_t(100) << 20));
auto compressed = codec->compress(data.get());
compressed->coalesce();
EXPECT_EQ(
data->length(),
ZSTD_getDecompressedSize(compressed->data(), compressed->length()));
}
}
#endif
}}} // namespaces
int main(int argc, char *argv[]) {
......
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