aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/packedtypes
diff options
context:
space:
mode:
authormvel <mvel@yandex-team.ru>2022-02-10 16:45:41 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:41 +0300
commit43f5a35593ebc9f6bcea619bb170394ea7ae468e (patch)
treee98df59de24d2ef7c77baed9f41e4875a2fef972 /library/cpp/packedtypes
parentbd30392c4cc92487950adc375c07adf52da1d592 (diff)
downloadydb-43f5a35593ebc9f6bcea619bb170394ea7ae468e.tar.gz
Restoring authorship annotation for <mvel@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/packedtypes')
-rw-r--r--library/cpp/packedtypes/longs.h62
-rw-r--r--library/cpp/packedtypes/packed.h4
-rw-r--r--library/cpp/packedtypes/packed_ut.cpp108
3 files changed, 87 insertions, 87 deletions
diff --git a/library/cpp/packedtypes/longs.h b/library/cpp/packedtypes/longs.h
index 72a868c3f9..084098d705 100644
--- a/library/cpp/packedtypes/longs.h
+++ b/library/cpp/packedtypes/longs.h
@@ -1,7 +1,7 @@
#pragma once
#include <util/system/defaults.h> // _BIDSCLASS _EXPCLASS
-#include <util/system/yassert.h>
+#include <util/system/yassert.h>
#include <util/system/unaligned_mem.h>
#define PUT_8(x, buf, shift) WriteUnaligned<ui8>((buf)++, (x) >> (shift))
@@ -305,43 +305,43 @@ inline int out_long(const i32& longVal, char* ptrBuf) {
inline int len_long(const i32& longVal) {
return MY_32(longVal);
}
-
-template <typename T, typename C>
-inline const C* Unpack32(T& x, const C* src) {
- int pkLen = 0;
- const char* c = reinterpret_cast<const char*>(src);
+
+template <typename T, typename C>
+inline const C* Unpack32(T& x, const C* src) {
+ int pkLen = 0;
+ const char* c = reinterpret_cast<const char*>(src);
Y_UNUSED(pkLen);
UNPACK_32(x, c, mem_traits, pkLen);
Y_ASSERT(pkLen);
- return reinterpret_cast<const C*>(c);
-}
-
-template <typename T, typename C>
-inline const C* Unpack64(T& x, const C* src) {
- int pkLen = 0;
- const char* c = reinterpret_cast<const char*>(src);
+ return reinterpret_cast<const C*>(c);
+}
+
+template <typename T, typename C>
+inline const C* Unpack64(T& x, const C* src) {
+ int pkLen = 0;
+ const char* c = reinterpret_cast<const char*>(src);
Y_UNUSED(pkLen);
- UNPACK_64(x, c, mem_traits, pkLen);
+ UNPACK_64(x, c, mem_traits, pkLen);
Y_ASSERT(pkLen);
- return reinterpret_cast<const C*>(c);
-}
-
-template <typename T, typename C>
-inline C* Pack32(const T& x, C* dest) {
- int pkLen = 0;
+ return reinterpret_cast<const C*>(c);
+}
+
+template <typename T, typename C>
+inline C* Pack32(const T& x, C* dest) {
+ int pkLen = 0;
Y_UNUSED(pkLen);
- char* c = reinterpret_cast<char*>(dest);
+ char* c = reinterpret_cast<char*>(dest);
PACK_32(x, c, mem_traits, pkLen);
Y_ASSERT(pkLen);
- return reinterpret_cast<C*>(c);
-}
-
-template <typename T, typename C>
-inline C* Pack64(const T& x, C* dest) {
- int pkLen = 0;
+ return reinterpret_cast<C*>(c);
+}
+
+template <typename T, typename C>
+inline C* Pack64(const T& x, C* dest) {
+ int pkLen = 0;
Y_UNUSED(pkLen);
- char* c = reinterpret_cast<char*>(dest);
- PACK_64(x, c, mem_traits, pkLen);
+ char* c = reinterpret_cast<char*>(dest);
+ PACK_64(x, c, mem_traits, pkLen);
Y_ASSERT(pkLen);
- return reinterpret_cast<C*>(c);
-}
+ return reinterpret_cast<C*>(c);
+}
diff --git a/library/cpp/packedtypes/packed.h b/library/cpp/packedtypes/packed.h
index 6628b5642d..88cff26ae2 100644
--- a/library/cpp/packedtypes/packed.h
+++ b/library/cpp/packedtypes/packed.h
@@ -69,7 +69,7 @@ void Y_FORCE_INLINE PackUI32(IOutputStream& out, ui32 v) {
char buf[sizeof(ui32)];
char* bufPtr = buf;
size_t size;
- PACK_28(v, bufPtr, mem_traits, size);
+ PACK_28(v, bufPtr, mem_traits, size);
out.Write(buf, size);
}
@@ -86,7 +86,7 @@ struct TInputStream2Traits<TZCMemoryInput> {
template <class TStream>
void Y_FORCE_INLINE UnPackUI32(TStream& in, ui32& v) {
size_t size;
- UNPACK_28(v, in, TInputStream2Traits<TStream>::TTraits, size);
+ UNPACK_28(v, in, TInputStream2Traits<TStream>::TTraits, size);
(void)size;
}
diff --git a/library/cpp/packedtypes/packed_ut.cpp b/library/cpp/packedtypes/packed_ut.cpp
index 9ddf0fe296..70a22cf9c3 100644
--- a/library/cpp/packedtypes/packed_ut.cpp
+++ b/library/cpp/packedtypes/packed_ut.cpp
@@ -2,51 +2,51 @@
#include <library/cpp/testing/unittest/registar.h>
-#include <util/system/defaults.h>
-#include <util/generic/ylimits.h>
+#include <util/system/defaults.h>
+#include <util/generic/ylimits.h>
#include <util/generic/buffer.h>
#include <util/stream/mem.h>
#include <util/stream/buffer.h>
-namespace NPrivate {
+namespace NPrivate {
#if 0
-static ui64 gSeed = 42;
-
-template<typename T>
-static T PseudoRandom(T max = Max<T>()) {
+static ui64 gSeed = 42;
+
+template<typename T>
+static T PseudoRandom(T max = Max<T>()) {
Y_ASSERT(max != 0);
- // stupid and non-threadsafe, but very predictable chaos generator
- gSeed += 1;
- gSeed *= 419;
- gSeed = gSeed ^ (ui64(max) << 17u);
- return gSeed % max;
-};
+ // stupid and non-threadsafe, but very predictable chaos generator
+ gSeed += 1;
+ gSeed *= 419;
+ gSeed = gSeed ^ (ui64(max) << 17u);
+ return gSeed % max;
+};
#endif
}
-
+
Y_UNIT_TEST_SUITE(TPackedTest) {
void TestPackUi32Sub(ui32 v, const TVector<char>& p) {
TBufferOutput out;
PackUI32(out, v);
const TBuffer& buf = out.Buffer();
- UNIT_ASSERT_VALUES_EQUAL(buf.Size(), p.size());
+ UNIT_ASSERT_VALUES_EQUAL(buf.Size(), p.size());
UNIT_ASSERT(!memcmp(buf.Data(), &p[0], buf.Size()));
{
TBufferInput in(buf);
ui32 v2;
UnPackUI32(in, v2);
- UNIT_ASSERT_VALUES_EQUAL(v, v2);
+ UNIT_ASSERT_VALUES_EQUAL(v, v2);
}
{
TZCMemoryInput in(buf.Data(), buf.Size());
ui32 v2;
UnPackUI32(in, v2);
- UNIT_ASSERT_VALUES_EQUAL(v, v2);
+ UNIT_ASSERT_VALUES_EQUAL(v, v2);
}
}
-
+
Y_UNIT_TEST(TestPackUi32) {
ui32 v;
TVector<char> pv;
@@ -87,44 +87,44 @@ Y_UNIT_TEST_SUITE(TPackedTest) {
#endif
TestPackUi32Sub(v, pv);
}
-
-#if 0
+
+#if 0
Y_UNIT_TEST(ReadWrite32) {
- TBuffer buffer(65536);
-
- char* writePtr = buffer.Data();
+ TBuffer buffer(65536);
+
+ char* writePtr = buffer.Data();
TVector<ui32> correctNumbers;
- for (size_t i = 0; i < 1000; ++i) {
- ui32 randNum = NPrivate::PseudoRandom<ui32>();
- correctNumbers.push_back(randNum);
- writePtr = Pack32(randNum, writePtr);
- }
-
- const char* readPtr = buffer.Data();
- for (size_t i = 0; i < correctNumbers.size(); ++i) {
- ui32 value = 0xCCCCCCCC;
- readPtr = Unpack32(value, readPtr);
- UNIT_ASSERT_VALUES_EQUAL(value, correctNumbers[i]);
- }
- }
-
+ for (size_t i = 0; i < 1000; ++i) {
+ ui32 randNum = NPrivate::PseudoRandom<ui32>();
+ correctNumbers.push_back(randNum);
+ writePtr = Pack32(randNum, writePtr);
+ }
+
+ const char* readPtr = buffer.Data();
+ for (size_t i = 0; i < correctNumbers.size(); ++i) {
+ ui32 value = 0xCCCCCCCC;
+ readPtr = Unpack32(value, readPtr);
+ UNIT_ASSERT_VALUES_EQUAL(value, correctNumbers[i]);
+ }
+ }
+
Y_UNIT_TEST(ReadWrite64) {
- TBuffer buffer(65536);
-
- char* writePtr = buffer.Data();
+ TBuffer buffer(65536);
+
+ char* writePtr = buffer.Data();
TVector<ui64> correctNumbers;
- for (size_t i = 0; i < 1000; ++i) {
- ui64 randNum = NPrivate::PseudoRandom<ui64>();
- correctNumbers.push_back(randNum);
- writePtr = Pack64(randNum, writePtr);
- }
-
- const char* readPtr = buffer.Data();
- for (size_t i = 0; i < correctNumbers.size(); ++i) {
- ui64 value = 0xDEADBEEF;
- readPtr = Unpack64(value, readPtr);
- UNIT_ASSERT_VALUES_EQUAL(value, correctNumbers[i]);
- }
- }
-#endif
+ for (size_t i = 0; i < 1000; ++i) {
+ ui64 randNum = NPrivate::PseudoRandom<ui64>();
+ correctNumbers.push_back(randNum);
+ writePtr = Pack64(randNum, writePtr);
+ }
+
+ const char* readPtr = buffer.Data();
+ for (size_t i = 0; i < correctNumbers.size(); ++i) {
+ ui64 value = 0xDEADBEEF;
+ readPtr = Unpack64(value, readPtr);
+ UNIT_ASSERT_VALUES_EQUAL(value, correctNumbers[i]);
+ }
+ }
+#endif
};