aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/blockcodecs/codecs/zstd/zstd.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/zstd/zstd.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/zstd/zstd.cpp')
-rw-r--r--library/cpp/blockcodecs/codecs/zstd/zstd.cpp102
1 files changed, 51 insertions, 51 deletions
diff --git a/library/cpp/blockcodecs/codecs/zstd/zstd.cpp b/library/cpp/blockcodecs/codecs/zstd/zstd.cpp
index 158747c52c..95299b3f6d 100644
--- a/library/cpp/blockcodecs/codecs/zstd/zstd.cpp
+++ b/library/cpp/blockcodecs/codecs/zstd/zstd.cpp
@@ -1,59 +1,59 @@
#include <library/cpp/blockcodecs/core/codecs.h>
#include <library/cpp/blockcodecs/core/common.h>
#include <library/cpp/blockcodecs/core/register.h>
-
-#define ZSTD_STATIC_LINKING_ONLY
+
+#define ZSTD_STATIC_LINKING_ONLY
#include <contrib/libs/zstd/include/zstd.h>
-
-using namespace NBlockCodecs;
-
-namespace {
- struct TZStd08Codec: public TAddLengthCodec<TZStd08Codec> {
- inline TZStd08Codec(unsigned level)
- : Level(level)
+
+using namespace NBlockCodecs;
+
+namespace {
+ struct TZStd08Codec: public TAddLengthCodec<TZStd08Codec> {
+ inline TZStd08Codec(unsigned level)
+ : Level(level)
, MyName(TStringBuf("zstd08_") + 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;
- }
-
- static inline size_t DoMaxCompressedLength(size_t l) noexcept {
- 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 {
- const size_t res = CheckError(ZSTD_decompress(out, dsize, in.data(), in.size()), "decompress");
-
- if (res != dsize) {
- ythrow TDecompressError(dsize, res);
- }
- }
-
- TStringBuf Name() const noexcept override {
- return MyName;
- }
-
- const unsigned Level;
- const TString MyName;
- };
-
- struct TZStd08Registrar {
- TZStd08Registrar() {
- for (int i = 1; i <= ZSTD_maxCLevel(); ++i) {
+ }
+
+ 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 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 {
+ const size_t res = CheckError(ZSTD_decompress(out, dsize, in.data(), in.size()), "decompress");
+
+ if (res != dsize) {
+ ythrow TDecompressError(dsize, res);
+ }
+ }
+
+ TStringBuf Name() const noexcept override {
+ return MyName;
+ }
+
+ const unsigned Level;
+ const TString MyName;
+ };
+
+ struct TZStd08Registrar {
+ TZStd08Registrar() {
+ for (int i = 1; i <= ZSTD_maxCLevel(); ++i) {
RegisterCodec(MakeHolder<TZStd08Codec>(i));
- RegisterAlias("zstd_" + ToString(i), "zstd08_" + ToString(i));
- }
- }
- };
+ RegisterAlias("zstd_" + ToString(i), "zstd08_" + ToString(i));
+ }
+ }
+ };
const TZStd08Registrar Registrar{};
-}
+}