aboutsummaryrefslogtreecommitdiffstats
path: root/util/system
diff options
context:
space:
mode:
authorMichael Roizner <mroizner@gmail.com>2022-02-10 16:50:47 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:47 +0300
commit4e10711f67db90b5b08220fee274f8f0fe620485 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /util/system
parenta196186fa7feb0aae6d87e1b6d890a83851be4f2 (diff)
downloadydb-4e10711f67db90b5b08220fee274f8f0fe620485.tar.gz
Restoring authorship annotation for Michael Roizner <mroizner@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'util/system')
-rw-r--r--util/system/file.cpp52
-rw-r--r--util/system/file.h4
-rw-r--r--util/system/file_ut.cpp12
-rw-r--r--util/system/filemap.cpp12
-rw-r--r--util/system/filemap.h8
5 files changed, 44 insertions, 44 deletions
diff --git a/util/system/file.cpp b/util/system/file.cpp
index d6d7d05062..4a261d020c 100644
--- a/util/system/file.cpp
+++ b/util/system/file.cpp
@@ -339,25 +339,25 @@ bool TFileHandle::Resize(i64 length) noexcept {
if (!IsOpen()) {
return false;
}
- i64 currentLength = GetLength();
+ i64 currentLength = GetLength();
if (length == currentLength) {
- return true;
+ return true;
}
#if defined(_win_)
- i64 currentPosition = GetPosition();
+ i64 currentPosition = GetPosition();
if (currentPosition == -1L) {
return false;
}
- Seek(length, sSet);
+ Seek(length, sSet);
if (!::SetEndOfFile(Fd_)) {
return false;
}
if (currentPosition < length) {
- Seek(currentPosition, sSet);
+ Seek(currentPosition, sSet);
}
return true;
#elif defined(_unix_)
- return (0 == ftruncate(Fd_, (off_t)length));
+ return (0 == ftruncate(Fd_, (off_t)length));
#else
#error unsupported platform
#endif
@@ -366,28 +366,28 @@ bool TFileHandle::Resize(i64 length) noexcept {
bool TFileHandle::Reserve(i64 length) noexcept {
// FIXME this should reserve disk space with fallocate
if (!IsOpen()) {
- return false;
+ return false;
}
- i64 currentLength = GetLength();
+ i64 currentLength = GetLength();
if (length <= currentLength) {
- return true;
+ return true;
}
if (!Resize(length)) {
- return false;
+ return false;
}
#if defined(_win_)
- if (!::SetFileValidData(Fd_, length)) {
- Resize(currentLength);
- return false;
- }
+ if (!::SetFileValidData(Fd_, length)) {
+ Resize(currentLength);
+ return false;
+ }
#elif defined(_unix_)
// No way to implement this under FreeBSD. Just do nothing
-#else
+#else
#error unsupported platform
-#endif
- return true;
-}
-
+#endif
+ return true;
+}
+
bool TFileHandle::FallocateNoResize(i64 length) noexcept {
if (!IsOpen()) {
return false;
@@ -897,7 +897,7 @@ public:
ythrow TFileError() << "can't reserve " << length << " for file " << FileName_.Quote();
}
}
-
+
void FallocateNoResize(i64 length) {
if (!Handle_.FallocateNoResize(length)) {
ythrow TFileError() << "can't allocate " << length << "bytes of space for file " << FileName_.Quote();
@@ -1137,14 +1137,14 @@ i64 TFile::Seek(i64 offset, SeekDir origin) {
return Impl_->Seek(offset, origin);
}
-void TFile::Resize(i64 length) {
- Impl_->Resize(length);
+void TFile::Resize(i64 length) {
+ Impl_->Resize(length);
+}
+
+void TFile::Reserve(i64 length) {
+ Impl_->Reserve(length);
}
-void TFile::Reserve(i64 length) {
- Impl_->Reserve(length);
-}
-
void TFile::FallocateNoResize(i64 length) {
Impl_->FallocateNoResize(length);
}
diff --git a/util/system/file.h b/util/system/file.h
index 3c22a7edd5..9502e159b6 100644
--- a/util/system/file.h
+++ b/util/system/file.h
@@ -162,8 +162,8 @@ public:
FHANDLE GetHandle() const noexcept;
i64 Seek(i64 offset, SeekDir origin);
- void Resize(i64 length);
- void Reserve(i64 length);
+ void Resize(i64 length);
+ void Reserve(i64 length);
void FallocateNoResize(i64 length);
void ShrinkToFit();
void Flush();
diff --git a/util/system/file_ut.cpp b/util/system/file_ut.cpp
index 098a875766..941e6a50f3 100644
--- a/util/system/file_ut.cpp
+++ b/util/system/file_ut.cpp
@@ -92,24 +92,24 @@ public:
UNIT_ASSERT_EQUAL(TUnbufferedFileInput(tmp.Name()).ReadAll(), "67895678");
}
-
+
inline void TestResize() {
TTempFile tmp("tmp");
-
+
{
TFile file(tmp.Name(), OpenAlways | WrOnly);
-
+
file.Write("1234567", 7);
file.Seek(3, sSet);
-
+
file.Resize(5);
UNIT_ASSERT_EQUAL(file.GetLength(), 5);
UNIT_ASSERT_EQUAL(file.GetPosition(), 3);
-
+
file.Resize(12);
UNIT_ASSERT_EQUAL(file.GetLength(), 12);
UNIT_ASSERT_EQUAL(file.GetPosition(), 3);
- }
+ }
const TString data = TUnbufferedFileInput(tmp.Name()).ReadAll();
UNIT_ASSERT_EQUAL(data.length(), 12);
diff --git a/util/system/filemap.cpp b/util/system/filemap.cpp
index d75c666b36..7454a4cb94 100644
--- a/util/system/filemap.cpp
+++ b/util/system/filemap.cpp
@@ -474,20 +474,20 @@ TFileMap::TFileMap(const TFileMap& fm) noexcept
{
}
-void TFileMap::Flush(void* ptr, size_t size, bool sync) {
+void TFileMap::Flush(void* ptr, size_t size, bool sync) {
Y_ASSERT(ptr >= Ptr());
Y_ASSERT(static_cast<char*>(ptr) + size <= static_cast<char*>(Ptr()) + MappedSize());
-
+
if (!Region_.IsMapped()) {
return;
}
#if defined(_win_)
- if (sync) {
- FlushViewOfFile(ptr, size);
- }
+ if (sync) {
+ FlushViewOfFile(ptr, size);
+ }
#else
- msync(ptr, size, sync ? MS_SYNC : MS_ASYNC);
+ msync(ptr, size, sync ? MS_SYNC : MS_ASYNC);
#endif
}
diff --git a/util/system/filemap.h b/util/system/filemap.h
index 0016d4f9e5..11be64bff4 100644
--- a/util/system/filemap.h
+++ b/util/system/filemap.h
@@ -129,15 +129,15 @@ public:
void Flush() {
Flush(Ptr(), MappedSize());
}
-
+
void FlushAsync(void* ptr, size_t size) {
Flush(ptr, size, false);
}
-
+
void FlushAsync() {
FlushAsync(Ptr(), MappedSize());
}
-
+
inline i64 Length() const noexcept {
return Map_.Length();
}
@@ -178,7 +178,7 @@ public:
private:
void Flush(void* ptr, size_t size, bool sync);
-
+
TMemoryMap Map_;
TMapResult Region_;
};