diff options
author | Alexey Bykov <alexei4203@yandex.ru> | 2022-02-10 16:47:16 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:16 +0300 |
commit | 4cadece7a57ab767e762a0bea1995a596aefeb11 (patch) | |
tree | 7649c16cf4b52e994709f6c9e1716c993ca28759 /library/cpp/codecs | |
parent | 143876304996506751ade0b80b3c47f188b9834f (diff) | |
download | ydb-4cadece7a57ab767e762a0bea1995a596aefeb11.tar.gz |
Restoring authorship annotation for Alexey Bykov <alexei4203@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/codecs')
-rw-r--r-- | library/cpp/codecs/codecs.h | 20 | ||||
-rw-r--r-- | library/cpp/codecs/zstd_dict_codec.cpp | 34 | ||||
-rw-r--r-- | library/cpp/codecs/zstd_dict_codec.h | 2 |
3 files changed, 28 insertions, 28 deletions
diff --git a/library/cpp/codecs/codecs.h b/library/cpp/codecs/codecs.h index cc5e72b285..2d8e56253e 100644 --- a/library/cpp/codecs/codecs.h +++ b/library/cpp/codecs/codecs.h @@ -76,11 +76,11 @@ namespace NCodecs { Trained = t; } - bool TryToLearn(ISequenceReader& r) { - Trained = DoTryToLearn(r); - return Trained; - } - + bool TryToLearn(ISequenceReader& r) { + Trained = DoTryToLearn(r); + return Trained; + } + void Learn(ISequenceReader& r) { LearnX(r, 1); } @@ -110,11 +110,11 @@ namespace NCodecs { protected: virtual void DoLearn(ISequenceReader&) = 0; - virtual bool DoTryToLearn(ISequenceReader& r) { - DoLearn(r); - return true; - } - + virtual bool DoTryToLearn(ISequenceReader& r) { + DoLearn(r); + return true; + } + // so the pipeline codec will know to adjust the sample for the subcodecs virtual void DoLearnX(ISequenceReader& r, double /*sampleSizeMultiplier*/) { DoLearn(r); diff --git a/library/cpp/codecs/zstd_dict_codec.cpp b/library/cpp/codecs/zstd_dict_codec.cpp index c42a2879e6..3d15e0a823 100644 --- a/library/cpp/codecs/zstd_dict_codec.cpp +++ b/library/cpp/codecs/zstd_dict_codec.cpp @@ -145,7 +145,7 @@ namespace NCodecs { } } - bool Learn(ISequenceReader& in, bool throwOnError) { + bool Learn(ISequenceReader& in, bool throwOnError) { TBuffer data; TVector<size_t> lens; @@ -168,19 +168,19 @@ namespace NCodecs { if (!lens) { Dict.Reset(); } else { - size_t trainResult = ZDICT_trainFromBuffer_legacy( - Dict.data(), Dict.size(), data.Data(), const_cast<const size_t*>(&lens[0]), lens.size(), params); - if (ZSTD_isError(trainResult)) { - if (!throwOnError) { - return false; - } - CheckSize(trainResult, __LOCATION__); - } - Dict.Resize(trainResult); + size_t trainResult = ZDICT_trainFromBuffer_legacy( + Dict.data(), Dict.size(), data.Data(), const_cast<const size_t*>(&lens[0]), lens.size(), params); + if (ZSTD_isError(trainResult)) { + if (!throwOnError) { + return false; + } + CheckSize(trainResult, __LOCATION__); + } + Dict.Resize(trainResult); Dict.ShrinkToFit(); } InitContexts(); - return true; + return true; } void Save(IOutputStream* out) const { @@ -247,14 +247,14 @@ namespace NCodecs { void TZStdDictCodec::DoLearn(ISequenceReader& in) { Impl = new TImpl(Impl->GetCompressionLevel()); - Impl->Learn(in, true/*throwOnError*/); - } - - bool TZStdDictCodec::DoTryToLearn(ISequenceReader& in) { - Impl = new TImpl(Impl->GetCompressionLevel()); - return Impl->Learn(in, false/*throwOnError*/); + Impl->Learn(in, true/*throwOnError*/); } + bool TZStdDictCodec::DoTryToLearn(ISequenceReader& in) { + Impl = new TImpl(Impl->GetCompressionLevel()); + return Impl->Learn(in, false/*throwOnError*/); + } + void TZStdDictCodec::Save(IOutputStream* out) const { Impl->Save(out); } diff --git a/library/cpp/codecs/zstd_dict_codec.h b/library/cpp/codecs/zstd_dict_codec.h index 59c1ad6c60..f23dcff4d0 100644 --- a/library/cpp/codecs/zstd_dict_codec.h +++ b/library/cpp/codecs/zstd_dict_codec.h @@ -30,7 +30,7 @@ namespace NCodecs { protected: void DoLearn(ISequenceReader& in) override; - bool DoTryToLearn(ISequenceReader& in) final; + bool DoTryToLearn(ISequenceReader& in) final; void Save(IOutputStream* out) const override; void Load(IInputStream* in) override; }; |