aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/blockcodecs/codecs
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:15 +0300
commit72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch)
treeda2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /library/cpp/blockcodecs/codecs
parent778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff)
downloadydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/blockcodecs/codecs')
-rw-r--r--library/cpp/blockcodecs/codecs/legacy_zstd06/legacy_zstd06.cpp74
1 files changed, 37 insertions, 37 deletions
diff --git a/library/cpp/blockcodecs/codecs/legacy_zstd06/legacy_zstd06.cpp b/library/cpp/blockcodecs/codecs/legacy_zstd06/legacy_zstd06.cpp
index 042f031679..7319008420 100644
--- a/library/cpp/blockcodecs/codecs/legacy_zstd06/legacy_zstd06.cpp
+++ b/library/cpp/blockcodecs/codecs/legacy_zstd06/legacy_zstd06.cpp
@@ -1,58 +1,58 @@
#include <library/cpp/blockcodecs/core/codecs.h>
#include <library/cpp/blockcodecs/core/common.h>
#include <library/cpp/blockcodecs/core/register.h>
-
+
#include <contrib/libs/zstd06/common/zstd.h>
#include <contrib/libs/zstd06/common/zstd_static.h>
-
-using namespace NBlockCodecs;
-
-namespace {
+
+using namespace NBlockCodecs;
+
+namespace {
struct TZStd06Codec: public TAddLengthCodec<TZStd06Codec> {
inline TZStd06Codec(unsigned level)
- : Level(level)
+ : Level(level)
, MyName(TStringBuf("zstd06_") + 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;
- }
-
+ }
+
+ 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 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 {
+ }
+
+ 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);
- }
- }
-
+
+ if (res != dsize) {
+ ythrow TDecompressError(dsize, res);
+ }
+ }
+
TStringBuf Name() const noexcept override {
- return MyName;
- }
-
- const unsigned Level;
+ return MyName;
+ }
+
+ const unsigned Level;
const TString MyName;
- };
-
+ };
+
struct TZStd06Registrar {
TZStd06Registrar() {
for (unsigned i = 1; i <= ZSTD_maxCLevel(); ++i) {
RegisterCodec(MakeHolder<TZStd06Codec>(i));
}
- }
+ }
};
const TZStd06Registrar Registrar{};
-}
+}