aboutsummaryrefslogtreecommitdiffstats
path: root/util
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
parent7377d7b033ffbef85e9bb0bf35091a8e79ed422c (diff)
downloadydb-aed1c1c7782eb0a0536e5b25bbed950b397e0ac8.tar.gz
Restoring authorship annotation for <sankear@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util')
-rw-r--r--util/generic/maybe.h18
-rw-r--r--util/generic/maybe_ut.cpp20
-rw-r--r--util/generic/vector.h4
-rw-r--r--util/memory/blob.cpp12
-rw-r--r--util/memory/blob.h12
-rw-r--r--util/string/vector.cpp18
-rw-r--r--util/string/vector.h10
-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
11 files changed, 144 insertions, 144 deletions
diff --git a/util/generic/maybe.h b/util/generic/maybe.h
index ce476a171d..34d21aebcd 100644
--- a/util/generic/maybe.h
+++ b/util/generic/maybe.h
@@ -708,15 +708,15 @@ template <class T, class TPolicy, class U, std::enable_if_t<std::is_convertible<
constexpr bool operator>=(const U& value, const TMaybe<T, TPolicy>& maybe) {
return !(value < maybe);
}
-
+
class IOutputStream;
-
-template <class T, class TPolicy>
+
+template <class T, class TPolicy>
inline IOutputStream& operator<<(IOutputStream& out, const TMaybe<T, TPolicy>& maybe) {
- if (maybe.Defined()) {
- out << *maybe;
- } else {
+ if (maybe.Defined()) {
+ out << *maybe;
+ } else {
out << TStringBuf("(empty maybe)");
- }
- return out;
-}
+ }
+ return out;
+}
diff --git a/util/generic/maybe_ut.cpp b/util/generic/maybe_ut.cpp
index ae5b46adea..2c1a425c5e 100644
--- a/util/generic/maybe_ut.cpp
+++ b/util/generic/maybe_ut.cpp
@@ -787,14 +787,14 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
UNIT_ASSERT(m2 == Nothing());
}
}
-
+
Y_UNIT_TEST(TestOutputStreamEmptyMaybe) {
TString s;
- TStringOutput output(s);
- output << TMaybe<int>();
- UNIT_ASSERT_EQUAL("(empty maybe)", s);
- }
-
+ TStringOutput output(s);
+ output << TMaybe<int>();
+ UNIT_ASSERT_EQUAL("(empty maybe)", s);
+ }
+
Y_UNIT_TEST(TestOutputStreamNothing) {
TString s;
TStringOutput output(s);
@@ -804,10 +804,10 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
Y_UNIT_TEST(TestOutputStreamDefinedMaybe) {
TString s;
- TStringOutput output(s);
- output << TMaybe<int>(42);
- UNIT_ASSERT_EQUAL("42", s);
- }
+ TStringOutput output(s);
+ output << TMaybe<int>(42);
+ UNIT_ASSERT_EQUAL("42", s);
+ }
Y_UNIT_TEST(TestMaybeCovarianceImplicit) {
struct TestStruct {
diff --git a/util/generic/vector.h b/util/generic/vector.h
index 843ac659c8..a5b258955a 100644
--- a/util/generic/vector.h
+++ b/util/generic/vector.h
@@ -73,7 +73,7 @@ public:
}
inline TVector(TSelf&& src) noexcept
- : TBase(std::forward<TSelf>(src))
+ : TBase(std::forward<TSelf>(src))
{
}
@@ -89,7 +89,7 @@ public:
}
inline TSelf& operator=(TSelf&& src) noexcept {
- TBase::operator=(std::forward<TSelf>(src));
+ TBase::operator=(std::forward<TSelf>(src));
return *this;
}
diff --git a/util/memory/blob.cpp b/util/memory/blob.cpp
index d7656c2bac..91da5cadca 100644
--- a/util/memory/blob.cpp
+++ b/util/memory/blob.cpp
@@ -284,14 +284,14 @@ TBlob TBlob::LockedFromFile(const TFile& file) {
return ConstructAsMap<TAtomicCounter>(file, EMappingMode::Locked);
}
-TBlob TBlob::LockedFromMemoryMapSingleThreaded(const TMemoryMap& map, ui64 offset, size_t length) {
+TBlob TBlob::LockedFromMemoryMapSingleThreaded(const TMemoryMap& map, ui64 offset, size_t length) {
return ConstructFromMap<TSimpleCounter>(map, offset, length, EMappingMode::Locked);
-}
-
-TBlob TBlob::LockedFromMemoryMap(const TMemoryMap& map, ui64 offset, size_t length) {
+}
+
+TBlob TBlob::LockedFromMemoryMap(const TMemoryMap& map, ui64 offset, size_t length) {
return ConstructFromMap<TAtomicCounter>(map, offset, length, EMappingMode::Locked);
-}
-
+}
+
TBlob TBlob::FromMemoryMapSingleThreaded(const TMemoryMap& map, ui64 offset, size_t length) {
return ConstructFromMap<TSimpleCounter>(map, offset, length, EMappingMode::Standard);
}
diff --git a/util/memory/blob.h b/util/memory/blob.h
index 701a6d9070..20c02a68df 100644
--- a/util/memory/blob.h
+++ b/util/memory/blob.h
@@ -250,12 +250,12 @@ public:
/// Creates a locked blob with a multi-threaded (atomic) refcounter. It maps the file content as data.
static TBlob LockedFromFile(const TFile& file);
- /// Creates a locked blob with a single-threaded (non atomic) refcounter from the mapped memory.
- static TBlob LockedFromMemoryMapSingleThreaded(const TMemoryMap& map, ui64 offset, size_t length);
-
- /// Creates a locked blob with a multi-threaded (atomic) refcounter from the mapped memory.
- static TBlob LockedFromMemoryMap(const TMemoryMap& map, ui64 offset, size_t length);
-
+ /// Creates a locked blob with a single-threaded (non atomic) refcounter from the mapped memory.
+ static TBlob LockedFromMemoryMapSingleThreaded(const TMemoryMap& map, ui64 offset, size_t length);
+
+ /// Creates a locked blob with a multi-threaded (atomic) refcounter from the mapped memory.
+ static TBlob LockedFromMemoryMap(const TMemoryMap& map, ui64 offset, size_t length);
+
/// Creates a blob with a single-threaded (non atomic) refcounter from the mapped memory.
static TBlob FromMemoryMapSingleThreaded(const TMemoryMap& map, ui64 offset, size_t length);
diff --git a/util/string/vector.cpp b/util/string/vector.cpp
index 1e8ddae94f..9ba401f0a2 100644
--- a/util/string/vector.cpp
+++ b/util/string/vector.cpp
@@ -12,7 +12,7 @@ static inline void DoSplit2(TConsumer& c, TDelim& d, const TBasicStringBuf<TChr>
template <class TConsumer, class TDelim, typename TChr>
static inline void DoSplit1(TConsumer& cc, TDelim& d, const TBasicStringBuf<TChr> str, int opts) {
if (opts & KEEP_EMPTY_TOKENS) {
- DoSplit2(cc, d, str, opts);
+ DoSplit2(cc, d, str, opts);
} else {
TSkipEmptyTokens<TConsumer> sc(&cc);
@@ -35,13 +35,13 @@ static inline void DoSplit0(C* res, const TBasicStringBuf<TChr> str, TDelim& d,
if (maxFields) {
TLimitingConsumer<TConsumer, const TChr> lc(maxFields, &cc);
- DoSplit1(lc, d, str, options);
+ DoSplit1(lc, d, str, options);
if (lc.Last) {
res->push_back(TStringType(lc.Last, str.data() + str.size() - lc.Last));
}
} else {
- DoSplit1(cc, d, str, options);
+ DoSplit1(cc, d, str, options);
}
}
@@ -55,11 +55,11 @@ static void SplitStringImplT(TVector<std::conditional_t<std::is_same<TChr, wchar
if (*(delim + 1)) {
TStringDelimiter<const TChr> d(delim, std::char_traits<TChr>::length(delim));
- DoSplit0(res, str, d, maxFields, options);
+ DoSplit0(res, str, d, maxFields, options);
} else {
TCharDelimiter<const TChr> d(*delim);
- DoSplit0(res, str, d, maxFields, options);
+ DoSplit0(res, str, d, maxFields, options);
}
}
@@ -69,16 +69,16 @@ void ::NPrivate::SplitStringImpl(TVector<TString>* res, const char* ptr, const c
void ::NPrivate::SplitStringImpl(TVector<TString>* res, const char* ptr, size_t len, const char* delim, size_t maxFields, int options) {
return SplitStringImplT<char>(res, TStringBuf(ptr, len), delim, maxFields, options);
-}
-
+}
+
void ::NPrivate::SplitStringImpl(TVector<TUtf16String>* res, const wchar16* ptr, const wchar16* delimiter, size_t maxFields, int options) {
return SplitStringImplT<wchar16>(res, TWtringBuf(ptr), delimiter, maxFields, options);
}
void ::NPrivate::SplitStringImpl(TVector<TUtf16String>* res, const wchar16* ptr, size_t len, const wchar16* delimiter, size_t maxFields, int options) {
return SplitStringImplT<wchar16>(res, TWtringBuf(ptr, len), delimiter, maxFields, options);
-}
-
+}
+
TUtf16String JoinStrings(const TVector<TUtf16String>& v, const TWtringBuf delim) {
return JoinStrings(v.begin(), v.end(), delim);
}
diff --git a/util/string/vector.h b/util/string/vector.h
index d01d9403c3..e36c348bbe 100644
--- a/util/string/vector.h
+++ b/util/string/vector.h
@@ -16,12 +16,12 @@
// NOTE: Check StringSplitter below to get more convenient split string interface.
namespace NPrivate {
-
+
void SplitStringImpl(TVector<TString>* res, const char* ptr,
const char* delimiter, size_t maxFields, int options);
void SplitStringImpl(TVector<TString>* res, const char* ptr, size_t len,
const char* delimiter, size_t maxFields, int options);
-
+
void SplitStringImpl(TVector<TUtf16String>* res, const wchar16* ptr,
const wchar16* delimiter, size_t maxFields, int options);
void SplitStringImpl(TVector<TUtf16String>* res, const wchar16* ptr, size_t len,
@@ -56,9 +56,9 @@ SplitString(const C* ptr, size_t len, const C* delimiter,
size_t maxFields = 0, int options = 0) {
TVector<typename ::NPrivate::TStringDeducer<C>::type> res;
::NPrivate::SplitStringImpl(&res, ptr, len, delimiter, maxFields, options);
- return res;
-}
-
+ return res;
+}
+
template <typename C>
TVector<typename ::NPrivate::TStringDeducer<C>::type>
SplitString(const typename ::NPrivate::TStringDeducer<C>::type& str, const C* delimiter,
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: