aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/blockcodecs/codecs/zlib/zlib.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
commitce1ca0f8ad5b8231d32b35629f85bb09beea1bfb (patch)
tree19b21fdcf9ef01e0c94a15434fb08a4a555a79e9 /library/cpp/blockcodecs/codecs/zlib/zlib.cpp
parentfc361854fd6ee8d747229b090f0b8018e260d1fb (diff)
downloadydb-ce1ca0f8ad5b8231d32b35629f85bb09beea1bfb.tar.gz
Restoring authorship annotation for <dvorkanton@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/blockcodecs/codecs/zlib/zlib.cpp')
-rw-r--r--library/cpp/blockcodecs/codecs/zlib/zlib.cpp118
1 files changed, 59 insertions, 59 deletions
diff --git a/library/cpp/blockcodecs/codecs/zlib/zlib.cpp b/library/cpp/blockcodecs/codecs/zlib/zlib.cpp
index cdb556c36d..077751d21b 100644
--- a/library/cpp/blockcodecs/codecs/zlib/zlib.cpp
+++ b/library/cpp/blockcodecs/codecs/zlib/zlib.cpp
@@ -1,64 +1,64 @@
#include <library/cpp/blockcodecs/core/codecs.h>
#include <library/cpp/blockcodecs/core/common.h>
#include <library/cpp/blockcodecs/core/register.h>
-
-#include <contrib/libs/zlib/zlib.h>
-
-using namespace NBlockCodecs;
-
-namespace {
- struct TZLibCodec: public TAddLengthCodec<TZLibCodec> {
- inline TZLibCodec(int level)
- : MyName("zlib-" + ToString(level))
- , Level(level)
- {
- }
-
- static inline size_t DoMaxCompressedLength(size_t in) noexcept {
- return compressBound(in);
- }
-
- TStringBuf Name() const noexcept override {
- return MyName;
- }
-
- inline size_t DoCompress(const TData& in, void* buf) const {
- //TRASH detected
- uLong ret = Max<unsigned int>();
-
- int cres = compress2((Bytef*)buf, &ret, (const Bytef*)in.data(), in.size(), Level);
-
- if (cres != Z_OK) {
- ythrow TCompressError(cres);
- }
-
- return ret;
- }
-
- inline void DoDecompress(const TData& in, void* out, size_t len) const {
- uLong ret = len;
-
- int uncres = uncompress((Bytef*)out, &ret, (const Bytef*)in.data(), in.size());
- if (uncres != Z_OK) {
- ythrow TDecompressError(uncres);
- }
-
- if (ret != len) {
- ythrow TDecompressError(len, ret);
- }
- }
-
- const TString MyName;
- const int Level;
- };
-
- struct TZLibRegistrar {
- TZLibRegistrar() {
- for (int i = 0; i < 10; ++i) {
+
+#include <contrib/libs/zlib/zlib.h>
+
+using namespace NBlockCodecs;
+
+namespace {
+ struct TZLibCodec: public TAddLengthCodec<TZLibCodec> {
+ inline TZLibCodec(int level)
+ : MyName("zlib-" + ToString(level))
+ , Level(level)
+ {
+ }
+
+ static inline size_t DoMaxCompressedLength(size_t in) noexcept {
+ return compressBound(in);
+ }
+
+ TStringBuf Name() const noexcept override {
+ return MyName;
+ }
+
+ inline size_t DoCompress(const TData& in, void* buf) const {
+ //TRASH detected
+ uLong ret = Max<unsigned int>();
+
+ int cres = compress2((Bytef*)buf, &ret, (const Bytef*)in.data(), in.size(), Level);
+
+ if (cres != Z_OK) {
+ ythrow TCompressError(cres);
+ }
+
+ return ret;
+ }
+
+ inline void DoDecompress(const TData& in, void* out, size_t len) const {
+ uLong ret = len;
+
+ int uncres = uncompress((Bytef*)out, &ret, (const Bytef*)in.data(), in.size());
+ if (uncres != Z_OK) {
+ ythrow TDecompressError(uncres);
+ }
+
+ if (ret != len) {
+ ythrow TDecompressError(len, ret);
+ }
+ }
+
+ const TString MyName;
+ const int Level;
+ };
+
+ struct TZLibRegistrar {
+ TZLibRegistrar() {
+ for (int i = 0; i < 10; ++i) {
RegisterCodec(MakeHolder<TZLibCodec>(i));
- }
- RegisterAlias("zlib", "zlib-6");
- }
- };
+ }
+ RegisterAlias("zlib", "zlib-6");
+ }
+ };
const TZLibRegistrar Registrar{};
-}
+}