15 using namespace folly;
17 using std::unique_ptr;
23 "The buffer growth size to use during IOBuf zlib deflation");
30 CHECK_EQ(stream->avail_out, 0);
33 buf->append(buf->capacity());
35 stream->next_out = buf->writableData();
36 stream->avail_out = buf->length();
41 int deflateHelper(z_stream* stream,
IOBuf* out,
int flush) {
42 if (stream->avail_out == 0) {
47 return deflate(stream, flush);
54 <<
"Attempt to re-initialize compression stream";
60 zlibStream_.zalloc = Z_NULL;
61 zlibStream_.zfree = Z_NULL;
62 zlibStream_.opaque = Z_NULL;
63 zlibStream_.total_in = 0;
64 zlibStream_.next_in = Z_NULL;
65 zlibStream_.avail_in = 0;
66 zlibStream_.avail_out = 0;
67 zlibStream_.next_out = Z_NULL;
69 DCHECK(level_ == Z_DEFAULT_COMPRESSION ||
70 (level_ >= Z_NO_COMPRESSION && level_ <= Z_BEST_COMPRESSION))
71 <<
"Invalid Zlib compression level. level=" << level_;
74 case ZlibCompressionType::GZIP:
75 status_ = deflateInit2(&zlibStream_,
78 static_cast<int32_t>(type),
82 case ZlibCompressionType::DEFLATE:
83 status_ = deflateInit(&zlibStream_, level);
86 DCHECK(
false) <<
"Unsupported zlib compression type.";
90 if (status_ != Z_OK) {
91 LOG(
ERROR) <<
"error initializing zlib stream. r=" << status_;
111 auto bufferLength = FLAGS_zlib_compressor_buffer_growth;
115 for (
auto&
range : *in) {
void init(ZlibCompressionType type, int level)
static std::unique_ptr< IOBuf > create(std::size_t capacity)
std::unique_ptr< folly::IOBuf > compress(const folly::IOBuf *in, bool trailer=true)
—— Concurrent Priority Queue Implementation ——
DEFINE_int64(threadtimeout_ms, 60000,"Idle time before ThreadPoolExecutor threads are joined")
static std::unique_ptr< IOBuf > addOutputBuffer(MutableByteRange &output, uint64_t size)
Gen range(Value begin, Value end)
void prependChain(std::unique_ptr< IOBuf > &&iobuf)
ZlibCompressionType type_
void trimEnd(std::size_t amount)