diff options
author | finder <finder@yandex-team.ru> | 2022-02-10 16:49:24 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:24 +0300 |
commit | abbbaf4075fbaa0ff4ce9faa1188089466a21dbe (patch) | |
tree | 4beaffe75727862ab08110c7ce520dc7aa49ff30 /library/cpp/packers | |
parent | 46f4bc6ab513a0ed1407f9095284a00e20f05adc (diff) | |
download | ydb-abbbaf4075fbaa0ff4ce9faa1188089466a21dbe.tar.gz |
Restoring authorship annotation for <finder@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/packers')
-rw-r--r-- | library/cpp/packers/region_packer.h | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/library/cpp/packers/region_packer.h b/library/cpp/packers/region_packer.h index 2c661cb5bc..682b55db7e 100644 --- a/library/cpp/packers/region_packer.h +++ b/library/cpp/packers/region_packer.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "packers.h" @@ -7,36 +7,36 @@ // Stores an array of PODs in the trie (copying them with memcpy). // Byte order and alignment are your problem. -template <class TRecord> -class TRegionPacker { -public: +template <class TRecord> +class TRegionPacker { +public: typedef TArrayRef<TRecord> TRecords; - + void UnpackLeaf(const char* p, TRecords& result) const { - size_t len; + size_t len; NPackers::TIntegralPacker<size_t>().UnpackLeaf(p, len); size_t start = NPackers::TIntegralPacker<size_t>().SkipLeaf(p); - result = TRecords((TRecord*)(p + start), len); - } - - void PackLeaf(char* buf, const TRecords& data, size_t computedSize) const { + result = TRecords((TRecord*)(p + start), len); + } + + void PackLeaf(char* buf, const TRecords& data, size_t computedSize) const { size_t len = data.size(); - size_t lenChar = len * sizeof(TRecord); - size_t start = computedSize - lenChar; + size_t lenChar = len * sizeof(TRecord); + size_t start = computedSize - lenChar; NPackers::TIntegralPacker<size_t>().PackLeaf(buf, len, NPackers::TIntegralPacker<size_t>().MeasureLeaf(len)); memcpy(buf + start, data.data(), lenChar); - } - - size_t MeasureLeaf(const TRecords& data) const { + } + + size_t MeasureLeaf(const TRecords& data) const { size_t len = data.size(); return NPackers::TIntegralPacker<size_t>().MeasureLeaf(len) + len * sizeof(TRecord); - } - + } + size_t SkipLeaf(const char* p) const { size_t result = NPackers::TIntegralPacker<size_t>().SkipLeaf(p); - size_t len; + size_t len; NPackers::TIntegralPacker<size_t>().UnpackLeaf(p, len); - result += len * sizeof(TRecord); - return result; - } -}; + result += len * sizeof(TRecord); + return result; + } +}; |