aboutsummaryrefslogtreecommitdiffstats
path: root/util/system
diff options
context:
space:
mode:
authorsankear <sankear@yandex-team.ru>2022-02-10 16:50:10 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:10 +0300
commitaed1c1c7782eb0a0536e5b25bbed950b397e0ac8 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /util/system
parent7377d7b033ffbef85e9bb0bf35091a8e79ed422c (diff)
downloadydb-aed1c1c7782eb0a0536e5b25bbed950b397e0ac8.tar.gz
Restoring authorship annotation for <sankear@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/system')
-rw-r--r--util/system/file.cpp16
-rw-r--r--util/system/file_ut.cpp140
-rw-r--r--util/system/filemap.cpp30
-rw-r--r--util/system/filemap.h8
4 files changed, 97 insertions, 97 deletions
diff --git a/util/system/file.cpp b/util/system/file.cpp
index 0b1b38d668..4a261d020c 100644
--- a/util/system/file.cpp
+++ b/util/system/file.cpp
@@ -937,7 +937,7 @@ public:
// 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) {
+ i32 RawRead(void* bufferIn, size_t numBytes) {
const size_t toRead = Min(MaxReadPortion, numBytes);
return Handle_.Read(bufferIn, toRead);
}
@@ -1002,7 +1002,7 @@ public:
while (numBytes) {
const i32 toRead = (i32)Min(MaxReadPortion, numBytes);
- const i32 reallyRead = RawPread(buf, toRead, offset);
+ const i32 reallyRead = RawPread(buf, toRead, offset);
if (reallyRead < 0) {
ythrow TFileError() << "can not read data from " << FileName_.Quote();
@@ -1021,10 +1021,10 @@ public:
return buf - (ui8*)bufferIn;
}
- i32 RawPread(void* buf, ui32 len, i64 offset) const {
- return Handle_.Pread(buf, len, offset);
- }
-
+ i32 RawPread(void* buf, ui32 len, i64 offset) const {
+ return Handle_.Pread(buf, len, offset);
+ }
+
void Pload(void* buf, size_t len, i64 offset) const {
if (Pread(buf, len, offset) != len) {
ythrow TFileError() << "can't read " << len << " bytes at offset " << offset << " from " << FileName_.Quote();
@@ -1171,8 +1171,8 @@ size_t TFile::Read(void* buf, size_t len) {
return Impl_->Read(buf, len);
}
-i32 TFile::RawRead(void* buf, size_t len) {
- return Impl_->RawRead(buf, len);
+i32 TFile::RawRead(void* buf, size_t len) {
+ return Impl_->RawRead(buf, len);
}
size_t TFile::ReadOrFail(void* buf, size_t len) {
diff --git a/util/system/file_ut.cpp b/util/system/file_ut.cpp
index abdee31d7e..941e6a50f3 100644
--- a/util/system/file_ut.cpp
+++ b/util/system/file_ut.cpp
@@ -19,10 +19,10 @@ class TFileTest: public TTestBase {
UNIT_TEST(TestLocale);
UNIT_TEST(TestFlush);
UNIT_TEST(TestFlushSpecialFile);
- UNIT_TEST(TestRawRead);
- UNIT_TEST(TestRead);
+ UNIT_TEST(TestRawRead);
+ UNIT_TEST(TestRead);
UNIT_TEST(TestRawPread);
- UNIT_TEST(TestPread);
+ UNIT_TEST(TestPread);
UNIT_TEST(TestCache);
UNIT_TEST_SUITE_END();
@@ -33,10 +33,10 @@ public:
void TestLocale();
void TestFlush();
void TestFlushSpecialFile();
- void TestRawRead();
- void TestRead();
+ void TestRawRead();
+ void TestRead();
void TestRawPread();
- void TestPread();
+ void TestPread();
void TestCache();
inline void TestLinkTo() {
@@ -239,48 +239,48 @@ void TFileTest::TestFlushSpecialFile() {
#endif
}
-void TFileTest::TestRawRead() {
- TTempFile tmp("tmp");
-
- {
- TFile file(tmp.Name(), OpenAlways | WrOnly);
- file.Write("1234567", 7);
- file.Flush();
- file.Close();
- }
-
- {
- TFile file(tmp.Name(), OpenExisting | RdOnly);
- char buf[7];
- i32 reallyRead = file.RawRead(buf, 7);
- Y_ENSURE(0 <= reallyRead && reallyRead <= 7);
- Y_ENSURE(TStringBuf(buf, reallyRead) == TStringBuf("1234567").Head(reallyRead));
- }
-}
-
-void TFileTest::TestRead() {
- TTempFile tmp("tmp");
-
- {
- TFile file(tmp.Name(), OpenAlways | WrOnly);
- file.Write("1234567", 7);
- file.Flush();
- file.Close();
- }
-
- {
- TFile file(tmp.Name(), OpenExisting | RdOnly);
- char buf[7];
- Y_ENSURE(file.Read(buf, 7) == 7);
- Y_ENSURE(TStringBuf(buf, 7) == "1234567");
-
- memset(buf, 0, sizeof(buf));
- file.Seek(0, sSet);
- Y_ENSURE(file.Read(buf, 123) == 7);
- Y_ENSURE(TStringBuf(buf, 7) == "1234567");
- }
-}
-
+void TFileTest::TestRawRead() {
+ TTempFile tmp("tmp");
+
+ {
+ TFile file(tmp.Name(), OpenAlways | WrOnly);
+ file.Write("1234567", 7);
+ file.Flush();
+ file.Close();
+ }
+
+ {
+ TFile file(tmp.Name(), OpenExisting | RdOnly);
+ char buf[7];
+ i32 reallyRead = file.RawRead(buf, 7);
+ Y_ENSURE(0 <= reallyRead && reallyRead <= 7);
+ Y_ENSURE(TStringBuf(buf, reallyRead) == TStringBuf("1234567").Head(reallyRead));
+ }
+}
+
+void TFileTest::TestRead() {
+ TTempFile tmp("tmp");
+
+ {
+ TFile file(tmp.Name(), OpenAlways | WrOnly);
+ file.Write("1234567", 7);
+ file.Flush();
+ file.Close();
+ }
+
+ {
+ TFile file(tmp.Name(), OpenExisting | RdOnly);
+ char buf[7];
+ Y_ENSURE(file.Read(buf, 7) == 7);
+ Y_ENSURE(TStringBuf(buf, 7) == "1234567");
+
+ memset(buf, 0, sizeof(buf));
+ file.Seek(0, sSet);
+ Y_ENSURE(file.Read(buf, 123) == 7);
+ Y_ENSURE(TStringBuf(buf, 7) == "1234567");
+ }
+}
+
void TFileTest::TestRawPread() {
TTempFile tmp("tmp");
@@ -305,28 +305,28 @@ void TFileTest::TestRawPread() {
}
}
-void TFileTest::TestPread() {
- TTempFile tmp("tmp");
-
- {
- TFile file(tmp.Name(), OpenAlways | WrOnly);
- file.Write("1234567", 7);
- file.Flush();
- file.Close();
- }
-
- {
- TFile file(tmp.Name(), OpenExisting | RdOnly);
- char buf[7];
- Y_ENSURE(file.Pread(buf, 3, 1) == 3);
- Y_ENSURE(TStringBuf(buf, 3) == "234");
-
- memset(buf, 0, sizeof(buf));
- Y_ENSURE(file.Pread(buf, 2, 5) == 2);
- Y_ENSURE(TStringBuf(buf, 2) == "67");
- }
-}
-
+void TFileTest::TestPread() {
+ TTempFile tmp("tmp");
+
+ {
+ TFile file(tmp.Name(), OpenAlways | WrOnly);
+ file.Write("1234567", 7);
+ file.Flush();
+ file.Close();
+ }
+
+ {
+ TFile file(tmp.Name(), OpenExisting | RdOnly);
+ char buf[7];
+ Y_ENSURE(file.Pread(buf, 3, 1) == 3);
+ Y_ENSURE(TStringBuf(buf, 3) == "234");
+
+ memset(buf, 0, sizeof(buf));
+ Y_ENSURE(file.Pread(buf, 2, 5) == 2);
+ Y_ENSURE(TStringBuf(buf, 2) == "67");
+ }
+}
+
#ifdef _linux_
#include <sys/statfs.h>
#endif
diff --git a/util/system/filemap.cpp b/util/system/filemap.cpp
index dde2baf5fc..7454a4cb94 100644
--- a/util/system/filemap.cpp
+++ b/util/system/filemap.cpp
@@ -337,7 +337,7 @@ private:
TFile File_;
TString DbgName_; // This string is never used to actually open a file, only in exceptions
i64 Length_;
- EOpenMode Mode_;
+ EOpenMode Mode_;
#if defined(_win_)
void* Mapping_;
@@ -347,10 +347,10 @@ private:
};
TMemoryMap::TMemoryMap(const TString& name)
- : Impl_(new TImpl(name, EOpenModeFlag::oRdOnly))
-{
-}
-
+ : Impl_(new TImpl(name, EOpenModeFlag::oRdOnly))
+{
+}
+
TMemoryMap::TMemoryMap(const TString& name, EOpenMode om)
: Impl_(new TImpl(name, om))
{
@@ -363,9 +363,9 @@ TMemoryMap::TMemoryMap(const TString& name, i64 length, EOpenMode om)
TMemoryMap::TMemoryMap(FILE* f, TString dbgName)
: Impl_(new TImpl(f, EOpenModeFlag::oRdOnly, std::move(dbgName)))
-{
-}
-
+{
+}
+
TMemoryMap::TMemoryMap(FILE* f, EOpenMode om, TString dbgName)
: Impl_(new TImpl(f, om, std::move(dbgName)))
{
@@ -373,9 +373,9 @@ TMemoryMap::TMemoryMap(FILE* f, EOpenMode om, TString dbgName)
TMemoryMap::TMemoryMap(const TFile& file, TString dbgName)
: Impl_(new TImpl(file, EOpenModeFlag::oRdOnly, std::move(dbgName)))
-{
-}
-
+{
+}
+
TMemoryMap::TMemoryMap(const TFile& file, EOpenMode om, TString dbgName)
: Impl_(new TImpl(file, om, std::move(dbgName)))
{
@@ -445,10 +445,10 @@ TFileMap::TFileMap(const TMemoryMap& map) noexcept
}
TFileMap::TFileMap(const TString& name)
- : Map_(name)
-{
-}
-
+ : Map_(name)
+{
+}
+
TFileMap::TFileMap(const TString& name, EOpenMode om)
: Map_(name, om)
{
diff --git a/util/system/filemap.h b/util/system/filemap.h
index 3a5516fe8d..11be64bff4 100644
--- a/util/system/filemap.h
+++ b/util/system/filemap.h
@@ -8,7 +8,7 @@
#include <util/generic/ptr.h>
#include <util/generic/utility.h>
#include <util/generic/yexception.h>
-#include <util/generic/flags.h>
+#include <util/generic/flags.h>
#include <util/generic/string.h>
#include <new>
@@ -48,7 +48,7 @@ struct TMemoryMapCommon {
}
};
- enum EOpenModeFlag {
+ enum EOpenModeFlag {
oRdOnly = 1,
oRdWr = 2,
oCopyOnWr = 4,
@@ -58,7 +58,7 @@ struct TMemoryMapCommon {
oPrecharge = 16,
oPopulate = 32, // Populate page table entries (see mmap's MAP_POPULATE)
};
- Y_DECLARE_FLAGS(EOpenMode, EOpenModeFlag)
+ Y_DECLARE_FLAGS(EOpenMode, EOpenModeFlag)
/**
* Name that will be printed in exceptions if not specified.
@@ -66,7 +66,7 @@ struct TMemoryMapCommon {
*/
static TString UnknownFileName();
};
-Y_DECLARE_OPERATORS_FOR_FLAGS(TMemoryMapCommon::EOpenMode)
+Y_DECLARE_OPERATORS_FOR_FLAGS(TMemoryMapCommon::EOpenMode)
class TMemoryMap: public TMemoryMapCommon {
public: