summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbabenko <[email protected]>2026-06-07 01:15:06 +0300
committerbabenko <[email protected]>2026-06-07 01:31:50 +0300
commitffc038d5a916cec181915795ca4b45f07ee2ae05 (patch)
tree5ad7c1359f9d96dbd9e17ccb7e1e34e3680682c8
parentd1c1aedb88345a776f41cd481415394ad0f4ca60 (diff)
YT-22593: Reduce TString usage in core/misc
commit_hash:ba8c42476d6274212745348071682042e780037f
-rw-r--r--library/cpp/yt/error/origin_attributes.cpp2
-rw-r--r--yt/yt/core/misc/error.cpp16
-rw-r--r--yt/yt/core/misc/fs.cpp31
-rw-r--r--yt/yt/core/misc/process_exit_profiler.cpp14
-rw-r--r--yt/yt/core/misc/process_exit_profiler.h4
-rw-r--r--yt/yt/core/misc/public.cpp4
-rw-r--r--yt/yt/core/misc/public.h2
-rw-r--r--yt/yt/core/misc/ref_counted_tracker-inl.h4
-rw-r--r--yt/yt/core/misc/ref_counted_tracker.cpp8
-rw-r--r--yt/yt/core/misc/ref_counted_tracker.h4
-rw-r--r--yt/yt/core/misc/statistic_path.cpp2
-rw-r--r--yt/yt/core/misc/statistics.cpp6
-rw-r--r--yt/yt/core/misc/unittests/algorithm_helpers_ut.cpp2
-rw-r--r--yt/yt/core/misc/unittests/checksum_ut.cpp2
-rw-r--r--yt/yt/core/misc/unittests/consistent_hashing_ut.cpp26
-rw-r--r--yt/yt/core/misc/unittests/default_map_ut.cpp2
-rw-r--r--yt/yt/core/misc/unittests/error_ut.cpp4
-rw-r--r--yt/yt/core/misc/unittests/fair_scheduler_ut.cpp2
-rw-r--r--yt/yt/core/misc/unittests/heap_ut.cpp20
-rw-r--r--yt/yt/core/misc/unittests/intern_registry_ut.cpp14
-rw-r--r--yt/yt/core/misc/unittests/lru_cache_ut.cpp8
-rw-r--r--yt/yt/core/misc/unittests/proc_ut.cpp2
-rw-r--r--yt/yt/core/misc/unittests/statistic_path_ut.cpp28
-rw-r--r--yt/yt/core/misc/unittests/statistics_ut.cpp6
-rw-r--r--yt/yt/core/misc/unittests/sync_cache_ut.cpp8
-rw-r--r--yt/yt/core/misc/unittests/tls_expiring_cache_ut.cpp6
26 files changed, 116 insertions, 111 deletions
diff --git a/library/cpp/yt/error/origin_attributes.cpp b/library/cpp/yt/error/origin_attributes.cpp
index 2198912d419..9feaca15f61 100644
--- a/library/cpp/yt/error/origin_attributes.cpp
+++ b/library/cpp/yt/error/origin_attributes.cpp
@@ -88,7 +88,7 @@ std::optional<TOriginAttributes::TErasedExtensionData> GetExtensionData()
std::string FormatOrigin(const TOriginAttributes& attributes)
{
- using TFunctor = TString(*)(const TOriginAttributes&);
+ using TFunctor = std::string(*)(const TOriginAttributes&);
if (auto strong = NGlobal::GetErasedVariable(FormatOriginTag)) {
return strong->AsConcrete<TFunctor>()(attributes);
diff --git a/yt/yt/core/misc/error.cpp b/yt/yt/core/misc/error.cpp
index 3c4c050ba2e..f1dbb25ae02 100644
--- a/yt/yt/core/misc/error.cpp
+++ b/yt/yt/core/misc/error.cpp
@@ -160,7 +160,7 @@ TOriginAttributes::TErasedExtensionData GetExtensionDataOverride()
return TOriginAttributes::TErasedExtensionData{result};
}
-TString FormatOriginOverride(const TOriginAttributes& attributes)
+std::string FormatOriginOverride(const TOriginAttributes& attributes)
{
TryExtractHost(attributes);
return Format("%v (pid %v, thread %v, fid %x)",
@@ -429,7 +429,7 @@ void Deserialize(TError& error, const NYTree::INodePtr& node)
error.SetCode(code);
static const std::string MessageKey("message");
- error.SetMessage(mapNode->GetChildValueOrThrow<TString>(MessageKey));
+ error.SetMessage(mapNode->GetChildValueOrThrow<std::string>(MessageKey));
static const std::string AttributesKey("attributes");
auto children = mapNode->GetChildOrThrow(AttributesKey)->AsMap()->GetChildren();
@@ -539,13 +539,13 @@ void FromProto(TError* error, const NYT::NProto::TError& protoError)
}
error->SetCode(TErrorCode(protoError.code()));
- error->SetMessage(FromProto<TString>(protoError.message()));
+ error->SetMessage(FromProto<std::string>(protoError.message()));
if (protoError.has_attributes()) {
for (const auto& protoAttribute : protoError.attributes().attributes()) {
// NB(arkady-e1ppa): Again for compatibility reasons we have to reconvert stuff
// here as well.
- auto key = FromProto<TString>(protoAttribute.key());
- auto value = FromProto<TString>(protoAttribute.value());
+ auto key = FromProto<std::string>(protoAttribute.key());
+ auto value = FromProto<std::string>(protoAttribute.value());
(*error) <<= TErrorAttribute(key, TYsonString(value));
}
error->UpdateOriginAttributes();
@@ -650,7 +650,7 @@ void TErrorSerializer::Save(TStreamSaveContext& context, const TError& error)
for (const auto& [key, value] : attributePairs) {
// NB(arkady-e1ppa): For the sake of compatibility we keep the old
// serialization format.
- Save(context, TString(key));
+ Save(context, std::string(key));
Save(context, NYson::TYsonString(value));
}
} else {
@@ -667,12 +667,12 @@ void TErrorSerializer::Load(TStreamLoadContext& context, TError& error)
error = {};
auto code = Load<TErrorCode>(context);
- auto message = Load<TString>(context);
+ auto message = Load<std::string>(context);
if (Load<bool>(context)) {
size_t size = TSizeSerializer::Load(context);
for (size_t index = 0; index < size; ++index) {
- auto key = Load<TString>(context);
+ auto key = Load<std::string>(context);
auto value = Load<TYsonString>(context);
error <<= TErrorAttribute(key, value);
}
diff --git a/yt/yt/core/misc/fs.cpp b/yt/yt/core/misc/fs.cpp
index 6a394e9c48b..5a71baf31d2 100644
--- a/yt/yt/core/misc/fs.cpp
+++ b/yt/yt/core/misc/fs.cpp
@@ -71,6 +71,7 @@ bool Exists(const std::string& path)
bool IsDirEmpty(const std::string& path)
{
+ // TODO(babenko): migrate to std::string
TString path_(path);
if (!IsDir(path_)) {
THROW_ERROR_EXCEPTION("%v is not a directory",
@@ -126,7 +127,7 @@ void Replace(const std::string& source, const std::string& destination)
void RemoveRecursive(const std::string& path)
{
- RemoveDirWithContents(TString(path));
+ RemoveDirWithContents(std::string(path));
}
void Rename(const std::string& source, const std::string& destination)
@@ -148,7 +149,7 @@ void Rename(const std::string& source, const std::string& destination)
std::string GetFileName(const std::string& path)
{
size_t slashPosition = path.find_last_of(LOCSLASH_C);
- if (slashPosition == TString::npos) {
+ if (slashPosition == std::string::npos) {
return path;
}
return path.substr(slashPosition + 1);
@@ -185,7 +186,7 @@ std::string GetRealPath(const std::string& path)
}
}
if (!curPath.empty()) {
- parts.push_back(RealPath(TString(curPath)));
+ parts.push_back(RealPath(std::string(curPath)));
} else {
parts.push_back(LOCSLASH_S);
}
@@ -209,7 +210,7 @@ bool IsPathRelativeAndInvolvesNoTraversal(const std::string& path)
currentPath = currentPath.substr(1);
continue;
}
- auto part = slashPosition == TString::npos ? currentPath : currentPath.substr(0, slashPosition);
+ auto part = slashPosition == std::string::npos ? currentPath : currentPath.substr(0, slashPosition);
if (part == "..") {
--depth;
if (depth < 0) {
@@ -220,7 +221,7 @@ bool IsPathRelativeAndInvolvesNoTraversal(const std::string& path)
} else {
++depth;
}
- if (slashPosition == TString::npos) {
+ if (slashPosition == std::string::npos) {
break;
}
currentPath = currentPath.substr(slashPosition + 1);
@@ -231,11 +232,11 @@ bool IsPathRelativeAndInvolvesNoTraversal(const std::string& path)
std::string GetFileExtension(const std::string& path)
{
size_t dotPosition = path.find_last_of('.');
- if (dotPosition == TString::npos) {
+ if (dotPosition == std::string::npos) {
return "";
}
size_t slashPosition = path.find_last_of(LOCSLASH_C);
- if (slashPosition != TString::npos && dotPosition < slashPosition) {
+ if (slashPosition != std::string::npos && dotPosition < slashPosition) {
return "";
}
return path.substr(dotPosition + 1);
@@ -245,7 +246,7 @@ std::string GetFileNameWithoutExtension(const std::string& path)
{
auto fileName = GetFileName(path);
size_t dotPosition = fileName.find_last_of('.');
- if (dotPosition == TString::npos) {
+ if (dotPosition == std::string::npos) {
return fileName;
}
return fileName.substr(0, dotPosition);
@@ -272,7 +273,7 @@ std::vector<std::string> EnumerateFiles(const std::string& path, int depth, bool
std::vector<std::string> result;
if (NFS::Exists(path)) {
TFileList list;
- list.Fill(TString(path), TStringBuf(), TStringBuf(), depth, sortByName);
+ list.Fill(std::string(path), TStringBuf(), TStringBuf(), depth, sortByName);
int size = list.Size();
for (int i = 0; i < size; ++i) {
result.push_back(list.Next());
@@ -286,7 +287,7 @@ std::vector<std::string> EnumerateDirectories(const std::string& path, int depth
std::vector<std::string> result;
if (NFS::Exists(path)) {
TDirsList list;
- list.Fill(TString(path), TStringBuf(), TStringBuf(), depth);
+ list.Fill(std::string(path), TStringBuf(), TStringBuf(), depth);
int size = list.Size();
for (int i = 0; i < size; ++i) {
result.push_back(list.Next());
@@ -540,7 +541,7 @@ std::string CombinePaths(const std::vector<std::string>& paths)
{
YT_VERIFY(!paths.empty());
if (paths.size() == 1) {
- return TString(paths[0]);
+ return std::string(paths[0]);
}
auto result = CombinePaths(paths[0], paths[1]);
for (int index = 2; index < std::ssize(paths); ++index) {
@@ -894,7 +895,9 @@ void SendfileChunkedCopy(
{
#ifdef _linux_
try {
+ // TODO(babenko): migrate to std::string
TFile src(TString(existingPath), OpenExisting | RdOnly | Seq | CloseOnExec);
+ // TODO(babenko): migrate to std::string
TFile dst(TString(newPath), CreateAlways | WrOnly | Seq | CloseOnExec);
dst.Flock(LOCK_EX);
SendfileChunkedCopy(src, dst, chunkSize);
@@ -1112,7 +1115,7 @@ TFuture<TSpliceResult> SpliceAsync(
TError AttachLsofOutput(TError error, const std::string& path)
{
- auto lsofOutput = TShellCommand("lsof", {TString(path)})
+ auto lsofOutput = TShellCommand("lsof", {std::string(path)})
.Run()
.Wait()
.GetOutput();
@@ -1122,7 +1125,7 @@ TError AttachLsofOutput(TError error, const std::string& path)
TError AttachFindOutput(TError error, const std::string& path)
{
- auto findOutput = TShellCommand("find", {TString(path), "-name", "*"})
+ auto findOutput = TShellCommand("find", {std::string(path), "-name", "*"})
.Run()
.Wait()
.GetOutput();
@@ -1143,7 +1146,7 @@ TDeviceId GetDeviceId(const std::string& path)
std::optional<std::string> FindBinaryPath(const std::string& binary)
{
- if (NFs::Exists(TString(binary))) {
+ if (NFs::Exists(std::string(binary))) {
return (TFsPath(NFs::CurrentWorkingDirectory()) / binary).GetPath();
}
diff --git a/yt/yt/core/misc/process_exit_profiler.cpp b/yt/yt/core/misc/process_exit_profiler.cpp
index ec15c33ae66..333d4c2cc5a 100644
--- a/yt/yt/core/misc/process_exit_profiler.cpp
+++ b/yt/yt/core/misc/process_exit_profiler.cpp
@@ -1,12 +1,15 @@
#include "process_exit_profiler.h"
+#include <algorithm>
+#include <cctype>
+
namespace NYT {
////////////////////////////////////////////////////////////////////////////////
TProcessExitProfiler::TProcessExitProfiler(
const NProfiling::TProfiler& parent,
- const TString& prefix)
+ const std::string& prefix)
: Profiler_(parent.WithPrefix(prefix))
, ExitDelayTimer_(Profiler_.Timer("/exit_delay"))
, ExitOKCounter_(Profiler_.Counter("/zero_exit_code"))
@@ -77,15 +80,14 @@ NProfiling::TCounter TProcessExitProfiler::MakeSignalExitCounter(int signal)
.Counter("/count");
}
-TString TProcessExitProfiler::GetSignalName(int signal)
+std::string TProcessExitProfiler::GetSignalName(int signal)
{
#ifdef _unix_
- auto result = TString(strsignal(signal));
- result.to_lower();
- result.Transform([] (size_t, char c) {
+ auto result = std::string(strsignal(signal));
+ std::transform(result.begin(), result.end(), result.begin(), [] (unsigned char c) {
return c == ' '
? '_'
- : c;
+ : std::tolower(c);
});
return result;
diff --git a/yt/yt/core/misc/process_exit_profiler.h b/yt/yt/core/misc/process_exit_profiler.h
index 08cc1aa22d1..0d4898ecb3c 100644
--- a/yt/yt/core/misc/process_exit_profiler.h
+++ b/yt/yt/core/misc/process_exit_profiler.h
@@ -19,7 +19,7 @@ class TProcessExitProfiler
public:
TProcessExitProfiler(
const NProfiling::TProfiler& parent,
- const TString& prefix);
+ const std::string& prefix);
void OnProcessExit(
const TError& error,
@@ -42,7 +42,7 @@ private:
NProfiling::TCounter MakeSignalExitCounter(int signal);
- static TString GetSignalName(int signal);
+ static std::string GetSignalName(int signal);
};
////////////////////////////////////////////////////////////////////////////////
diff --git a/yt/yt/core/misc/public.cpp b/yt/yt/core/misc/public.cpp
index 54920e5a1fa..1fa02285d06 100644
--- a/yt/yt/core/misc/public.cpp
+++ b/yt/yt/core/misc/public.cpp
@@ -4,11 +4,11 @@ namespace NYT {
////////////////////////////////////////////////////////////////////////////////
-const TString YTCoreNoteName = "YT";
+const std::string YTCoreNoteName = "YT";
////////////////////////////////////////////////////////////////////////////////
-TString ProcessErrorCodeFormatter(int code)
+std::string ProcessErrorCodeFormatter(int code)
{
return TEnumTraits<EProcessErrorCode>::ToString(static_cast<EProcessErrorCode>(code));
}
diff --git a/yt/yt/core/misc/public.h b/yt/yt/core/misc/public.h
index 2c07828937c..81d18c89f0e 100644
--- a/yt/yt/core/misc/public.h
+++ b/yt/yt/core/misc/public.h
@@ -140,7 +140,7 @@ class TRefCountedProto;
DECLARE_REFCOUNTED_CLASS(TProcessBase)
const ui32 YTCoreNoteType = 0x5f59545f; // = hex("_YT_") ;)
-extern const TString YTCoreNoteName;
+extern const std::string YTCoreNoteName;
template <class T>
class TInternRegistry;
diff --git a/yt/yt/core/misc/ref_counted_tracker-inl.h b/yt/yt/core/misc/ref_counted_tracker-inl.h
index 5f4a0becd9d..6acc7de6991 100644
--- a/yt/yt/core/misc/ref_counted_tracker-inl.h
+++ b/yt/yt/core/misc/ref_counted_tracker-inl.h
@@ -61,8 +61,8 @@ public:
TRefCountedTypeKey GetTypeKey() const;
const TSourceLocation& GetLocation() const;
- TString GetTypeName() const;
- TString GetFullName() const;
+ std::string GetTypeName() const;
+ std::string GetFullName() const;
size_t GetObjectsAllocated() const;
size_t GetObjectsFreed() const;
diff --git a/yt/yt/core/misc/ref_counted_tracker.cpp b/yt/yt/core/misc/ref_counted_tracker.cpp
index 6eef1377825..668e8d67b66 100644
--- a/yt/yt/core/misc/ref_counted_tracker.cpp
+++ b/yt/yt/core/misc/ref_counted_tracker.cpp
@@ -70,16 +70,16 @@ const TSourceLocation& TRefCountedTracker::TNamedSlot::GetLocation() const
return Key_.Location;
}
-TString TRefCountedTracker::TNamedSlot::GetTypeName() const
+std::string TRefCountedTracker::TNamedSlot::GetTypeName() const
{
return TypeName(*GetTypeKey().Underlying());
}
-TString TRefCountedTracker::TNamedSlot::GetFullName() const
+std::string TRefCountedTracker::TNamedSlot::GetFullName() const
{
const auto& location = Key_.Location;
return location.IsValid()
- ? Format("%v at %v:%v", GetTypeName(), location.GetFileName(), location.GetLine())
+ ? std::string(Format("%v at %v:%v", GetTypeName(), location.GetFileName(), location.GetLine()))
: GetTypeName();
}
@@ -240,7 +240,7 @@ void TRefCountedTracker::SortSnapshot(TNamedStatistics* snapshot, int sortByColu
std::sort(snapshot->begin(), snapshot->end(), predicate);
}
-TString TRefCountedTracker::GetDebugInfo(int sortByColumn) const
+std::string TRefCountedTracker::GetDebugInfo(int sortByColumn) const
{
auto snapshot = GetSnapshot();
SortSnapshot(&snapshot, sortByColumn);
diff --git a/yt/yt/core/misc/ref_counted_tracker.h b/yt/yt/core/misc/ref_counted_tracker.h
index 550d77691b1..c7ef14cc67d 100644
--- a/yt/yt/core/misc/ref_counted_tracker.h
+++ b/yt/yt/core/misc/ref_counted_tracker.h
@@ -30,7 +30,7 @@ struct TRefCountedTrackerStatistics final
struct TNamedSlotStatistics
: public TStatistics
{
- TString FullName;
+ std::string FullName;
};
std::vector<TNamedSlotStatistics> NamedStatistics;
@@ -76,7 +76,7 @@ public:
static void AllocateSpace(TRefCountedTypeCookie cookie, size_t size);
static void FreeSpace(TRefCountedTypeCookie cookie, size_t size);
- TString GetDebugInfo(int sortByColumn = -1) const;
+ std::string GetDebugInfo(int sortByColumn = -1) const;
TRefCountedTrackerStatistics GetStatistics() const;
size_t GetObjectsAllocated(TRefCountedTypeKey typeKey) const;
diff --git a/yt/yt/core/misc/statistic_path.cpp b/yt/yt/core/misc/statistic_path.cpp
index 5526697d320..45f6341039c 100644
--- a/yt/yt/core/misc/statistic_path.cpp
+++ b/yt/yt/core/misc/statistic_path.cpp
@@ -100,7 +100,7 @@ TErrorOr<TStatisticPath> ParseStatisticPath(const TStatisticPathType& path)
TErrorOr<TStatisticPath> SlashedStatisticPath(const TStatisticPathType& path)
{
- TString copy;
+ std::string copy;
std::replace_copy(path.begin(), path.end(), std::back_inserter(copy), TChar('/'), Delimiter);
return ParseStatisticPath(copy);
}
diff --git a/yt/yt/core/misc/statistics.cpp b/yt/yt/core/misc/statistics.cpp
index 28fe01e5ffa..24d10ee9bc9 100644
--- a/yt/yt/core/misc/statistics.cpp
+++ b/yt/yt/core/misc/statistics.cpp
@@ -139,7 +139,7 @@ void TStatistics::ProcessNodeWithCallback(const TStatisticPath& path, const NYTr
case ENodeType::Map:
for (const auto& [key, child] : sample->AsMap()->GetChildren()) {
- callback(path / TStatisticPathLiteral(TString(key)), child);
+ callback(path / TStatisticPathLiteral(std::string(key)), child);
}
break;
@@ -170,7 +170,7 @@ TStatistics::TSummaryRange TStatistics::GetRangeByPrefix(const TStatisticPath& p
// lower_bound is equivalent to upper_bound in this case, but upper_bound is semantically better.
auto begin = Data().upper_bound(prefix);
// This will effectively return an iterator to the first path not starting with "`prefix`/".
- auto end = Data().lower_bound(ParseStatisticPath(prefix.Path() + TString(TChar(Delimiter + 1))).ValueOrThrow());
+ auto end = Data().lower_bound(ParseStatisticPath(prefix.Path() + std::string(1, TChar(Delimiter + 1))).ValueOrThrow());
return TSummaryRange(begin, end);
}
@@ -405,7 +405,7 @@ private:
i64 FilledSummaryFields_ = 0;
bool LastFound_ = false;
- TString LastKey_;
+ std::string LastKey_;
bool FirstMapOpen_ = false;
bool AtSummaryMap_ = false;
diff --git a/yt/yt/core/misc/unittests/algorithm_helpers_ut.cpp b/yt/yt/core/misc/unittests/algorithm_helpers_ut.cpp
index f7dc0f91cac..62d89ce7378 100644
--- a/yt/yt/core/misc/unittests/algorithm_helpers_ut.cpp
+++ b/yt/yt/core/misc/unittests/algorithm_helpers_ut.cpp
@@ -35,7 +35,7 @@ std::reverse_iterator<TIter> BinarySearchReverse(
TEST(TAlgorithmHelpersTest, BinarySearch)
{
{
- std::vector<TString> v;
+ std::vector<std::string> v;
auto it = NYT::LowerBound(v.begin(), v.end(), "test");
EXPECT_EQ(it, v.end());
}
diff --git a/yt/yt/core/misc/unittests/checksum_ut.cpp b/yt/yt/core/misc/unittests/checksum_ut.cpp
index a7390d391fe..86106f33381 100644
--- a/yt/yt/core/misc/unittests/checksum_ut.cpp
+++ b/yt/yt/core/misc/unittests/checksum_ut.cpp
@@ -17,7 +17,7 @@ struct TCrcTestCase
ui64 Iso;
ui64 Ecma;
ui64 Ours;
- TString Data;
+ std::string Data;
};
static std::vector<TCrcTestCase> Cases = {
diff --git a/yt/yt/core/misc/unittests/consistent_hashing_ut.cpp b/yt/yt/core/misc/unittests/consistent_hashing_ut.cpp
index 9d0593b823e..86dbed687c5 100644
--- a/yt/yt/core/misc/unittests/consistent_hashing_ut.cpp
+++ b/yt/yt/core/misc/unittests/consistent_hashing_ut.cpp
@@ -19,7 +19,7 @@ namespace {
struct TStringComparer
{
- bool operator()(const TString& lhs, const TString& rhs) const
+ bool operator()(const std::string& lhs, const std::string& rhs) const
{
return lhs < rhs;
}
@@ -27,7 +27,7 @@ struct TStringComparer
struct TStringHasher
{
- size_t operator()(const TString& node, ui64 index) const
+ size_t operator()(const std::string& node, ui64 index) const
{
return MultiHash(node, index);
}
@@ -35,7 +35,7 @@ struct TStringHasher
struct TCustomStringHasher
{
- size_t operator()(const TString& node, int index) const
+ size_t operator()(const std::string& node, int index) const
{
if (index == 0) {
if (node == "a") {
@@ -58,14 +58,14 @@ struct TCustomStringHasher
TEST(TConsistentHashingRingTest, CheckCollision)
{
- TConsistentHashingRing<TString, TString, TStringComparer, TCustomStringHasher, 1> ring;
+ TConsistentHashingRing<std::string, std::string, TStringComparer, TCustomStringHasher, 1> ring;
ring.AddFile("a", 1);
ring.AddServer("b", 1);
ring.AddServer("c", 1);
EXPECT_EQ(ring.GetServersForFile("a", 1)[0], "c");
}
-void CheckServers(const TCompactVector<TString, 1>& src, const std::vector<TString>& target)
+void CheckServers(const TCompactVector<std::string, 1>& src, const std::vector<std::string>& target)
{
EXPECT_EQ(src.size(), target.size());
EXPECT_TRUE(std::equal(src.begin(), src.end(), target.begin()));
@@ -73,7 +73,7 @@ void CheckServers(const TCompactVector<TString, 1>& src, const std::vector<TStri
TEST(TConsistentHashingRingTest, AddRemove)
{
- TConsistentHashingRing<TString, TString, TStringComparer, TCustomStringHasher, 1> ring;
+ TConsistentHashingRing<std::string, std::string, TStringComparer, TCustomStringHasher, 1> ring;
ring.AddFile("a", 1);
ring.AddServer("b", 1);
CheckServers(ring.GetServersForFile("a", 1), {"b"});
@@ -111,7 +111,7 @@ TEST(TConsistentHashingRingTest, AddRemove)
TEST(TConsistentHashingRingTest, AddRemoveManyReplicas)
{
- TConsistentHashingRing<TString, TString, TStringComparer, TCustomStringHasher, 1> ring;
+ TConsistentHashingRing<std::string, std::string, TStringComparer, TCustomStringHasher, 1> ring;
ring.AddFile("a", 1);
ring.AddServer("b", 2);
@@ -155,7 +155,7 @@ TEST(TConsistentHashingRingTest, AddRemoveManyReplicas)
TEST(TConsistentHashingRingTest, CheckConsistency)
{
- TConsistentHashingRing<TString, TString, TStringComparer, TCustomStringHasher, 1> ring;
+ TConsistentHashingRing<std::string, std::string, TStringComparer, TCustomStringHasher, 1> ring;
ring.AddFile("e", 1);
@@ -207,7 +207,7 @@ private:
std::uniform_int_distribution<> Distribution_;
};
-using TCrpItemWithToken = std::pair<TString, int>;
+using TCrpItemWithToken = std::pair<std::string, int>;
enum class EQueryType
{
@@ -291,7 +291,7 @@ double GetPercentageInconsistentFiles(
int candidateCount,
int batchSize = 1)
{
- TConsistentHashingRing<TString, TString, TStringComparer, TStringHasher, 3> ring;
+ TConsistentHashingRing<std::string, std::string, TStringComparer, TStringHasher, 3> ring;
TCrpItemsContainer servers;
TCrpItemsContainer files;
@@ -312,8 +312,8 @@ double GetPercentageInconsistentFiles(
ring.AddServer(generatedServer.first, generatedServer.second);
}
- auto countDisplaced = [&] (const std::vector<std::pair<EQueryType, std::pair<TString, int>>>& queries) {
- std::map<TCrpItemWithToken, TCompactVector<TString, 1>> serversBefore;
+ auto countDisplaced = [&] (const std::vector<std::pair<EQueryType, std::pair<std::string, int>>>& queries) {
+ std::map<TCrpItemWithToken, TCompactVector<std::string, 1>> serversBefore;
for (const auto& file : files) {
auto candidates = ring.GetServersForFile(file.first, file.second);
candidates.resize(std::min(file.second, candidateCount));
@@ -398,7 +398,7 @@ double GetPercentageInconsistentFiles(
TCrpItemWithToken GenerateItem() {
auto generator = TUniformGenerator();
- TString buffer;
+ std::string buffer;
for (int i = 0; i < StringSize; ++i) {
buffer.push_back(PossibleSymbols[generator(PossibleSymbolsCount)]);
}
diff --git a/yt/yt/core/misc/unittests/default_map_ut.cpp b/yt/yt/core/misc/unittests/default_map_ut.cpp
index e6b385dbef6..7bcbddc4c9f 100644
--- a/yt/yt/core/misc/unittests/default_map_ut.cpp
+++ b/yt/yt/core/misc/unittests/default_map_ut.cpp
@@ -11,7 +11,7 @@ namespace {
TEST(TDefaultMapTest, Common)
{
- TDefaultMap<THashMap<int, TString>> defaultMap("Hello");
+ TDefaultMap<THashMap<int, std::string>> defaultMap("Hello");
EXPECT_EQ(defaultMap[1], "Hello");
defaultMap[1].append(", World");
EXPECT_EQ(defaultMap[1], "Hello, World");
diff --git a/yt/yt/core/misc/unittests/error_ut.cpp b/yt/yt/core/misc/unittests/error_ut.cpp
index 4335e604af9..335c7e3d9e9 100644
--- a/yt/yt/core/misc/unittests/error_ut.cpp
+++ b/yt/yt/core/misc/unittests/error_ut.cpp
@@ -40,7 +40,7 @@ TEST(TErrorTest, SerializationDepthLimit)
for (int i = 0; i < ErrorSerializationDepthLimit - 1; ++i) {
ASSERT_EQ(errorNode->GetChildValueOrThrow<i64>("code"), i);
- ASSERT_EQ(errorNode->GetChildValueOrThrow<TString>("message"), "error");
+ ASSERT_EQ(errorNode->GetChildValueOrThrow<std::string>("message"), "error");
ASSERT_FALSE(errorNode->GetChildOrThrow("attributes")->AsMap()->FindChild("original_error_depth"));
auto innerErrors = errorNode->GetChildOrThrow("inner_errors")->AsList()->GetChildren();
ASSERT_EQ(innerErrors.size(), 1u);
@@ -52,7 +52,7 @@ TEST(TErrorTest, SerializationDepthLimit)
for (int i = 0; i < std::ssize(children); ++i) {
auto child = children[i]->AsMap();
ASSERT_EQ(child->GetChildValueOrThrow<i64>("code"), i + ErrorSerializationDepthLimit);
- ASSERT_EQ(child->GetChildValueOrThrow<TString>("message"), "error");
+ ASSERT_EQ(child->GetChildValueOrThrow<std::string>("message"), "error");
auto originalErrorDepth = child->GetChildOrThrow("attributes")->AsMap()->FindChild("original_error_depth");
if (i > 0) {
ASSERT_TRUE(originalErrorDepth);
diff --git a/yt/yt/core/misc/unittests/fair_scheduler_ut.cpp b/yt/yt/core/misc/unittests/fair_scheduler_ut.cpp
index d249f87b404..c77304ffdd8 100644
--- a/yt/yt/core/misc/unittests/fair_scheduler_ut.cpp
+++ b/yt/yt/core/misc/unittests/fair_scheduler_ut.cpp
@@ -13,7 +13,7 @@ class TFairSchedulerTest
: public ::testing::Test
{
protected:
- const IFairSchedulerPtr<TString> Scheduler_ = CreateFairScheduler<TString>();
+ const IFairSchedulerPtr<std::string> Scheduler_ = CreateFairScheduler<std::string>();
};
TEST_F(TFairSchedulerTest, Simple)
diff --git a/yt/yt/core/misc/unittests/heap_ut.cpp b/yt/yt/core/misc/unittests/heap_ut.cpp
index 6d969765c11..476b1fea8f9 100644
--- a/yt/yt/core/misc/unittests/heap_ut.cpp
+++ b/yt/yt/core/misc/unittests/heap_ut.cpp
@@ -9,9 +9,9 @@ namespace {
////////////////////////////////////////////////////////////////////////////////
-TString GetRandomString(int len)
+std::string GetRandomString(int len)
{
- TString str;
+ std::string str;
for (int i = 0; i < len; ++i) {
str.push_back('a' + rand() % 26);
}
@@ -22,7 +22,7 @@ TEST(THeapTest, MakeThenExtract)
{
srand(0);
- std::vector<TString> words;
+ std::vector<std::string> words;
for (int i = 0; i < 10000; ++i) {
words.push_back(GetRandomString(10));
}
@@ -30,10 +30,10 @@ TEST(THeapTest, MakeThenExtract)
auto sorted = words;
std::sort(sorted.begin(), sorted.end());
- NYT::MakeHeap(words.begin(), words.end(), std::greater<TString>());
+ NYT::MakeHeap(words.begin(), words.end(), std::greater<std::string>());
auto end = words.end();
while (end != words.begin()) {
- NYT::ExtractHeap(words.begin(), end, std::greater<TString>());
+ NYT::ExtractHeap(words.begin(), end, std::greater<std::string>());
--end;
}
@@ -76,9 +76,9 @@ TEST(THeapTest, MakeThenExtractMoveOnly)
{
srand(0);
- std::vector<std::unique_ptr<TString>> words;
+ std::vector<std::unique_ptr<std::string>> words;
for (int i = 0; i < 10000; ++i) {
- words.push_back(std::make_unique<TString>(GetRandomString(10)));
+ words.push_back(std::make_unique<std::string>(GetRandomString(10)));
}
NYT::MakeHeap(words.begin(), words.end(), [] (const auto& lhs, const auto& rhs) { return *lhs > *rhs; });
@@ -96,7 +96,7 @@ TEST(THeapTest, InsertThenExtract)
{
srand(0);
- std::vector<TString> words;
+ std::vector<std::string> words;
for (int i = 0; i < 10000; ++i) {
words.push_back(GetRandomString(10));
}
@@ -105,12 +105,12 @@ TEST(THeapTest, InsertThenExtract)
std::sort(sorted.begin(), sorted.end());
for (auto it = words.begin(); it != words.end(); ++it) {
- NYT::AdjustHeapBack(words.begin(), it, std::greater<TString>());
+ NYT::AdjustHeapBack(words.begin(), it, std::greater<std::string>());
}
auto end = words.end();
while (end != words.begin()) {
- NYT::ExtractHeap(words.begin(), end, std::greater<TString>());
+ NYT::ExtractHeap(words.begin(), end, std::greater<std::string>());
--end;
}
diff --git a/yt/yt/core/misc/unittests/intern_registry_ut.cpp b/yt/yt/core/misc/unittests/intern_registry_ut.cpp
index a7974265137..e441ede0b27 100644
--- a/yt/yt/core/misc/unittests/intern_registry_ut.cpp
+++ b/yt/yt/core/misc/unittests/intern_registry_ut.cpp
@@ -7,8 +7,8 @@ namespace {
////////////////////////////////////////////////////////////////////////////////
-using TStringRegistry = TInternRegistry<TString>;
-using TInternedString = TInternedObject<TString>;
+using TStringRegistry = TInternRegistry<std::string>;
+using TInternedString = TInternedObject<std::string>;
TEST(TInternRegistryTest, TestEmptyRegistry)
{
@@ -27,19 +27,19 @@ TEST(TInternRegistryTest, Simple)
auto registry = New<TStringRegistry>();
EXPECT_EQ(0, registry->GetSize());
- auto s1 = registry->Intern(TString("hello"));
+ auto s1 = registry->Intern(std::string("hello"));
EXPECT_EQ(1, registry->GetSize());
- auto s2 = registry->Intern(TString("world"));
+ auto s2 = registry->Intern(std::string("world"));
EXPECT_EQ(2, registry->GetSize());
- auto s3 = registry->Intern(TString("hello"));
+ auto s3 = registry->Intern(std::string("hello"));
EXPECT_EQ(2, registry->GetSize());
EXPECT_TRUE(*s1 == *s3);
EXPECT_FALSE(*s1 == *s2);
- auto s4 = registry->Intern(TString("test"));
+ auto s4 = registry->Intern(std::string("test"));
EXPECT_EQ(3, registry->GetSize());
s4 = TInternedString();
@@ -63,7 +63,7 @@ TEST(TInternRegistryTest, Default)
auto s1 = TInternedString();
- auto s2 = registry->Intern(TString());
+ auto s2 = registry->Intern(std::string());
EXPECT_EQ(0, registry->GetSize());
EXPECT_TRUE(*s1 == *s2);
diff --git a/yt/yt/core/misc/unittests/lru_cache_ut.cpp b/yt/yt/core/misc/unittests/lru_cache_ut.cpp
index 3c25f3b69b0..712ee9d767a 100644
--- a/yt/yt/core/misc/unittests/lru_cache_ut.cpp
+++ b/yt/yt/core/misc/unittests/lru_cache_ut.cpp
@@ -9,7 +9,7 @@ namespace {
TEST(TSimpleLruCacheTest, Common)
{
- TSimpleLruCache<TString, int> cache(2);
+ TSimpleLruCache<std::string, int> cache(2);
cache.Insert("a", 1);
cache.Insert("b", 2);
@@ -46,7 +46,7 @@ TEST(TSimpleLruCacheTest, Common)
TEST(TSimpleLruCacheTest, Clear)
{
- TSimpleLruCache<TString, int> cache(2);
+ TSimpleLruCache<std::string, int> cache(2);
cache.Insert("a", 1);
cache.Insert("b", 2);
@@ -67,7 +67,7 @@ TEST(TSimpleLruCacheTest, Clear)
TEST(TMultiLruCacheTest, InsertAndFind)
{
- TMultiLruCache<TString, int> cache(3);
+ TMultiLruCache<std::string, int> cache(3);
EXPECT_EQ(cache.GetSize(), 0);
@@ -113,7 +113,7 @@ TEST(TMultiLruCacheTest, InsertAndFind)
TEST(TMultiLruCacheTest, Extract)
{
- TMultiLruCache<TString, int> cache(3);
+ TMultiLruCache<std::string, int> cache(3);
cache.Insert("a", 1);
cache.Insert("b", 2);
diff --git a/yt/yt/core/misc/unittests/proc_ut.cpp b/yt/yt/core/misc/unittests/proc_ut.cpp
index 3ec36825315..6134acfc7b3 100644
--- a/yt/yt/core/misc/unittests/proc_ut.cpp
+++ b/yt/yt/core/misc/unittests/proc_ut.cpp
@@ -12,7 +12,7 @@ namespace {
TEST(TProcTest, TestParseMemoryMappings)
{
- const TString rawSMaps =
+ const std::string rawSMaps =
"7fbb7b24d000-7fbb7b251000 rw-s 00000000 00:00 0 \n"
"Size: 1 kB\n"
"KernelPageSize: 2 kB\n"
diff --git a/yt/yt/core/misc/unittests/statistic_path_ut.cpp b/yt/yt/core/misc/unittests/statistic_path_ut.cpp
index 36019a63338..00dabdf4a7e 100644
--- a/yt/yt/core/misc/unittests/statistic_path_ut.cpp
+++ b/yt/yt/core/misc/unittests/statistic_path_ut.cpp
@@ -20,12 +20,12 @@ TEST(TStatisticPathTest, Literal)
EXPECT_EQ("ABC"_L.Literal(), "ABC");
EXPECT_TRUE(CheckStatisticPathLiteral("$a/b.c").IsOK());
- EXPECT_FALSE(CheckStatisticPathLiteral(TString(Delimiter)).IsOK());
+ EXPECT_FALSE(CheckStatisticPathLiteral(std::string(1, Delimiter)).IsOK());
EXPECT_FALSE(CheckStatisticPathLiteral("\0").IsOK());
EXPECT_FALSE(CheckStatisticPathLiteral("").IsOK());
EXPECT_THROW(TStatisticPathLiteral("\0"), TErrorException);
- EXPECT_THROW(TStatisticPathLiteral(TString(Delimiter)), TErrorException);
+ EXPECT_THROW(TStatisticPathLiteral(std::string(1, Delimiter)), TErrorException);
EXPECT_THROW(TStatisticPathLiteral(""), TErrorException);
EXPECT_EQ("A"_L / "BB"_L / "CCC"_L, "/A/BB/CCC"_SP);
@@ -36,7 +36,7 @@ TEST(TStatisticPathTest, Literal)
TEST(TStatisticPathTest, Append)
{
EXPECT_EQ(("A"_L / "BB"_L / "CCC"_L).Path(),
- TString(Delimiter) + "A" + Delimiter + "BB" + Delimiter + "CCC");
+ std::string(1, Delimiter) + "A" + Delimiter + "BB" + Delimiter + "CCC");
EXPECT_EQ(("A"_L / "B"_L) / "C"_L, "A"_L / ("B"_L / "C"_L));
@@ -53,16 +53,16 @@ TEST(TStatisticPathTest, Iterator)
TStatisticPath path = "A"_L / "BB"_L / "CCC"_L;
- std::vector<TString> expected{"A", "BB", "CCC"};
+ std::vector<std::string> expected{"A", "BB", "CCC"};
{
- std::vector<TString> actual(path.begin(), path.end());
+ std::vector<std::string> actual(path.begin(), path.end());
EXPECT_EQ(actual, expected);
}
{
std::reverse(expected.begin(), expected.end());
- std::vector<TString> actual(path.rbegin(), path.rend());
+ std::vector<std::string> actual(path.rbegin(), path.rend());
EXPECT_EQ(actual, expected);
}
@@ -105,7 +105,7 @@ TEST(TStatisticPathTest, Compare)
TEST(TStatisticPathTest, Adjacent)
{
for (TChar c = std::numeric_limits<TChar>::min();; ++c) {
- auto literal = ParseStatisticPathLiteral(TString("A") + c + "B");
+ auto literal = ParseStatisticPathLiteral(std::string("A") + c + "B");
if (literal.IsOK()) {
EXPECT_LT("A"_L / "B"_L, TStatisticPath(literal.Value()));
}
@@ -119,22 +119,22 @@ TEST(TStatisticPathTest, Adjacent)
TEST(TStatisticPathTest, Parse)
{
- EXPECT_EQ(ParseStatisticPath(TString(Delimiter) + "ABC" + Delimiter + "DEF").ValueOrThrow(), "ABC"_L / "DEF"_L);
+ EXPECT_EQ(ParseStatisticPath(std::string(1, Delimiter) + "ABC" + Delimiter + "DEF").ValueOrThrow(), "ABC"_L / "DEF"_L);
EXPECT_EQ(ParseStatisticPath("").ValueOrThrow(), TStatisticPath());
- EXPECT_FALSE(ParseStatisticPath(TString(Delimiter) + "A\0B"_sb).IsOK());
- EXPECT_FALSE(ParseStatisticPath(TString(Delimiter) + "AB" + Delimiter).IsOK());
- EXPECT_FALSE(ParseStatisticPath(TString(Delimiter) + "A" + Delimiter + Delimiter + "B").IsOK());
+ EXPECT_FALSE(ParseStatisticPath(std::string(1, Delimiter) + std::string("A\0B"_sb)).IsOK());
+ EXPECT_FALSE(ParseStatisticPath(std::string(1, Delimiter) + "AB" + Delimiter).IsOK());
+ EXPECT_FALSE(ParseStatisticPath(std::string(1, Delimiter) + "A" + Delimiter + Delimiter + "B").IsOK());
}
////////////////////////////////////////////////////////////////////////////////
TEST(TStatisticPathTest, Constructor)
{
- EXPECT_EQ(TStatisticPath("abc"_L).Path(), TString(Delimiter) + "abc");
+ EXPECT_EQ(TStatisticPath("abc"_L).Path(), std::string(1, Delimiter) + "abc");
TStatisticPath defaultConstructed;
- EXPECT_EQ(defaultConstructed.Path(), TString());
+ EXPECT_EQ(defaultConstructed.Path(), std::string());
EXPECT_TRUE(defaultConstructed.Empty());
}
@@ -222,7 +222,7 @@ TEST(TStatisticPathTest, Serialize)
{
TStatisticPath path = "A"_L / "B/C"_L;
EXPECT_EQ(
- ConvertTo<TString>(ConvertToYsonString(path)),
+ ConvertTo<std::string>(ConvertToYsonString(path)),
path.Path());
}
diff --git a/yt/yt/core/misc/unittests/statistics_ut.cpp b/yt/yt/core/misc/unittests/statistics_ut.cpp
index c7085801cd4..256c3c0ded4 100644
--- a/yt/yt/core/misc/unittests/statistics_ut.cpp
+++ b/yt/yt/core/misc/unittests/statistics_ut.cpp
@@ -72,7 +72,7 @@ TStatistics CreateStatistics(std::initializer_list<std::pair<TStatisticPath, i64
TEST(TStatisticsTest, AddSample)
{
- std::map<TString, int> origin = {{"x", 5}, {"y", 7}};
+ std::map<std::string, int> origin = {{"x", 5}, {"y", 7}};
TStatistics statistics;
statistics.AddSample(
@@ -200,7 +200,7 @@ TEST(TStatisticsTest, GetRangeByPrefix) {
{"a"_L, 1},
{"b"_L / "a"_L, 1},
{"b"_L / "aa"_L / "a"_L, 1},
- {"b"_L / TStatisticPathLiteral(TString(std::numeric_limits<char>::max())), 1},
+ {"b"_L / TStatisticPathLiteral(std::string(1, std::numeric_limits<char>::max())), 1},
{"c"_L, 1},
});
@@ -214,7 +214,7 @@ TEST(TStatisticsTest, GetRangeByPrefix) {
TStatistics expectedRange = CreateStatistics({
{"b"_L / "a"_L, 1},
{"b"_L / "aa"_L / "a"_L, 1},
- {"b"_L / TStatisticPathLiteral(TString(std::numeric_limits<char>::max())), 1},
+ {"b"_L / TStatisticPathLiteral(std::string(1, std::numeric_limits<char>::max())), 1},
});
EXPECT_EQ(std::map(actualRange.begin(), actualRange.end()), expectedRange.Data());
diff --git a/yt/yt/core/misc/unittests/sync_cache_ut.cpp b/yt/yt/core/misc/unittests/sync_cache_ut.cpp
index 61420f4f65b..f85e8a56125 100644
--- a/yt/yt/core/misc/unittests/sync_cache_ut.cpp
+++ b/yt/yt/core/misc/unittests/sync_cache_ut.cpp
@@ -12,7 +12,7 @@ namespace {
DECLARE_REFCOUNTED_STRUCT(TTestValue)
struct TTestValue
- : TSyncCacheValueBase<TString, TTestValue>
+ : TSyncCacheValueBase<std::string, TTestValue>
{
public:
using TSyncCacheValueBase::TSyncCacheValueBase;
@@ -23,7 +23,7 @@ public:
DEFINE_REFCOUNTED_TYPE(TTestValue)
class TTestCache
- : public TSyncSlruCacheBase<TString, TTestValue>
+ : public TSyncSlruCacheBase<std::string, TTestValue>
{
public:
using TSyncSlruCacheBase::TSyncSlruCacheBase;
@@ -36,7 +36,7 @@ public:
TSharedRef CreateRandomReference(TFastRng64& rnd, i64 size)
{
- TString s;
+ std::string s;
s.resize(size, '*');
for (i64 index = 0; index < size; ++index) {
@@ -79,7 +79,7 @@ TEST(TSyncSlruCacheTest, EntryWeightUpdate)
auto cache = New<TTestCache>(config);
for (; cache->GetSize() < 990;) {
- cache->TryInsert(New<TTestValue>(TString(CreateRandomReference(rng, 256).ToStringBuf())));
+ cache->TryInsert(New<TTestValue>(std::string(CreateRandomReference(rng, 256).ToStringBuf())));
}
EXPECT_GE(990, cache->GetSize());
diff --git a/yt/yt/core/misc/unittests/tls_expiring_cache_ut.cpp b/yt/yt/core/misc/unittests/tls_expiring_cache_ut.cpp
index e3f4415e722..a019ec38e5c 100644
--- a/yt/yt/core/misc/unittests/tls_expiring_cache_ut.cpp
+++ b/yt/yt/core/misc/unittests/tls_expiring_cache_ut.cpp
@@ -15,7 +15,7 @@ using namespace NConcurrency;
TEST(TThreadLocalExpiringCacheTest, Simple)
{
- TThreadLocalExpiringCache<TString, int> cache(TDuration::Hours(1));
+ TThreadLocalExpiringCache<std::string, int> cache(TDuration::Hours(1));
EXPECT_EQ(std::nullopt, cache.Get("hello"));
EXPECT_EQ(std::nullopt, cache.Get("hello"));
@@ -26,7 +26,7 @@ TEST(TThreadLocalExpiringCacheTest, Simple)
TEST(TThreadLocalExpiringCacheTest, ThreadLocal)
{
- TThreadLocalExpiringCache<TString, int> cache(TDuration::Hours(1));
+ TThreadLocalExpiringCache<std::string, int> cache(TDuration::Hours(1));
std::vector<std::thread> threads;
for (int i = 0; i < 16; ++i) {
@@ -49,7 +49,7 @@ TEST(TThreadLocalExpiringCacheTest, Expiration)
auto duration = TDuration::MilliSeconds(100);
auto cpuDuration = DurationToCpuDuration(duration);
- TThreadLocalExpiringCache<TString, int> cache(duration);
+ TThreadLocalExpiringCache<std::string, int> cache(duration);
cache.Set("hello", 42);
EXPECT_EQ(42, cache.Get("hello"));
auto now = GetCpuInstant();