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/bzip | |
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/bzip')
-rw-r--r-- | library/cpp/blockcodecs/codecs/bzip/bzip.cpp | 114 | ||||
-rw-r--r-- | library/cpp/blockcodecs/codecs/bzip/ya.make | 26 |
2 files changed, 70 insertions, 70 deletions
diff --git a/library/cpp/blockcodecs/codecs/bzip/bzip.cpp b/library/cpp/blockcodecs/codecs/bzip/bzip.cpp index 3a5cfdd0e9..851c1447c3 100644 --- a/library/cpp/blockcodecs/codecs/bzip/bzip.cpp +++ b/library/cpp/blockcodecs/codecs/bzip/bzip.cpp @@ -1,62 +1,62 @@ #include <library/cpp/blockcodecs/core/codecs.h> #include <library/cpp/blockcodecs/core/common.h> #include <library/cpp/blockcodecs/core/register.h> - -#include <contrib/libs/libbz2/bzlib.h> - -using namespace NBlockCodecs; - -namespace { - struct TBZipCodec: public TAddLengthCodec<TBZipCodec> { - inline TBZipCodec(int level) - : Level(level) - , MyName("bzip2-" + ToString(Level)) - { - } - - static inline size_t DoMaxCompressedLength(size_t in) noexcept { - // very strange - return in * 2 + 128; - } - - TStringBuf Name() const noexcept override { - return MyName; - } - - inline size_t DoCompress(const TData& in, void* buf) const { - unsigned int ret = DoMaxCompressedLength(in.size()); - const int res = BZ2_bzBuffToBuffCompress((char*)buf, &ret, (char*)in.data(), in.size(), Level, 0, 0); - if (res != BZ_OK) { - ythrow TCompressError(res); - } - - return ret; - } - - inline void DoDecompress(const TData& in, void* out, size_t len) const { - unsigned int tmp = SafeIntegerCast<unsigned int>(len); - const int res = BZ2_bzBuffToBuffDecompress((char*)out, &tmp, (char*)in.data(), in.size(), 0, 0); - - if (res != BZ_OK) { - ythrow TDecompressError(res); - } - - if (len != tmp) { - ythrow TDecompressError(len, tmp); - } - } - - const int Level; - const TString MyName; - }; - - struct TBZipRegistrar { - TBZipRegistrar() { - for (int i = 1; i < 10; ++i) { + +#include <contrib/libs/libbz2/bzlib.h> + +using namespace NBlockCodecs; + +namespace { + struct TBZipCodec: public TAddLengthCodec<TBZipCodec> { + inline TBZipCodec(int level) + : Level(level) + , MyName("bzip2-" + ToString(Level)) + { + } + + static inline size_t DoMaxCompressedLength(size_t in) noexcept { + // very strange + return in * 2 + 128; + } + + TStringBuf Name() const noexcept override { + return MyName; + } + + inline size_t DoCompress(const TData& in, void* buf) const { + unsigned int ret = DoMaxCompressedLength(in.size()); + const int res = BZ2_bzBuffToBuffCompress((char*)buf, &ret, (char*)in.data(), in.size(), Level, 0, 0); + if (res != BZ_OK) { + ythrow TCompressError(res); + } + + return ret; + } + + inline void DoDecompress(const TData& in, void* out, size_t len) const { + unsigned int tmp = SafeIntegerCast<unsigned int>(len); + const int res = BZ2_bzBuffToBuffDecompress((char*)out, &tmp, (char*)in.data(), in.size(), 0, 0); + + if (res != BZ_OK) { + ythrow TDecompressError(res); + } + + if (len != tmp) { + ythrow TDecompressError(len, tmp); + } + } + + const int Level; + const TString MyName; + }; + + struct TBZipRegistrar { + TBZipRegistrar() { + for (int i = 1; i < 10; ++i) { RegisterCodec(MakeHolder<TBZipCodec>(i)); - } - RegisterAlias("bzip2", "bzip2-6"); - } - }; + } + RegisterAlias("bzip2", "bzip2-6"); + } + }; const TBZipRegistrar Registrar{}; -} +} diff --git a/library/cpp/blockcodecs/codecs/bzip/ya.make b/library/cpp/blockcodecs/codecs/bzip/ya.make index f0a8aefd62..ddf2f7b29f 100644 --- a/library/cpp/blockcodecs/codecs/bzip/ya.make +++ b/library/cpp/blockcodecs/codecs/bzip/ya.make @@ -1,14 +1,14 @@ -LIBRARY() - -OWNER(pg) - -PEERDIR( - contrib/libs/libbz2 +LIBRARY() + +OWNER(pg) + +PEERDIR( + contrib/libs/libbz2 library/cpp/blockcodecs/core -) - -SRCS( - GLOBAL bzip.cpp -) - -END() +) + +SRCS( + GLOBAL bzip.cpp +) + +END() |