diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /library/cpp/streams/zstd/zstd.h | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'library/cpp/streams/zstd/zstd.h')
-rw-r--r-- | library/cpp/streams/zstd/zstd.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/library/cpp/streams/zstd/zstd.h b/library/cpp/streams/zstd/zstd.h new file mode 100644 index 0000000000..667a0494b7 --- /dev/null +++ b/library/cpp/streams/zstd/zstd.h @@ -0,0 +1,53 @@ +#pragma once + +#include <util/generic/ptr.h> +#include <util/stream/input.h> +#include <util/stream/output.h> + +/** + * @addtogroup Streams_Archs + * @{ + */ + +// @brief Stream to compress into zstd archive +class TZstdCompress: public IOutputStream { +public: + /** + @param slave stream to write compressed data to + @param quality, higher quality - slower but better compression. + 0 is default compression (see constant ZSTD_CLEVEL_DEFAULT(3)) + max compression is ZSTD_MAX_CLEVEL (22) + */ + explicit TZstdCompress(IOutputStream* slave, int quality = 0); + ~TZstdCompress() override; +private: + void DoWrite(const void* buffer, size_t size) override; + void DoFlush() override; + void DoFinish() override; + +public: + class TImpl; + THolder<TImpl> Impl_; +}; + +//////////////////////////////////////////////////////////////////////////////// + +// @brief Buffered stream to decompress from zstd archive +class TZstdDecompress: public IInputStream { +public: + /** + @param slave stream to read compressed data from + @param bufferSize approximate size of buffer compressed data is read in + */ + explicit TZstdDecompress(IInputStream* slave, size_t bufferSize = 8 * 1024); + ~TZstdDecompress() override; + +private: + size_t DoRead(void* buffer, size_t size) override; + +private: + class TImpl; + THolder<TImpl> Impl_; +}; + +/** @} */ |