aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/on_disk/chunks
diff options
context:
space:
mode:
authoryazevnul <yazevnul@yandex-team.ru>2022-02-10 16:46:48 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:48 +0300
commit9abfb1a53b7f7b791444d1378e645d8fad9b06ed (patch)
tree49e222ea1c5804306084bb3ae065bb702625360f /library/cpp/on_disk/chunks
parent8cbc307de0221f84c80c42dcbe07d40727537e2c (diff)
downloadydb-9abfb1a53b7f7b791444d1378e645d8fad9b06ed.tar.gz
Restoring authorship annotation for <yazevnul@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/on_disk/chunks')
-rw-r--r--library/cpp/on_disk/chunks/chunked_helpers.cpp2
-rw-r--r--library/cpp/on_disk/chunks/chunked_helpers.h80
-rw-r--r--library/cpp/on_disk/chunks/chunks_ut.cpp6
-rw-r--r--library/cpp/on_disk/chunks/reader.cpp12
-rw-r--r--library/cpp/on_disk/chunks/writer.cpp6
-rw-r--r--library/cpp/on_disk/chunks/writer.h4
6 files changed, 55 insertions, 55 deletions
diff --git a/library/cpp/on_disk/chunks/chunked_helpers.cpp b/library/cpp/on_disk/chunks/chunked_helpers.cpp
index e0bd21bf7c..b7adba2753 100644
--- a/library/cpp/on_disk/chunks/chunked_helpers.cpp
+++ b/library/cpp/on_disk/chunks/chunked_helpers.cpp
@@ -37,7 +37,7 @@ TNamedChunkedDataReader::TNamedChunkedDataReader(const TBlob& blob)
/*************************** TNamedChunkedDataWriter ***************************/
-TNamedChunkedDataWriter::TNamedChunkedDataWriter(IOutputStream& slave)
+TNamedChunkedDataWriter::TNamedChunkedDataWriter(IOutputStream& slave)
: TChunkedDataWriter(slave)
{
}
diff --git a/library/cpp/on_disk/chunks/chunked_helpers.h b/library/cpp/on_disk/chunks/chunked_helpers.h
index 4b04771c31..5fa96afdca 100644
--- a/library/cpp/on_disk/chunks/chunked_helpers.h
+++ b/library/cpp/on_disk/chunks/chunked_helpers.h
@@ -8,15 +8,15 @@
#include <util/memory/blob.h>
#include <util/stream/buffer.h>
#include <util/stream/mem.h>
-#include <util/system/unaligned_mem.h>
+#include <util/system/unaligned_mem.h>
#include <util/ysaveload.h>
#include "reader.h"
#include "writer.h"
#include <cmath>
-#include <cstddef>
-
+#include <cstddef>
+
template <typename T>
class TYVector {
private:
@@ -25,14 +25,14 @@ private:
public:
TYVector(const TBlob& blob)
- : Size(IntegerCast<ui32>(ReadUnaligned<ui64>(blob.Data())))
+ : Size(IntegerCast<ui32>(ReadUnaligned<ui64>(blob.Data())))
, Data((const T*)((const char*)blob.Data() + sizeof(ui64)))
{
}
void Get(size_t idx, T& t) const {
assert(idx < (size_t)Size);
- t = ReadUnaligned<T>(Data + idx);
+ t = ReadUnaligned<T>(Data + idx);
}
const T& At(size_t idx) const {
@@ -63,7 +63,7 @@ public:
Vector.push_back(value);
}
- void Save(IOutputStream& out) const {
+ void Save(IOutputStream& out) const {
ui64 uSize = (ui64)Vector.size();
out.Write(&uSize, sizeof(uSize));
out.Write(Vector.data(), Vector.size() * sizeof(T));
@@ -172,16 +172,16 @@ protected:
typename TTypeTraits<TValue>::TFuncParam Second() const {
return Value;
}
-
- static TKey GetFirst(const void* self) {
- static constexpr size_t offset = offsetof(TThis, Key);
+
+ static TKey GetFirst(const void* self) {
+ static constexpr size_t offset = offsetof(TThis, Key);
return ReadUnaligned<TKey>(reinterpret_cast<const char*>(self) + offset);
- }
-
- static TValue GetSecond(const void* self) {
- static constexpr size_t offset = offsetof(TThis, Value);
+ }
+
+ static TValue GetSecond(const void* self) {
+ static constexpr size_t offset = offsetof(TThis, Value);
return ReadUnaligned<TValue>(reinterpret_cast<const char*>(self) + offset);
- }
+ }
};
#pragma pack(pop)
@@ -221,10 +221,10 @@ protected:
template <typename TKey>
static ui32 KeyHash(typename TTypeTraits<TKey>::TFuncParam key, ui16 bits) {
- Y_ASSERT(bits < 32);
+ Y_ASSERT(bits < 32);
const ui32 res = ui32(key) & ((ui32(1) << bits) - 1);
- Y_ASSERT(res < (ui32(1) << bits));
+ Y_ASSERT(res < (ui32(1) << bits));
return res;
}
};
@@ -240,7 +240,7 @@ private:
bool IsPlainEnought(ui16 bits) const {
TVector<size_t> counts(1LL << bits, 0);
for (size_t i = 0; i < Data.size(); ++i) {
- size_t& count = counts[KeyHash<TKey>(TKeyValuePair::GetFirst(&Data[i]), bits)];
+ size_t& count = counts[KeyHash<TKey>(TKeyValuePair::GetFirst(&Data[i]), bits)];
++count;
if (count > 2)
return false;
@@ -253,8 +253,8 @@ public:
Data.push_back(TKeyValuePair(key, value));
}
- void Save(IOutputStream& out) const {
- Y_ASSERT(Data.size() < Max<ui32>());
+ void Save(IOutputStream& out) const {
+ Y_ASSERT(Data.size() < Max<ui32>());
WriteBin<ui16>(&out, VERSION_ID);
static const ui32 PAIR_SIZE = sizeof(TKeyValuePair);
@@ -274,7 +274,7 @@ public:
const ui32 nBuckets = ui32(1) << bits;
TData2 data2(nBuckets);
for (size_t i = 0; i < Data.size(); ++i)
- data2[KeyHash<TKey>(TKeyValuePair::GetFirst(&Data[i]), bits)].push_back(Data[i]);
+ data2[KeyHash<TKey>(TKeyValuePair::GetFirst(&Data[i]), bits)].push_back(Data[i]);
typedef TVector<TInterval> TIntervals;
TIntervals intervals(nBuckets);
@@ -288,7 +288,7 @@ public:
for (ui32 i = 0; i < nBuckets; ++i) {
for (size_t j = 0; j < data2[i].size(); ++j)
for (size_t k = j + 1; k < data2[i].size(); ++k)
- if (TKeyValuePair::GetFirst(&data2[i][j]) == TKeyValuePair::GetFirst(&data2[i][k]))
+ if (TKeyValuePair::GetFirst(&data2[i][j]) == TKeyValuePair::GetFirst(&data2[i][k]))
ythrow yexception() << "key clash";
}
#endif
@@ -306,11 +306,11 @@ private:
const char* P;
ui16 GetBits() const {
- return ReadUnaligned<ui16>(P + 6);
+ return ReadUnaligned<ui16>(P + 6);
}
ui32 GetSize() const {
- return ReadUnaligned<ui32>(P + 8);
+ return ReadUnaligned<ui32>(P + 8);
}
const TInterval* GetIntervals() const {
@@ -326,11 +326,11 @@ private:
static_assert(sizeof(T) == 1, "expect sizeof(T) == 1");
P = reinterpret_cast<const char*>(p);
#ifndef NDEBUG
- ui16 version = ReadUnaligned<ui16>(p);
+ ui16 version = ReadUnaligned<ui16>(p);
if (version != VERSION_ID)
ythrow yexception() << "bad version: " << version;
static const ui32 PAIR_SIZE = sizeof(TKeyValuePair);
- const ui32 size = ReadUnaligned<ui32>(p + 2);
+ const ui32 size = ReadUnaligned<ui32>(p + 2);
if (size != PAIR_SIZE)
ythrow yexception() << "bad size " << size << " instead of " << PAIR_SIZE;
#endif
@@ -354,8 +354,8 @@ public:
const TKeyValuePair* pair = GetData() + TInterval::GetOffset(intervalPtr + hash);
const ui32 length = TInterval::GetLength(intervalPtr + hash);
for (ui32 i = 0; i < length; ++i, ++pair) {
- if (TKeyValuePair::GetFirst(pair) == key) {
- *res = TKeyValuePair::GetSecond(pair);
+ if (TKeyValuePair::GetFirst(pair) == key) {
+ *res = TKeyValuePair::GetSecond(pair);
return true;
}
}
@@ -407,8 +407,8 @@ private:
public:
TSingleValue(const TBlob& blob) {
- Y_ASSERT(blob.Length() >= sizeof(T));
- Y_ASSERT(blob.Length() <= sizeof(T) + 16);
+ Y_ASSERT(blob.Length() >= sizeof(T));
+ Y_ASSERT(blob.Length() <= sizeof(T) + 16);
Value = reinterpret_cast<const T*>(blob.Begin());
}
@@ -434,7 +434,7 @@ public:
Value = value;
}
- void Save(IOutputStream& out) const {
+ void Save(IOutputStream& out) const {
out.Write(&Value, sizeof(Value));
}
};
@@ -528,12 +528,12 @@ private:
template <class T>
struct TSaveLoadVectorNonPodElement {
- static inline void Save(IOutputStream* out, const T& t) {
+ static inline void Save(IOutputStream* out, const T& t) {
TSerializer<T>::Save(out, t);
}
- static inline void Load(IInputStream* in, T& t, size_t elementSize) {
- Y_ASSERT(elementSize > 0);
+ static inline void Load(IInputStream* in, T& t, size_t elementSize) {
+ Y_ASSERT(elementSize > 0);
TSerializer<T>::Load(in, t);
}
};
@@ -547,8 +547,8 @@ private:
public:
TVectorTakingIntoAccountThePodType(const TBlob& blob) {
- SizeofOffsets = ReadUnaligned<ui64>(blob.Begin());
- Y_ASSERT(SizeofOffsets > 0);
+ SizeofOffsets = ReadUnaligned<ui64>(blob.Begin());
+ Y_ASSERT(SizeofOffsets > 0);
Offsets = reinterpret_cast<const ui64*>(blob.Begin() + sizeof(ui64));
Data = reinterpret_cast<const char*>(blob.Begin() + sizeof(ui64) + SizeofOffsets * sizeof(ui64));
}
@@ -560,12 +560,12 @@ public:
size_t GetLength(ui64 index) const {
if (index + 1 >= SizeofOffsets)
ythrow yexception() << "bad offset";
- return IntegerCast<size_t>(ReadUnaligned<ui64>(Offsets + index + 1) - ReadUnaligned<ui64>(Offsets + index));
+ return IntegerCast<size_t>(ReadUnaligned<ui64>(Offsets + index + 1) - ReadUnaligned<ui64>(Offsets + index));
}
void Get(ui64 index, T& t) const {
const size_t len = GetLength(index);
- TMemoryInput input(Data + ReadUnaligned<ui64>(Offsets + index), len);
+ TMemoryInput input(Data + ReadUnaligned<ui64>(Offsets + index), len);
TSaveLoadVectorNonPodElement<T>::Load(&input, t, len);
}
@@ -603,7 +603,7 @@ public:
return Offsets.size();
}
- void Save(IOutputStream& out) const {
+ void Save(IOutputStream& out) const {
ui64 sizeofOffsets = Offsets.size() + 1;
out.Write(&sizeofOffsets, sizeof(sizeofOffsets));
out.Write(Offsets.data(), Offsets.size() * sizeof(Offsets[0]));
@@ -656,12 +656,12 @@ struct TGeneralVectorG<TItem, true> {
template <>
struct TSaveLoadVectorNonPodElement<TString> {
- static inline void Save(IOutputStream* out, const TString& s) {
+ static inline void Save(IOutputStream* out, const TString& s) {
out->Write(s.data(), s.size() + 1);
}
static inline void Load(TMemoryInput* in, TString& s, size_t elementSize) {
- Y_ASSERT(elementSize > 0 && in->Avail() >= elementSize);
+ Y_ASSERT(elementSize > 0 && in->Avail() >= elementSize);
s.assign(in->Buf(), elementSize - 1); /// excluding 0 at the end
}
};
diff --git a/library/cpp/on_disk/chunks/chunks_ut.cpp b/library/cpp/on_disk/chunks/chunks_ut.cpp
index 2be71e9108..f727647f7f 100644
--- a/library/cpp/on_disk/chunks/chunks_ut.cpp
+++ b/library/cpp/on_disk/chunks/chunks_ut.cpp
@@ -20,13 +20,13 @@ struct TPodStruct {
template <>
struct TSaveLoadVectorNonPodElement<TPodStruct> {
typedef TPodStruct TItem;
- static inline void Save(IOutputStream* out, const TItem& item) {
+ static inline void Save(IOutputStream* out, const TItem& item) {
TSerializer<int>::Save(out, item.x);
TSerializer<float>::Save(out, item.y);
}
- static inline void Load(IInputStream* in, TItem& item, size_t elementSize) {
- Y_ASSERT(elementSize == sizeof(TItem));
+ static inline void Load(IInputStream* in, TItem& item, size_t elementSize) {
+ Y_ASSERT(elementSize == sizeof(TItem));
TSerializer<int>::Load(in, item.x);
TSerializer<float>::Load(in, item.y);
}
diff --git a/library/cpp/on_disk/chunks/reader.cpp b/library/cpp/on_disk/chunks/reader.cpp
index c4ba350f11..6e28cbf367 100644
--- a/library/cpp/on_disk/chunks/reader.cpp
+++ b/library/cpp/on_disk/chunks/reader.cpp
@@ -1,6 +1,6 @@
#include <util/generic/cast.h>
#include <util/memory/blob.h>
-#include <util/system/unaligned_mem.h>
+#include <util/system/unaligned_mem.h>
#include "reader.h"
@@ -8,7 +8,7 @@ template <typename T>
static inline void ReadAux(const char* data, T* aux, T count, TVector<const char*>* result) {
result->resize(count);
for (size_t i = 0; i < count; ++i) {
- (*result)[i] = data + ReadUnaligned<T>(aux + i);
+ (*result)[i] = data + ReadUnaligned<T>(aux + i);
}
}
@@ -17,7 +17,7 @@ TChunkedDataReader::TChunkedDataReader(const TBlob& blob) {
const size_t size = blob.Size();
Y_ENSURE(size >= sizeof(ui32), "Empty file with chunks. ");
- ui32 last = ReadUnaligned<ui32>((ui32*)(cdata + size) - 1);
+ ui32 last = ReadUnaligned<ui32>((ui32*)(cdata + size) - 1);
if (last != 0) { // old version file
ui32* aux = (ui32*)(cdata + size);
@@ -32,10 +32,10 @@ TChunkedDataReader::TChunkedDataReader(const TBlob& blob) {
Y_ENSURE(size >= 3 * sizeof(ui64), "Blob size must be >= 3 * sizeof(ui64). ");
ui64* aux = (ui64*)(cdata + size);
- Version = ReadUnaligned<ui64>(aux - 2);
+ Version = ReadUnaligned<ui64>(aux - 2);
Y_ENSURE(Version > 0, "Invalid chunked array version. ");
- ui64 count = ReadUnaligned<ui64>(aux - 3);
+ ui64 count = ReadUnaligned<ui64>(aux - 3);
aux -= (count + 3);
ReadAux<ui64>(cdata, aux, count, &Offsets);
@@ -43,7 +43,7 @@ TChunkedDataReader::TChunkedDataReader(const TBlob& blob) {
aux -= count;
Lengths.resize(count);
for (size_t i = 0; i < count; ++i) {
- Lengths[i] = IntegerCast<size_t>(ReadUnaligned<ui64>(aux + i));
+ Lengths[i] = IntegerCast<size_t>(ReadUnaligned<ui64>(aux + i));
}
}
diff --git a/library/cpp/on_disk/chunks/writer.cpp b/library/cpp/on_disk/chunks/writer.cpp
index c605f1e79e..6dc7397f09 100644
--- a/library/cpp/on_disk/chunks/writer.cpp
+++ b/library/cpp/on_disk/chunks/writer.cpp
@@ -8,7 +8,7 @@ static inline void WriteAux(IOutputStream* out, const TVector<ui64>& data) {
/*************************** TBuffersWriter ***************************/
-TChunkedDataWriter::TChunkedDataWriter(IOutputStream& slave)
+TChunkedDataWriter::TChunkedDataWriter(IOutputStream& slave)
: Slave(slave)
, Offset(0)
{
@@ -36,8 +36,8 @@ void TChunkedDataWriter::WriteFooter() {
}
size_t TChunkedDataWriter::GetCurrentBlockOffset() const {
- Y_ASSERT(!Offsets.empty());
- Y_ASSERT(Offset >= Offsets.back());
+ Y_ASSERT(!Offsets.empty());
+ Y_ASSERT(Offset >= Offsets.back());
return Offset - Offsets.back();
}
diff --git a/library/cpp/on_disk/chunks/writer.h b/library/cpp/on_disk/chunks/writer.h
index aace042949..ab14522bdd 100644
--- a/library/cpp/on_disk/chunks/writer.h
+++ b/library/cpp/on_disk/chunks/writer.h
@@ -4,11 +4,11 @@
#include <util/stream/output.h>
template <typename T>
-inline void WriteBin(IOutputStream* out, typename TTypeTraits<T>::TFuncParam t) {
+inline void WriteBin(IOutputStream* out, typename TTypeTraits<T>::TFuncParam t) {
out->Write(&t, sizeof(T));
}
-class TChunkedDataWriter: public IOutputStream {
+class TChunkedDataWriter: public IOutputStream {
public:
TChunkedDataWriter(IOutputStream& slave);
~TChunkedDataWriter() override;