diff options
author | eeight <eeight@yandex-team.ru> | 2022-02-10 16:46:18 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:18 +0300 |
commit | 475c0a46f28166e83fd263badc7546377cddcabe (patch) | |
tree | 39c5a49b8aaad78fe390b6f1f2886bdbda40f3e7 /library/cpp/codecs/float_huffman.h | |
parent | a6e0145a095c7bb3770d6e07aee301de5c73f96e (diff) | |
download | ydb-475c0a46f28166e83fd263badc7546377cddcabe.tar.gz |
Restoring authorship annotation for <eeight@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/codecs/float_huffman.h')
-rw-r--r-- | library/cpp/codecs/float_huffman.h | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/library/cpp/codecs/float_huffman.h b/library/cpp/codecs/float_huffman.h index 786a8eae1d..0fc1573d8e 100644 --- a/library/cpp/codecs/float_huffman.h +++ b/library/cpp/codecs/float_huffman.h @@ -1,50 +1,50 @@ #pragma once -#include <util/generic/array_ref.h> +#include <util/generic/array_ref.h> #include <util/generic/vector.h> #include <util/generic/strbuf.h> -#include <array> - -namespace NCodecs::NFloatHuff { - TString Encode(TArrayRef<const float> factors); - - class TDecoder { - public: - explicit TDecoder(TStringBuf data); - - TVector<float> DecodeAll(size_t sizeHint = 0); - - // Returns number of decoded floats. May be fewer than requested if the EOS is found. - size_t Decode(TArrayRef<float> dest); - - // Returns the number of skipped values. - size_t Skip(size_t count); - - bool HasMore() const; - - private: - struct TState { - ui64 Workspace = 0; - int WorkspaceSize = 0; - ui64 Position = 0; - TStringBuf Data; - - ui64 NextBitsUnmasked(int count); // The upper 64 - count bits may be arbitrary - ui64 PeekBits(int count); - void SkipBits(int count); - }; - - void FillDecodeBuffer(); - - TState State; - std::array<float, 128> DecodeBuffer; - // The range of already decompressed numbers inside the DecodeBuffer. - // Always kept non-empty until the EOS is encountered. - float* Begin; - float* End; - bool HitEos = false; - }; - - TVector<float> Decode(TStringBuf data, size_t sizeHint = 0); +#include <array> + +namespace NCodecs::NFloatHuff { + TString Encode(TArrayRef<const float> factors); + + class TDecoder { + public: + explicit TDecoder(TStringBuf data); + + TVector<float> DecodeAll(size_t sizeHint = 0); + + // Returns number of decoded floats. May be fewer than requested if the EOS is found. + size_t Decode(TArrayRef<float> dest); + + // Returns the number of skipped values. + size_t Skip(size_t count); + + bool HasMore() const; + + private: + struct TState { + ui64 Workspace = 0; + int WorkspaceSize = 0; + ui64 Position = 0; + TStringBuf Data; + + ui64 NextBitsUnmasked(int count); // The upper 64 - count bits may be arbitrary + ui64 PeekBits(int count); + void SkipBits(int count); + }; + + void FillDecodeBuffer(); + + TState State; + std::array<float, 128> DecodeBuffer; + // The range of already decompressed numbers inside the DecodeBuffer. + // Always kept non-empty until the EOS is encountered. + float* Begin; + float* End; + bool HitEos = false; + }; + + TVector<float> Decode(TStringBuf data, size_t sizeHint = 0); } |