aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/blockcodecs/codecs/bzip/bzip.cpp
diff options
context:
space:
mode:
authordvorkanton <dvorkanton@yandex-team.ru>2022-02-10 16:46:04 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:04 +0300
commit110a978b66fe6c0916572df51cfead2a9b647174 (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /library/cpp/blockcodecs/codecs/bzip/bzip.cpp
parentce1ca0f8ad5b8231d32b35629f85bb09beea1bfb (diff)
downloadydb-110a978b66fe6c0916572df51cfead2a9b647174.tar.gz
Restoring authorship annotation for <dvorkanton@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/blockcodecs/codecs/bzip/bzip.cpp')
-rw-r--r--library/cpp/blockcodecs/codecs/bzip/bzip.cpp114
1 files changed, 57 insertions, 57 deletions
diff --git a/library/cpp/blockcodecs/codecs/bzip/bzip.cpp b/library/cpp/blockcodecs/codecs/bzip/bzip.cpp
index 851c1447c3..3a5cfdd0e9 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{};
-}
+}