aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/archive/directory_models_archive_reader.cpp
diff options
context:
space:
mode:
authorIlnur Khuziev <ilnur.khuziev@yandex.ru>2022-02-10 16:46:14 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:14 +0300
commit60040c91ffe701a84689b2c6310ff845e65cff42 (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /library/cpp/archive/directory_models_archive_reader.cpp
parent736dcd8ca259457a136f2f9f9168c44643914323 (diff)
downloadydb-60040c91ffe701a84689b2c6310ff845e65cff42.tar.gz
Restoring authorship annotation for Ilnur Khuziev <ilnur.khuziev@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/archive/directory_models_archive_reader.cpp')
-rw-r--r--library/cpp/archive/directory_models_archive_reader.cpp64
1 files changed, 32 insertions, 32 deletions
diff --git a/library/cpp/archive/directory_models_archive_reader.cpp b/library/cpp/archive/directory_models_archive_reader.cpp
index 392c99b511..6de9424c7c 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);
+ return BlobByKey_.contains(key) || PathByKey_.contains(key);
+}
+
+namespace {
+ struct TBlobOwningStream : public TMemoryInput {
+ TBlob Blob;
+ TBlobOwningStream(TBlob blob)
+ : TMemoryInput(blob.Data(), blob.Length())
+ , Blob(blob)
+ {}
+ };
}
-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);
}
}