aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/blockcodecs/codecs/lzma/lzma.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/lzma/lzma.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/lzma/lzma.cpp')
-rw-r--r--library/cpp/blockcodecs/codecs/lzma/lzma.cpp136
1 files changed, 68 insertions, 68 deletions
diff --git a/library/cpp/blockcodecs/codecs/lzma/lzma.cpp b/library/cpp/blockcodecs/codecs/lzma/lzma.cpp
index eb52842aee..6c8d5fded4 100644
--- a/library/cpp/blockcodecs/codecs/lzma/lzma.cpp
+++ b/library/cpp/blockcodecs/codecs/lzma/lzma.cpp
@@ -1,74 +1,74 @@
#include <library/cpp/blockcodecs/core/codecs.h>
#include <library/cpp/blockcodecs/core/common.h>
#include <library/cpp/blockcodecs/core/register.h>
-
-#include <contrib/libs/lzmasdk/LzmaLib.h>
-
-using namespace NBlockCodecs;
-
-namespace {
- struct TLzmaCodec: public TAddLengthCodec<TLzmaCodec> {
- inline TLzmaCodec(int level)
- : Level(level)
- , MyName("lzma-" + ToString(Level))
- {
- }
-
- static inline size_t DoMaxCompressedLength(size_t in) noexcept {
- return Max<size_t>(in + in / 20, 128) + LZMA_PROPS_SIZE;
- }
-
- TStringBuf Name() const noexcept override {
- return MyName;
- }
-
- inline size_t DoCompress(const TData& in, void* buf) const {
- unsigned char* props = (unsigned char*)buf;
- unsigned char* data = props + LZMA_PROPS_SIZE;
- size_t destLen = Max<size_t>();
- size_t outPropsSize = LZMA_PROPS_SIZE;
-
- const int ret = LzmaCompress(data, &destLen, (const unsigned char*)in.data(), in.size(), props, &outPropsSize, Level, 0, -1, -1, -1, -1, -1);
-
- if (ret != SZ_OK) {
- ythrow TCompressError(ret);
- }
-
- return destLen + LZMA_PROPS_SIZE;
- }
-
- inline void DoDecompress(const TData& in, void* out, size_t len) const {
- if (in.size() <= LZMA_PROPS_SIZE) {
+
+#include <contrib/libs/lzmasdk/LzmaLib.h>
+
+using namespace NBlockCodecs;
+
+namespace {
+ struct TLzmaCodec: public TAddLengthCodec<TLzmaCodec> {
+ inline TLzmaCodec(int level)
+ : Level(level)
+ , MyName("lzma-" + ToString(Level))
+ {
+ }
+
+ static inline size_t DoMaxCompressedLength(size_t in) noexcept {
+ return Max<size_t>(in + in / 20, 128) + LZMA_PROPS_SIZE;
+ }
+
+ TStringBuf Name() const noexcept override {
+ return MyName;
+ }
+
+ inline size_t DoCompress(const TData& in, void* buf) const {
+ unsigned char* props = (unsigned char*)buf;
+ unsigned char* data = props + LZMA_PROPS_SIZE;
+ size_t destLen = Max<size_t>();
+ size_t outPropsSize = LZMA_PROPS_SIZE;
+
+ const int ret = LzmaCompress(data, &destLen, (const unsigned char*)in.data(), in.size(), props, &outPropsSize, Level, 0, -1, -1, -1, -1, -1);
+
+ if (ret != SZ_OK) {
+ ythrow TCompressError(ret);
+ }
+
+ return destLen + LZMA_PROPS_SIZE;
+ }
+
+ inline void DoDecompress(const TData& in, void* out, size_t len) const {
+ if (in.size() <= LZMA_PROPS_SIZE) {
ythrow TDataError() << TStringBuf("broken lzma stream");
- }
-
- const unsigned char* props = (const unsigned char*)in.data();
- const unsigned char* data = props + LZMA_PROPS_SIZE;
- size_t destLen = len;
- SizeT srcLen = in.size() - LZMA_PROPS_SIZE;
-
- const int res = LzmaUncompress((unsigned char*)out, &destLen, data, &srcLen, props, LZMA_PROPS_SIZE);
-
- if (res != SZ_OK) {
- ythrow TDecompressError(res);
- }
-
- if (destLen != len) {
- ythrow TDecompressError(len, destLen);
- }
- }
-
- const int Level;
- const TString MyName;
- };
-
- struct TLzmaRegistrar {
- TLzmaRegistrar() {
- for (int i = 0; i < 10; ++i) {
+ }
+
+ const unsigned char* props = (const unsigned char*)in.data();
+ const unsigned char* data = props + LZMA_PROPS_SIZE;
+ size_t destLen = len;
+ SizeT srcLen = in.size() - LZMA_PROPS_SIZE;
+
+ const int res = LzmaUncompress((unsigned char*)out, &destLen, data, &srcLen, props, LZMA_PROPS_SIZE);
+
+ if (res != SZ_OK) {
+ ythrow TDecompressError(res);
+ }
+
+ if (destLen != len) {
+ ythrow TDecompressError(len, destLen);
+ }
+ }
+
+ const int Level;
+ const TString MyName;
+ };
+
+ struct TLzmaRegistrar {
+ TLzmaRegistrar() {
+ for (int i = 0; i < 10; ++i) {
RegisterCodec(MakeHolder<TLzmaCodec>(i));
- }
- RegisterAlias("lzma", "lzma-5");
- }
- };
+ }
+ RegisterAlias("lzma", "lzma-5");
+ }
+ };
const TLzmaRegistrar Registrar{};
-}
+}