diff options
author | Ilnur Khuziev <ilnur.khuziev@yandex.ru> | 2022-02-10 16:46:13 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:13 +0300 |
commit | 736dcd8ca259457a136f2f9f9168c44643914323 (patch) | |
tree | ddd46a036d68bfa83aa11b892f31243ea6b068a1 /library/cpp/archive | |
parent | 9bf2fa2b060c9881d3135c2208c624a1dd546ecc (diff) | |
download | ydb-736dcd8ca259457a136f2f9f9168c44643914323.tar.gz |
Restoring authorship annotation for Ilnur Khuziev <ilnur.khuziev@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/archive')
-rw-r--r-- | library/cpp/archive/directory_models_archive_reader.cpp | 64 | ||||
-rw-r--r-- | library/cpp/archive/directory_models_archive_reader.h | 6 | ||||
-rw-r--r-- | library/cpp/archive/directory_models_archive_reader_ut.cpp | 2 | ||||
-rw-r--r-- | library/cpp/archive/yarchive.cpp | 18 | ||||
-rw-r--r-- | library/cpp/archive/yarchive.h | 6 | ||||
-rw-r--r-- | library/cpp/archive/yarchive_ut.cpp | 2 |
6 files changed, 49 insertions, 49 deletions
diff --git a/library/cpp/archive/directory_models_archive_reader.cpp b/library/cpp/archive/directory_models_archive_reader.cpp index 6de9424c7c..392c99b511 100644 --- a/library/cpp/archive/directory_models_archive_reader.cpp +++ b/library/cpp/archive/directory_models_archive_reader.cpp @@ -9,12 +9,12 @@ #include <util/stream/input.h> #include <util/stream/mem.h> -TDirectoryModelsArchiveReader::TDirectoryModelsArchiveReader(const TString& path, bool lockMemory, bool ownBlobs) +TDirectoryModelsArchiveReader::TDirectoryModelsArchiveReader(const TString& path, bool lockMemory, bool ownBlobs) : Path_(path) { Y_ENSURE(IsDir(path), "directory not found on this path"); - LoadFilesAndSubdirs("", lockMemory, ownBlobs); + LoadFilesAndSubdirs("", lockMemory, ownBlobs); } TDirectoryModelsArchiveReader::~TDirectoryModelsArchiveReader() {} @@ -29,21 +29,21 @@ TString TDirectoryModelsArchiveReader::KeyByIndex(size_t n) const { } bool TDirectoryModelsArchiveReader::Has(const TStringBuf key) const { - return BlobByKey_.contains(key) || PathByKey_.contains(key); -} - -namespace { - struct TBlobOwningStream : public TMemoryInput { - TBlob Blob; - TBlobOwningStream(TBlob blob) - : TMemoryInput(blob.Data(), blob.Length()) - , Blob(blob) - {} - }; + return BlobByKey_.contains(key) || PathByKey_.contains(key); } +namespace { + struct TBlobOwningStream : public TMemoryInput { + TBlob Blob; + TBlobOwningStream(TBlob blob) + : TMemoryInput(blob.Data(), blob.Length()) + , Blob(blob) + {} + }; +} + TAutoPtr<IInputStream> TDirectoryModelsArchiveReader::ObjectByKey(const TStringBuf key) const { - return new TBlobOwningStream(BlobByKey(key)); + return new TBlobOwningStream(BlobByKey(key)); } TBlob TDirectoryModelsArchiveReader::ObjectBlobByKey(const TStringBuf key) const { @@ -51,14 +51,14 @@ TBlob TDirectoryModelsArchiveReader::ObjectBlobByKey(const TStringBuf key) const } TBlob TDirectoryModelsArchiveReader::BlobByKey(const TStringBuf key) const { - Y_ENSURE(Has(key), "key " << key << " not found"); - if (auto ptr = BlobByKey_.FindPtr(key); ptr) { - return *ptr; - } - if (auto ptr = PathByKey_.FindPtr(key); ptr) { - return TBlob::FromFile(*ptr); - } - Y_UNREACHABLE(); + Y_ENSURE(Has(key), "key " << key << " not found"); + if (auto ptr = BlobByKey_.FindPtr(key); ptr) { + return *ptr; + } + if (auto ptr = PathByKey_.FindPtr(key); ptr) { + return TBlob::FromFile(*ptr); + } + Y_UNREACHABLE(); } bool TDirectoryModelsArchiveReader::Compressed() const { @@ -74,18 +74,18 @@ TString TDirectoryModelsArchiveReader::NormalizePath(TString path) const { return path; } -void TDirectoryModelsArchiveReader::LoadFilesAndSubdirs(const TString& subPath, bool lockMemory, bool ownBlobs) { +void TDirectoryModelsArchiveReader::LoadFilesAndSubdirs(const TString& subPath, bool lockMemory, bool ownBlobs) { TFileList fileList; fileList.Fill(JoinFsPaths(Path_, subPath)); const char* file; while ((file = fileList.Next()) != nullptr) { TString key = JoinFsPaths(subPath, TString(file)); - TString fullPath = JoinFsPaths(Path_, key); + TString fullPath = JoinFsPaths(Path_, key); TBlob fileBlob; if (lockMemory) { - fileBlob = TBlob::LockedFromFile(fullPath); + fileBlob = TBlob::LockedFromFile(fullPath); } else { - fileBlob = TBlob::FromFile(fullPath); + fileBlob = TBlob::FromFile(fullPath); } if (key.EndsWith(".archive")) { TArchiveReader reader(fileBlob); @@ -97,11 +97,11 @@ void TDirectoryModelsArchiveReader::LoadFilesAndSubdirs(const TString& subPath, } } else { const TString normalizedPath = NormalizePath(key); - if (lockMemory || ownBlobs) { - BlobByKey_.emplace(normalizedPath, fileBlob); - } else { - PathByKey_.emplace(normalizedPath, RealPath(fullPath)); - } + if (lockMemory || ownBlobs) { + BlobByKey_.emplace(normalizedPath, fileBlob); + } else { + PathByKey_.emplace(normalizedPath, RealPath(fullPath)); + } Recs_.push_back(normalizedPath); } } @@ -110,6 +110,6 @@ void TDirectoryModelsArchiveReader::LoadFilesAndSubdirs(const TString& subPath, dirsList.Fill(JoinFsPaths(Path_, subPath)); const char* dir; while ((dir = dirsList.Next()) != nullptr) { - LoadFilesAndSubdirs(JoinFsPaths(subPath, TString(dir)), lockMemory, ownBlobs); + LoadFilesAndSubdirs(JoinFsPaths(subPath, TString(dir)), lockMemory, ownBlobs); } } diff --git a/library/cpp/archive/directory_models_archive_reader.h b/library/cpp/archive/directory_models_archive_reader.h index d16d6d728d..5d65e76197 100644 --- a/library/cpp/archive/directory_models_archive_reader.h +++ b/library/cpp/archive/directory_models_archive_reader.h @@ -15,7 +15,7 @@ class TBlob; class TDirectoryModelsArchiveReader : public IModelsArchiveReader { public: - TDirectoryModelsArchiveReader(const TString& path, bool lockMemory = false, bool ownBlobs = false); + TDirectoryModelsArchiveReader(const TString& path, bool lockMemory = false, bool ownBlobs = false); virtual ~TDirectoryModelsArchiveReader() override; virtual size_t Count() const noexcept override; @@ -28,11 +28,11 @@ public: private: TString NormalizePath(TString path) const; // in archive path works unix-like path delimiter and leading slash is neccesery - void LoadFilesAndSubdirs(const TString& subPath, bool lockMemory, bool ownBlobs); + void LoadFilesAndSubdirs(const TString& subPath, bool lockMemory, bool ownBlobs); private: TString Path_; - THashMap<TString, TString> PathByKey_; + THashMap<TString, TString> PathByKey_; THashMap<TString, TBlob> BlobByKey_; TVector<TString> Recs_; }; diff --git a/library/cpp/archive/directory_models_archive_reader_ut.cpp b/library/cpp/archive/directory_models_archive_reader_ut.cpp index 09994de9b4..d7d24fce5a 100644 --- a/library/cpp/archive/directory_models_archive_reader_ut.cpp +++ b/library/cpp/archive/directory_models_archive_reader_ut.cpp @@ -1,6 +1,6 @@ #include "directory_models_archive_reader.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #include <util/folder/tempdir.h> #include <util/string/cast.h> diff --git a/library/cpp/archive/yarchive.cpp b/library/cpp/archive/yarchive.cpp index 1becc3e5da..e4ac611ca9 100644 --- a/library/cpp/archive/yarchive.cpp +++ b/library/cpp/archive/yarchive.cpp @@ -153,15 +153,15 @@ public: TransferData(src, &compress); compress.Finish(); } else { - size_t skip_size = ArchiveWriterDefaultDataAlignment - Off_ % ArchiveWriterDefaultDataAlignment; - if (skip_size == ArchiveWriterDefaultDataAlignment) { - skip_size = 0; - } - while(skip_size > 0) { - Out_->Write(char(0)); - Off_ += 1; - skip_size -= 1; - } + size_t skip_size = ArchiveWriterDefaultDataAlignment - Off_ % ArchiveWriterDefaultDataAlignment; + if (skip_size == ArchiveWriterDefaultDataAlignment) { + skip_size = 0; + } + while(skip_size > 0) { + Out_->Write(char(0)); + Off_ += 1; + skip_size -= 1; + } TransferData(src, &out); out.Finish(); } diff --git a/library/cpp/archive/yarchive.h b/library/cpp/archive/yarchive.h index 8120bcb940..bbd84ab071 100644 --- a/library/cpp/archive/yarchive.h +++ b/library/cpp/archive/yarchive.h @@ -11,9 +11,9 @@ class IOutputStream; class TBlob; -//noncompressed data will be stored with default alignment DEVTOOLS-4384 -static constexpr size_t ArchiveWriterDefaultDataAlignment = 16; - +//noncompressed data will be stored with default alignment DEVTOOLS-4384 +static constexpr size_t ArchiveWriterDefaultDataAlignment = 16; + class TArchiveWriter { public: explicit TArchiveWriter(IOutputStream* out, bool compress = true); diff --git a/library/cpp/archive/yarchive_ut.cpp b/library/cpp/archive/yarchive_ut.cpp index 602a1cdbbd..5736504aac 100644 --- a/library/cpp/archive/yarchive_ut.cpp +++ b/library/cpp/archive/yarchive_ut.cpp @@ -1,6 +1,6 @@ #include "yarchive.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #include <util/string/cast.h> #include <util/stream/file.h> |