aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/packers
diff options
context:
space:
mode:
authormyltsev <myltsev@yandex-team.ru>2022-02-10 16:46:03 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:03 +0300
commitfc361854fd6ee8d747229b090f0b8018e260d1fb (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /library/cpp/packers
parent9166d66c30c23c9e85a7c88185a068987148d23f (diff)
downloadydb-fc361854fd6ee8d747229b090f0b8018e260d1fb.tar.gz
Restoring authorship annotation for <myltsev@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/packers')
-rw-r--r--library/cpp/packers/region_packer.h14
-rw-r--r--library/cpp/packers/ut/region_packer_ut.cpp60
2 files changed, 37 insertions, 37 deletions
diff --git a/library/cpp/packers/region_packer.h b/library/cpp/packers/region_packer.h
index 0e82475531..2c661cb5bc 100644
--- a/library/cpp/packers/region_packer.h
+++ b/library/cpp/packers/region_packer.h
@@ -1,18 +1,18 @@
#pragma once
-
+
#include "packers.h"
#include <util/generic/array_ref.h>
-
-// Stores an array of PODs in the trie (copying them with memcpy).
-// Byte order and alignment are your problem.
-
+
+// 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:
typedef TArrayRef<TRecord> TRecords;
- void UnpackLeaf(const char* p, TRecords& result) const {
+ void UnpackLeaf(const char* p, TRecords& result) const {
size_t len;
NPackers::TIntegralPacker<size_t>().UnpackLeaf(p, len);
size_t start = NPackers::TIntegralPacker<size_t>().SkipLeaf(p);
@@ -32,7 +32,7 @@ public:
return NPackers::TIntegralPacker<size_t>().MeasureLeaf(len) + len * sizeof(TRecord);
}
- size_t SkipLeaf(const char* p) const {
+ size_t SkipLeaf(const char* p) const {
size_t result = NPackers::TIntegralPacker<size_t>().SkipLeaf(p);
size_t len;
NPackers::TIntegralPacker<size_t>().UnpackLeaf(p, len);
diff --git a/library/cpp/packers/ut/region_packer_ut.cpp b/library/cpp/packers/ut/region_packer_ut.cpp
index 0da6a8b773..0cb08ccf65 100644
--- a/library/cpp/packers/ut/region_packer_ut.cpp
+++ b/library/cpp/packers/ut/region_packer_ut.cpp
@@ -1,40 +1,40 @@
-#include "region_packer.h"
+#include "region_packer.h"
#include <library/cpp/testing/unittest/registar.h>
-
-template <typename TValue>
-void TestPacker() {
- TValue values[] = {1, 2, 3, 42};
+
+template <typename TValue>
+void TestPacker() {
+ TValue values[] = {1, 2, 3, 42};
TString buffer;
-
- TRegionPacker<TValue> p;
-
+
+ TRegionPacker<TValue> p;
+
using TValues = TArrayRef<TValue>;
TValues valueRegion = TValues(values, Y_ARRAY_SIZE(values));
- size_t sz = p.MeasureLeaf(valueRegion);
- UNIT_ASSERT_VALUES_EQUAL(sz, 1 + sizeof(values));
-
- buffer.resize(sz);
- p.PackLeaf(buffer.begin(), valueRegion, sz);
- UNIT_ASSERT_VALUES_EQUAL(buffer[0], 4);
-
+ size_t sz = p.MeasureLeaf(valueRegion);
+ UNIT_ASSERT_VALUES_EQUAL(sz, 1 + sizeof(values));
+
+ buffer.resize(sz);
+ p.PackLeaf(buffer.begin(), valueRegion, sz);
+ UNIT_ASSERT_VALUES_EQUAL(buffer[0], 4);
+
p.UnpackLeaf(buffer.data(), valueRegion);
UNIT_ASSERT_EQUAL(valueRegion.data(), (const TValue*)(buffer.begin() + 1));
UNIT_ASSERT_EQUAL(valueRegion.size(), Y_ARRAY_SIZE(values));
UNIT_ASSERT_EQUAL(0, memcmp(values, valueRegion.data(), sizeof(values)));
-}
-
+}
+
Y_UNIT_TEST_SUITE(RegionPacker) {
Y_UNIT_TEST(Test0) {
- TestPacker<char>();
- TestPacker<signed char>();
- TestPacker<unsigned char>();
- TestPacker<i8>();
- TestPacker<ui8>();
- TestPacker<i16>();
- TestPacker<ui16>();
- TestPacker<i32>();
- TestPacker<ui32>();
- TestPacker<i64>();
- TestPacker<ui64>();
- }
-}
+ TestPacker<char>();
+ TestPacker<signed char>();
+ TestPacker<unsigned char>();
+ TestPacker<i8>();
+ TestPacker<ui8>();
+ TestPacker<i16>();
+ TestPacker<ui16>();
+ TestPacker<i32>();
+ TestPacker<ui32>();
+ TestPacker<i64>();
+ TestPacker<ui64>();
+ }
+}