aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/on_disk/chunks/chunked_helpers.cpp
diff options
context:
space:
mode:
authoryoda <yoda@yandex-team.ru>2022-02-10 16:50:00 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:00 +0300
commit86ac2045bfe9733d3396425a6ecade74c11ac489 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/on_disk/chunks/chunked_helpers.cpp
parentddd64736134d6d92b80a934c8cf8228944ee4236 (diff)
downloadydb-86ac2045bfe9733d3396425a6ecade74c11ac489.tar.gz
Restoring authorship annotation for <yoda@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/on_disk/chunks/chunked_helpers.cpp')
-rw-r--r--library/cpp/on_disk/chunks/chunked_helpers.cpp96
1 files changed, 48 insertions, 48 deletions
diff --git a/library/cpp/on_disk/chunks/chunked_helpers.cpp b/library/cpp/on_disk/chunks/chunked_helpers.cpp
index b3aa5c8234..b7adba2753 100644
--- a/library/cpp/on_disk/chunks/chunked_helpers.cpp
+++ b/library/cpp/on_disk/chunks/chunked_helpers.cpp
@@ -9,59 +9,59 @@ TBlob GetBlock(const TBlob& blob, size_t index) {
size_t begin = (const char*)reader.GetBlock(index) - (const char*)blob.Data();
return blob.SubBlob(begin, begin + reader.GetBlockLen(index));
}
-
-/*************************** TNamedChunkedDataReader ***************************/
-
+
+/*************************** TNamedChunkedDataReader ***************************/
+
static const char* NamedChunkedDataMagic = "NamedChunkedData";
-
+
TNamedChunkedDataReader::TNamedChunkedDataReader(const TBlob& blob)
: TChunkedDataReader(blob)
-{
- if (TChunkedDataReader::GetBlocksCount() < 1)
- throw yexception() << "Too few blocks";
-
- size_t block = TChunkedDataReader::GetBlocksCount() - 1;
- size_t magicLen = strlen(NamedChunkedDataMagic);
- if (GetBlockLen(block) < magicLen || memcmp(GetBlock(block), NamedChunkedDataMagic, magicLen) != 0)
- throw yexception() << "Not a valid named chunked data file";
-
+{
+ if (TChunkedDataReader::GetBlocksCount() < 1)
+ throw yexception() << "Too few blocks";
+
+ size_t block = TChunkedDataReader::GetBlocksCount() - 1;
+ size_t magicLen = strlen(NamedChunkedDataMagic);
+ if (GetBlockLen(block) < magicLen || memcmp(GetBlock(block), NamedChunkedDataMagic, magicLen) != 0)
+ throw yexception() << "Not a valid named chunked data file";
+
TMemoryInput input(static_cast<const char*>(GetBlock(block)) + magicLen, GetBlockLen(block) - magicLen);
- Load(&input, Names);
-
- size_t index = 0;
+ Load(&input, Names);
+
+ size_t index = 0;
for (TVector<TString>::const_iterator it = Names.begin(); it != Names.end(); ++it, ++index) {
- if (!it->empty())
- NameToIndex[*it] = index;
- }
-}
-
-/*************************** TNamedChunkedDataWriter ***************************/
-
+ if (!it->empty())
+ NameToIndex[*it] = index;
+ }
+}
+
+/*************************** TNamedChunkedDataWriter ***************************/
+
TNamedChunkedDataWriter::TNamedChunkedDataWriter(IOutputStream& slave)
- : TChunkedDataWriter(slave)
-{
-}
-
+ : TChunkedDataWriter(slave)
+{
+}
+
TNamedChunkedDataWriter::~TNamedChunkedDataWriter() {
-}
-
-void TNamedChunkedDataWriter::NewBlock() {
- NewBlock("");
-}
-
+}
+
+void TNamedChunkedDataWriter::NewBlock() {
+ NewBlock("");
+}
+
void TNamedChunkedDataWriter::NewBlock(const TString& name) {
- if (!name.empty()) {
- if (NameToIndex.count(name) != 0)
- throw yexception() << "Block name is not unique";
- NameToIndex[name] = Names.size();
- }
- Names.push_back(name);
- TChunkedDataWriter::NewBlock();
-}
-
-void TNamedChunkedDataWriter::WriteFooter() {
- NewBlock("");
- Write(NamedChunkedDataMagic);
- Save(this, Names);
- TChunkedDataWriter::WriteFooter();
-}
+ if (!name.empty()) {
+ if (NameToIndex.count(name) != 0)
+ throw yexception() << "Block name is not unique";
+ NameToIndex[name] = Names.size();
+ }
+ Names.push_back(name);
+ TChunkedDataWriter::NewBlock();
+}
+
+void TNamedChunkedDataWriter::WriteFooter() {
+ NewBlock("");
+ Write(NamedChunkedDataMagic);
+ Save(this, Names);
+ TChunkedDataWriter::WriteFooter();
+}