diff options
author | eeight <eeight@yandex-team.ru> | 2022-02-10 16:46:19 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:19 +0300 |
commit | bd085aee9b4f7a0bee302ce687964ffb7098f986 (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /library/cpp/codecs/float_huffman.h | |
parent | 475c0a46f28166e83fd263badc7546377cddcabe (diff) | |
download | ydb-bd085aee9b4f7a0bee302ce687964ffb7098f986.tar.gz |
Restoring authorship annotation for <eeight@yandex-team.ru>. Commit 2 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 0fc1573d8e0..786a8eae1d0 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); } |