diff options
author | dvorkanton <dvorkanton@yandex-team.ru> | 2022-02-10 16:46:04 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:04 +0300 |
commit | ce1ca0f8ad5b8231d32b35629f85bb09beea1bfb (patch) | |
tree | 19b21fdcf9ef01e0c94a15434fb08a4a555a79e9 /library/cpp/blockcodecs/codecs/zstd | |
parent | fc361854fd6ee8d747229b090f0b8018e260d1fb (diff) | |
download | ydb-ce1ca0f8ad5b8231d32b35629f85bb09beea1bfb.tar.gz |
Restoring authorship annotation for <dvorkanton@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/blockcodecs/codecs/zstd')
-rw-r--r-- | library/cpp/blockcodecs/codecs/zstd/ya.make | 26 | ||||
-rw-r--r-- | library/cpp/blockcodecs/codecs/zstd/zstd.cpp | 102 |
2 files changed, 64 insertions, 64 deletions
diff --git a/library/cpp/blockcodecs/codecs/zstd/ya.make b/library/cpp/blockcodecs/codecs/zstd/ya.make index c077dd47b7..67435b71b2 100644 --- a/library/cpp/blockcodecs/codecs/zstd/ya.make +++ b/library/cpp/blockcodecs/codecs/zstd/ya.make @@ -1,14 +1,14 @@ -LIBRARY() - -OWNER(pg) - -PEERDIR( - contrib/libs/zstd +LIBRARY() + +OWNER(pg) + +PEERDIR( + contrib/libs/zstd library/cpp/blockcodecs/core -) - -SRCS( - GLOBAL zstd.cpp -) - -END() +) + +SRCS( + GLOBAL zstd.cpp +) + +END() diff --git a/library/cpp/blockcodecs/codecs/zstd/zstd.cpp b/library/cpp/blockcodecs/codecs/zstd/zstd.cpp index 95299b3f6d..158747c52c 100644 --- a/library/cpp/blockcodecs/codecs/zstd/zstd.cpp +++ b/library/cpp/blockcodecs/codecs/zstd/zstd.cpp @@ -1,59 +1,59 @@ #include <library/cpp/blockcodecs/core/codecs.h> #include <library/cpp/blockcodecs/core/common.h> #include <library/cpp/blockcodecs/core/register.h> - -#define ZSTD_STATIC_LINKING_ONLY + +#define ZSTD_STATIC_LINKING_ONLY #include <contrib/libs/zstd/include/zstd.h> - -using namespace NBlockCodecs; - -namespace { - struct TZStd08Codec: public TAddLengthCodec<TZStd08Codec> { - inline TZStd08Codec(unsigned level) - : Level(level) + +using namespace NBlockCodecs; + +namespace { + struct TZStd08Codec: public TAddLengthCodec<TZStd08Codec> { + inline TZStd08Codec(unsigned level) + : Level(level) , MyName(TStringBuf("zstd08_") + ToString(Level)) - { - } - - static inline size_t CheckError(size_t ret, const char* what) { - if (ZSTD_isError(ret)) { + { + } + + static inline size_t CheckError(size_t ret, const char* what) { + if (ZSTD_isError(ret)) { ythrow yexception() << what << TStringBuf(" zstd error: ") << ZSTD_getErrorName(ret); - } - - return ret; - } - - static inline size_t DoMaxCompressedLength(size_t l) noexcept { - return ZSTD_compressBound(l); - } - - inline size_t DoCompress(const TData& in, void* out) const { - return CheckError(ZSTD_compress(out, DoMaxCompressedLength(in.size()), in.data(), in.size(), Level), "compress"); - } - - inline void DoDecompress(const TData& in, void* out, size_t dsize) const { - const size_t res = CheckError(ZSTD_decompress(out, dsize, in.data(), in.size()), "decompress"); - - if (res != dsize) { - ythrow TDecompressError(dsize, res); - } - } - - TStringBuf Name() const noexcept override { - return MyName; - } - - const unsigned Level; - const TString MyName; - }; - - struct TZStd08Registrar { - TZStd08Registrar() { - for (int i = 1; i <= ZSTD_maxCLevel(); ++i) { + } + + return ret; + } + + static inline size_t DoMaxCompressedLength(size_t l) noexcept { + return ZSTD_compressBound(l); + } + + inline size_t DoCompress(const TData& in, void* out) const { + return CheckError(ZSTD_compress(out, DoMaxCompressedLength(in.size()), in.data(), in.size(), Level), "compress"); + } + + inline void DoDecompress(const TData& in, void* out, size_t dsize) const { + const size_t res = CheckError(ZSTD_decompress(out, dsize, in.data(), in.size()), "decompress"); + + if (res != dsize) { + ythrow TDecompressError(dsize, res); + } + } + + TStringBuf Name() const noexcept override { + return MyName; + } + + const unsigned Level; + const TString MyName; + }; + + struct TZStd08Registrar { + TZStd08Registrar() { + for (int i = 1; i <= ZSTD_maxCLevel(); ++i) { RegisterCodec(MakeHolder<TZStd08Codec>(i)); - RegisterAlias("zstd_" + ToString(i), "zstd08_" + ToString(i)); - } - } - }; + RegisterAlias("zstd_" + ToString(i), "zstd08_" + ToString(i)); + } + } + }; const TZStd08Registrar Registrar{}; -} +} |