aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/file.cpp
diff options
context:
space:
mode:
authormyltsev <myltsev@yandex-team.ru>2022-02-10 16:46:03 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:03 +0300
commit9166d66c30c23c9e85a7c88185a068987148d23f (patch)
tree421bdcec5755d9e441c485560aab5ab8d74c7475 /util/system/file.cpp
parent8d3a5ed3a188a34167eaee54f1691ce5c9edf2f3 (diff)
downloadydb-9166d66c30c23c9e85a7c88185a068987148d23f.tar.gz
Restoring authorship annotation for <myltsev@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/system/file.cpp')
-rw-r--r--util/system/file.cpp66
1 files changed, 33 insertions, 33 deletions
diff --git a/util/system/file.cpp b/util/system/file.cpp
index 4a261d020c..b468d2cfb4 100644
--- a/util/system/file.cpp
+++ b/util/system/file.cpp
@@ -16,7 +16,7 @@
#include <util/random/random.h>
-#include <util/generic/size_literals.h>
+#include <util/generic/size_literals.h>
#include <util/generic/string.h>
#include <util/generic/ylimits.h>
#include <util/generic/yexception.h>
@@ -932,31 +932,31 @@ public:
return res;
}
- // Maximum amount of bytes to be read via single system call.
- // Some libraries fail when it is greater than max int.
- // Syscalls can cause contention if they operate on very large data blocks.
- static constexpr size_t MaxReadPortion = 1_GB;
-
+ // Maximum amount of bytes to be read via single system call.
+ // Some libraries fail when it is greater than max int.
+ // Syscalls can cause contention if they operate on very large data blocks.
+ static constexpr size_t MaxReadPortion = 1_GB;
+
i32 RawRead(void* bufferIn, size_t numBytes) {
- const size_t toRead = Min(MaxReadPortion, numBytes);
- return Handle_.Read(bufferIn, toRead);
- }
-
- size_t ReadOrFail(void* buf, size_t numBytes) {
- const i32 reallyRead = RawRead(buf, numBytes);
-
- if (reallyRead < 0) {
- ythrow TFileError() << "can not read data from " << FileName_.Quote();
- }
-
- return reallyRead;
- }
-
+ const size_t toRead = Min(MaxReadPortion, numBytes);
+ return Handle_.Read(bufferIn, toRead);
+ }
+
+ size_t ReadOrFail(void* buf, size_t numBytes) {
+ const i32 reallyRead = RawRead(buf, numBytes);
+
+ if (reallyRead < 0) {
+ ythrow TFileError() << "can not read data from " << FileName_.Quote();
+ }
+
+ return reallyRead;
+ }
+
size_t Read(void* bufferIn, size_t numBytes) {
ui8* buf = (ui8*)bufferIn;
while (numBytes) {
- const size_t reallyRead = ReadOrFail(buf, numBytes);
+ const size_t reallyRead = ReadOrFail(buf, numBytes);
if (reallyRead == 0) {
// file exhausted
@@ -976,16 +976,16 @@ public:
}
}
- // Maximum amount of bytes to be written via single system call.
- // Some libraries fail when it is greater than max int.
- // Syscalls can cause contention if they operate on very large data blocks.
- static constexpr size_t MaxWritePortion = 1_GB;
-
+ // Maximum amount of bytes to be written via single system call.
+ // Some libraries fail when it is greater than max int.
+ // Syscalls can cause contention if they operate on very large data blocks.
+ static constexpr size_t MaxWritePortion = 1_GB;
+
void Write(const void* buffer, size_t numBytes) {
const ui8* buf = (const ui8*)buffer;
while (numBytes) {
- const i32 toWrite = (i32)Min(MaxWritePortion, numBytes);
+ const i32 toWrite = (i32)Min(MaxWritePortion, numBytes);
const i32 reallyWritten = Handle_.Write(buf, toWrite);
if (reallyWritten < 0) {
@@ -1001,7 +1001,7 @@ public:
ui8* buf = (ui8*)bufferIn;
while (numBytes) {
- const i32 toRead = (i32)Min(MaxReadPortion, numBytes);
+ const i32 toRead = (i32)Min(MaxReadPortion, numBytes);
const i32 reallyRead = RawPread(buf, toRead, offset);
if (reallyRead < 0) {
@@ -1035,7 +1035,7 @@ public:
const ui8* buf = (const ui8*)buffer;
while (numBytes) {
- const i32 toWrite = (i32)Min(MaxWritePortion, numBytes);
+ const i32 toWrite = (i32)Min(MaxWritePortion, numBytes);
const i32 reallyWritten = Handle_.Pwrite(buf, toWrite, offset);
if (reallyWritten < 0) {
@@ -1175,10 +1175,10 @@ i32 TFile::RawRead(void* buf, size_t len) {
return Impl_->RawRead(buf, len);
}
-size_t TFile::ReadOrFail(void* buf, size_t len) {
- return Impl_->ReadOrFail(buf, len);
-}
-
+size_t TFile::ReadOrFail(void* buf, size_t len) {
+ return Impl_->ReadOrFail(buf, len);
+}
+
void TFile::Load(void* buf, size_t len) {
Impl_->Load(buf, len);
}