diff options
author | sereglond <sereglond@yandex-team.ru> | 2022-02-10 16:47:46 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:46 +0300 |
commit | eb3d925534734c808602b31b38b953677f0a279f (patch) | |
tree | 4222ef8dc375ee9f30b68a004ee42a0845e005b6 /util/memory | |
parent | 4c8065245df3ea26b7757bcb1f8218df287f9148 (diff) | |
download | ydb-eb3d925534734c808602b31b38b953677f0a279f.tar.gz |
Restoring authorship annotation for <sereglond@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/memory')
-rw-r--r-- | util/memory/blob.cpp | 44 | ||||
-rw-r--r-- | util/memory/blob.h | 16 |
2 files changed, 30 insertions, 30 deletions
diff --git a/util/memory/blob.cpp b/util/memory/blob.cpp index 91da5cadca..e794e73b7f 100644 --- a/util/memory/blob.cpp +++ b/util/memory/blob.cpp @@ -209,7 +209,7 @@ static inline TBlob ConstructFromMap(const TMemoryMap& map, ui64 offset, size_t template <class TCounter, class T> static inline TBlob ConstructAsMap(const T& t, EMappingMode mode) { TMemoryMap::EOpenMode openMode = (mode == EMappingMode::Precharged) ? (TMemoryMap::oRdOnly | TMemoryMap::oPrecharge) : TMemoryMap::oRdOnly; - + TMemoryMap map(t, openMode); const ui64 toMap = map.Length(); @@ -301,7 +301,7 @@ TBlob TBlob::FromMemoryMap(const TMemoryMap& map, ui64 offset, size_t length) { } template <class TCounter> -static inline TBlob ReadFromFile(const TFile& file, ui64 offset, size_t length) { +static inline TBlob ReadFromFile(const TFile& file, ui64 offset, size_t length) { using TBase = TDynamicBlobBase<TCounter>; THolder<TBase> base(new (length) TBase); @@ -316,32 +316,32 @@ static inline TBlob ReadFromFile(const TFile& file, ui64 offset, size_t length) } template <class TCounter> -static inline TBlob ConstructFromFileContent(const TFile& file, ui64 offset, ui64 length) { - if (length > Max<size_t>()) { - ythrow yexception() << "can not read whole file(length = " << length << ")"; - } - - return ReadFromFile<TCounter>(file, offset, static_cast<size_t>(length)); +static inline TBlob ConstructFromFileContent(const TFile& file, ui64 offset, ui64 length) { + if (length > Max<size_t>()) { + ythrow yexception() << "can not read whole file(length = " << length << ")"; + } + + return ReadFromFile<TCounter>(file, offset, static_cast<size_t>(length)); } TBlob TBlob::FromFileContentSingleThreaded(const TString& path) { - TFile file(path, RdOnly); - return ConstructFromFileContent<TSimpleCounter>(file, 0, file.GetLength()); -} - + TFile file(path, RdOnly); + return ConstructFromFileContent<TSimpleCounter>(file, 0, file.GetLength()); +} + TBlob TBlob::FromFileContent(const TString& path) { - TFile file(path, RdOnly); - return ConstructFromFileContent<TAtomicCounter>(file, 0, file.GetLength()); -} - + TFile file(path, RdOnly); + return ConstructFromFileContent<TAtomicCounter>(file, 0, file.GetLength()); +} + TBlob TBlob::FromFileContentSingleThreaded(const TFile& file) { - return ConstructFromFileContent<TSimpleCounter>(file, 0, file.GetLength()); -} - + return ConstructFromFileContent<TSimpleCounter>(file, 0, file.GetLength()); +} + TBlob TBlob::FromFileContent(const TFile& file) { - return ConstructFromFileContent<TAtomicCounter>(file, 0, file.GetLength()); -} - + return ConstructFromFileContent<TAtomicCounter>(file, 0, file.GetLength()); +} + TBlob TBlob::FromFileContentSingleThreaded(const TFile& file, ui64 offset, size_t length) { return ConstructFromFileContent<TSimpleCounter>(file, offset, length); } diff --git a/util/memory/blob.h b/util/memory/blob.h index 20c02a68df..597be6d280 100644 --- a/util/memory/blob.h +++ b/util/memory/blob.h @@ -228,16 +228,16 @@ public: /// Creates a precharged blob with a single-threaded (non atomic) refcounter. It maps the file on the path as data. static TBlob PrechargedFromFileSingleThreaded(const TString& path); - + /// Creates a precharged blob with a multi-threaded (atomic) refcounter. It maps the file on the path as data. static TBlob PrechargedFromFile(const TString& path); - + /// Creates a precharged blob with a single-threaded (non atomic) refcounter. It maps the file content as data. static TBlob PrechargedFromFileSingleThreaded(const TFile& file); - + /// Creates a precharged blob with a multi-threaded (atomic) refcounter. It maps the file content as data. static TBlob PrechargedFromFile(const TFile& file); - + /// Creates a locked blob with a single-threaded (non atomic) refcounter. It maps the file on the path as data. static TBlob LockedFromFileSingleThreaded(const TString& path); @@ -264,16 +264,16 @@ public: /// Creates a blob with a single-threaded (non atomic) refcounter. Dynamically allocates memory and copies data from the file on the path using pread(). static TBlob FromFileContentSingleThreaded(const TString& path); - + /// Creates a blob with a multi-threaded (atomic) refcounter. Dynamically allocates memory and copies data from the file on the path using pread(). static TBlob FromFileContent(const TString& path); - + /// Creates a blob with a single-threaded (non atomic) refcounter. Dynamically allocates memory and copies data from the file using pread(). static TBlob FromFileContentSingleThreaded(const TFile& file); - + /// Creates a blob with a multi-threaded (atomic) refcounter. Dynamically allocates memory and copies data from the file using pread(). static TBlob FromFileContent(const TFile& file); - + /// Creates a blob with a single-threaded (non atomic) refcounter. Dynamically allocates memory and copies data from the provided range of the file content using pread(). static TBlob FromFileContentSingleThreaded(const TFile& file, ui64 offset, size_t length); |