aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yson/varint.cpp
diff options
context:
space:
mode:
authormonster <monster@yandex-team.ru>2022-02-10 16:47:19 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:19 +0300
commitdd76ae1f6213d065375ab296699f764faafbe5bd (patch)
tree075a4553d0011d8f92752c0891794febb15912cf /library/cpp/yson/varint.cpp
parentf02a874a7290593efbe4b3aeae69a04b46c1cc86 (diff)
downloadydb-dd76ae1f6213d065375ab296699f764faafbe5bd.tar.gz
Restoring authorship annotation for <monster@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/yson/varint.cpp')
-rw-r--r--library/cpp/yson/varint.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/library/cpp/yson/varint.cpp b/library/cpp/yson/varint.cpp
index d538ee3cff..b962dcede7 100644
--- a/library/cpp/yson/varint.cpp
+++ b/library/cpp/yson/varint.cpp
@@ -1,12 +1,12 @@
#include "varint.h"
-#include "zigzag.h"
-
+#include "zigzag.h"
+
#include <util/generic/yexception.h>
-
+
namespace NYson {
////////////////////////////////////////////////////////////////////////////////
-
+
int WriteVarUInt64(IOutputStream* output, ui64 value) {
bool stop = false;
int bytesWritten = 0;
@@ -19,22 +19,22 @@ namespace NYson {
byte &= 0x7F;
}
output->Write(byte);
- }
+ }
return bytesWritten;
- }
-
+ }
+
int WriteVarInt32(IOutputStream* output, i32 value) {
return WriteVarUInt64(output, static_cast<ui64>(ZigZagEncode32(value)));
}
-
+
int WriteVarInt64(IOutputStream* output, i64 value) {
return WriteVarUInt64(output, static_cast<ui64>(ZigZagEncode64(value)));
}
-
+
int ReadVarUInt64(IInputStream* input, ui64* value) {
size_t count = 0;
ui64 result = 0;
-
+
ui8 byte = 0;
do {
if (7 * count > 8 * sizeof(ui64)) {
@@ -56,16 +56,16 @@ namespace NYson {
int bytesRead = ReadVarUInt64(input, &varInt);
if (varInt > Max<ui32>()) {
ythrow yexception() << "The data is too long to read ui64";
- }
+ }
*value = ZigZagDecode32(static_cast<ui32>(varInt));
return bytesRead;
}
-
+
int ReadVarInt64(IInputStream* input, i64* value) {
ui64 varInt;
int bytesRead = ReadVarUInt64(input, &varInt);
*value = ZigZagDecode64(varInt);
return bytesRead;
- }
-
+ }
+
} // namespace NYson