aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarkady-e1ppa <arkady-e1ppa@yandex-team.com>2024-06-11 22:01:04 +0300
committerarkady-e1ppa <arkady-e1ppa@yandex-team.com>2024-06-12 11:47:00 +0300
commit89f56e044a4f82c7e88fa15771beca2d5787c7c8 (patch)
treeadb31c52e55de4c2131cf15ca722e64b609b1a10
parenta41bb65a80fdc183e427b6c337dbbc15776f1c92 (diff)
downloadydb-89f56e044a4f82c7e88fa15771beca2d5787c7c8.tar.gz
YT-21868: Delete unneeded ToString methods
e856aa45df227b86e8b121852d3774bb2504193b
-rw-r--r--library/cpp/yt/misc/optional.h6
-rw-r--r--library/cpp/yt/misc/source_location.cpp7
-rw-r--r--library/cpp/yt/misc/source_location.h3
-rw-r--r--library/cpp/yt/misc/strong_typedef.h7
-rw-r--r--library/cpp/yt/misc/variant-inl.h6
-rw-r--r--library/cpp/yt/misc/variant.cpp2
-rw-r--r--library/cpp/yt/misc/variant.h5
-rw-r--r--library/cpp/yt/string/format-inl.h16
-rw-r--r--library/cpp/yt/string/format_arg-inl.h7
-rw-r--r--library/cpp/yt/string/format_arg.h3
-rw-r--r--library/cpp/yt/string/string_builder-inl.h9
-rw-r--r--yt/yt/client/chaos_client/replication_card_cache.cpp5
-rw-r--r--yt/yt/client/chaos_client/replication_card_cache.h1
-rw-r--r--yt/yt/client/chunk_client/data_statistics.cpp5
-rw-r--r--yt/yt/client/chunk_client/data_statistics.h1
-rw-r--r--yt/yt/client/chunk_client/read_limit.cpp66
-rw-r--r--yt/yt/client/chunk_client/read_limit.h2
-rw-r--r--yt/yt/client/driver/helpers.cpp4
-rw-r--r--yt/yt/client/driver/helpers.h2
-rw-r--r--yt/yt/client/driver/proxy_discovery_cache.cpp5
-rw-r--r--yt/yt/client/driver/proxy_discovery_cache.h1
-rw-r--r--yt/yt/client/hydra/version.cpp15
-rw-r--r--yt/yt/client/hydra/version.h3
-rw-r--r--yt/yt/client/misc/workload.cpp7
-rw-r--r--yt/yt/client/misc/workload.h3
-rw-r--r--yt/yt/client/node_tracker_client/helpers.cpp10
-rw-r--r--yt/yt/client/node_tracker_client/helpers.h2
-rw-r--r--yt/yt/client/node_tracker_client/node_directory.cpp5
-rw-r--r--yt/yt/client/node_tracker_client/node_directory.h1
-rw-r--r--yt/yt/client/object_client/public.cpp5
-rw-r--r--yt/yt/client/object_client/public.h3
-rw-r--r--yt/yt/client/scheduler/operation_id_or_alias.cpp7
-rw-r--r--yt/yt/client/scheduler/operation_id_or_alias.h3
-rw-r--r--yt/yt/client/table_client/column_sort_schema.cpp7
-rw-r--r--yt/yt/client/table_client/column_sort_schema.h3
-rw-r--r--yt/yt/client/table_client/comparator.cpp5
-rw-r--r--yt/yt/client/table_client/comparator.h1
-rw-r--r--yt/yt/client/table_client/key.cpp7
-rw-r--r--yt/yt/client/table_client/key.h3
-rw-r--r--yt/yt/client/table_client/key_bound.cpp14
-rw-r--r--yt/yt/client/table_client/key_bound.h6
-rw-r--r--yt/yt/client/table_client/versioned_row.cpp30
-rw-r--r--yt/yt/client/table_client/versioned_row.h13
-rw-r--r--yt/yt/client/ypath/rich.cpp9
-rw-r--r--yt/yt/client/ypath/rich.h1
-rw-r--r--yt/yt/core/dns/dns_resolver.cpp5
-rw-r--r--yt/yt/core/dns/dns_resolver.h1
-rw-r--r--yt/yt/core/misc/arithmetic_formula.cpp14
-rw-r--r--yt/yt/core/misc/arithmetic_formula.h6
-rw-r--r--yt/yt/core/misc/error-inl.h6
-rw-r--r--yt/yt/core/misc/error.cpp12
-rw-r--r--yt/yt/core/misc/error.h5
-rw-r--r--yt/yt/core/misc/maybe_inf-inl.h14
-rw-r--r--yt/yt/core/misc/maybe_inf.h3
-rw-r--r--yt/yt/core/net/address.cpp10
-rw-r--r--yt/yt/core/net/address.h2
-rw-r--r--yt/yt/core/rpc/authentication_identity.cpp7
-rw-r--r--yt/yt/core/rpc/authentication_identity.h3
-rw-r--r--yt/yt/core/rpc/grpc/helpers.cpp14
-rw-r--r--yt/yt/core/rpc/grpc/helpers.h3
-rw-r--r--yt/yt/core/rpc/protocol_version.cpp5
-rw-r--r--yt/yt/core/rpc/protocol_version.h1
-rw-r--r--yt/yt/core/rpc/service.cpp16
-rw-r--r--yt/yt/core/rpc/service.h4
-rw-r--r--yt/yt/core/tracing/trace_context.cpp15
-rw-r--r--yt/yt/core/tracing/trace_context.h3
-rw-r--r--yt/yt/core/ytree/attribute_filter.cpp7
-rw-r--r--yt/yt/core/ytree/attribute_filter.h3
-rw-r--r--yt/yt/core/ytree/ypath_service.cpp6
-rw-r--r--yt/yt/library/numeric/double_array_format.h5
-rw-r--r--yt/yt/library/numeric/piecewise_linear_function-inl.h4
-rw-r--r--yt/yt/library/numeric/piecewise_linear_function.h1
-rw-r--r--yt/yt/library/numeric/unittests/piecewise_linear_function_ut.cpp40
-rw-r--r--yt/yt/library/numeric/vector_format.h26
-rw-r--r--yt/yt/library/numeric/ya.make1
-rw-r--r--yt/yt/library/profiling/sensor.cpp5
-rw-r--r--yt/yt/library/profiling/sensor.h4
77 files changed, 142 insertions, 435 deletions
diff --git a/library/cpp/yt/misc/optional.h b/library/cpp/yt/misc/optional.h
index d5e3c07fbe..c5982af7bf 100644
--- a/library/cpp/yt/misc/optional.h
+++ b/library/cpp/yt/misc/optional.h
@@ -97,12 +97,6 @@ struct TStdOptionalTraits<std::optional<T>>
} // namespace NYT
template <class T>
-TString ToString(const std::optional<T>& nullable)
-{
- return nullable ? ToString(*nullable) : "<Null>";
-}
-
-template <class T>
struct THash<std::optional<T>>
{
size_t operator()(const std::optional<T>& nullable) const
diff --git a/library/cpp/yt/misc/source_location.cpp b/library/cpp/yt/misc/source_location.cpp
index 3fe45e23a7..37eb5edd53 100644
--- a/library/cpp/yt/misc/source_location.cpp
+++ b/library/cpp/yt/misc/source_location.cpp
@@ -10,7 +10,7 @@ namespace NYT {
#ifdef __cpp_lib_source_location
-void FormatValue(TStringBuilderBase* builder, const std::source_location& location, TStringBuf /*format*/)
+void FormatValue(TStringBuilderBase* builder, const std::source_location& location, TStringBuf /*spec*/)
{
if (location.file_name() != nullptr) {
builder->AppendFormat(
@@ -23,11 +23,6 @@ void FormatValue(TStringBuilderBase* builder, const std::source_location& locati
}
}
-TString ToString(const std::source_location& location)
-{
- return ToStringViaBuilder(location);
-}
-
#endif // __cpp_lib_source_location
////////////////////////////////////////////////////////////////////////////////
diff --git a/library/cpp/yt/misc/source_location.h b/library/cpp/yt/misc/source_location.h
index 38a6f83c80..43b2b86fcd 100644
--- a/library/cpp/yt/misc/source_location.h
+++ b/library/cpp/yt/misc/source_location.h
@@ -15,8 +15,7 @@ namespace NYT {
class TStringBuilderBase;
-void FormatValue(TStringBuilderBase* builder, const std::source_location& location, TStringBuf /*format*/);
-TString ToString(const std::source_location& location);
+void FormatValue(TStringBuilderBase* builder, const std::source_location& location, TStringBuf /*spec*/);
#endif // __cpp_lib_source_location
diff --git a/library/cpp/yt/misc/strong_typedef.h b/library/cpp/yt/misc/strong_typedef.h
index d47581701d..58d96ebd2c 100644
--- a/library/cpp/yt/misc/strong_typedef.h
+++ b/library/cpp/yt/misc/strong_typedef.h
@@ -56,13 +56,6 @@ public:
private:
T Underlying_;
-
- //! NB: Hidden friend definition to make this name accessible only via ADL.
- friend TString ToString(const TStrongTypedef& value)
- requires requires (T value) { { ToString(value) } -> std::same_as<TString>; }
- {
- return ToString(value.Underlying_);
- }
};
#define YT_DEFINE_STRONG_TYPEDEF(T, TUnderlying) \
diff --git a/library/cpp/yt/misc/variant-inl.h b/library/cpp/yt/misc/variant-inl.h
index 01f0e08593..4b0e04c92c 100644
--- a/library/cpp/yt/misc/variant-inl.h
+++ b/library/cpp/yt/misc/variant-inl.h
@@ -45,12 +45,6 @@ void FormatValue(TStringBuilderBase* builder, const std::variant<Ts...>& variant
NDetail::TVariantFormatter<0, Ts...>::Do(builder, variant, spec);
}
-template <class... Ts>
-TString ToString(const std::variant<Ts...>& variant)
-{
- return ToStringViaBuilder(variant);
-}
-
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT
diff --git a/library/cpp/yt/misc/variant.cpp b/library/cpp/yt/misc/variant.cpp
index be86affef8..df78563d0c 100644
--- a/library/cpp/yt/misc/variant.cpp
+++ b/library/cpp/yt/misc/variant.cpp
@@ -6,7 +6,7 @@ namespace NYT {
////////////////////////////////////////////////////////////////////////////////
-void FormatValue(TStringBuilderBase* builder, const std::monostate&, TStringBuf /*format*/)
+void FormatValue(TStringBuilderBase* builder, const std::monostate&, TStringBuf /*spec*/)
{
builder->AppendString(TStringBuf("<monostate>"));
}
diff --git a/library/cpp/yt/misc/variant.h b/library/cpp/yt/misc/variant.h
index 4ca977873e..9e8e122089 100644
--- a/library/cpp/yt/misc/variant.h
+++ b/library/cpp/yt/misc/variant.h
@@ -12,10 +12,7 @@ class TStringBuilderBase;
template <class... Ts>
void FormatValue(TStringBuilderBase* builder, const std::variant<Ts...>& variant, TStringBuf spec);
-void FormatValue(TStringBuilderBase* builder, const std::monostate&, TStringBuf /*format*/);
-
-template <class... Ts>
-TString ToString(const std::variant<Ts...>& variant);
+void FormatValue(TStringBuilderBase* builder, const std::monostate&, TStringBuf /*spec*/);
////////////////////////////////////////////////////////////////////////////////
diff --git a/library/cpp/yt/string/format-inl.h b/library/cpp/yt/string/format-inl.h
index acaa8f7011..8d0ef4de93 100644
--- a/library/cpp/yt/string/format-inl.h
+++ b/library/cpp/yt/string/format-inl.h
@@ -473,19 +473,19 @@ template <class T, class TPolicy>
void FormatValue(TStringBuilderBase* builder, const TMaybe<T, TPolicy>& value, TStringBuf spec);
// std::optional
-template <class T>
+template <CFormattable T>
void FormatValue(TStringBuilderBase* builder, const std::optional<T>& value, TStringBuf spec);
// std::pair
-template <class A, class B>
+template <CFormattable A, CFormattable B>
void FormatValue(TStringBuilderBase* builder, const std::pair<A, B>& value, TStringBuf spec);
// std::tuple
-template <class... Ts>
+template <CFormattable... Ts>
void FormatValue(TStringBuilderBase* builder, const std::tuple<Ts...>& value, TStringBuf spec);
// TEnumIndexedArray
-template <class E, class T>
+template <class E, CFormattable T>
void FormatValue(TStringBuilderBase* builder, const TEnumIndexedArray<E, T>& collection, TStringBuf spec);
// One-valued ranges
@@ -531,7 +531,7 @@ inline void FormatValue(TStringBuilderBase* builder, std::nullopt_t, TStringBuf
}
// std::optional: generic T
-template <class T>
+template <CFormattable T>
void FormatValue(TStringBuilderBase* builder, const std::optional<T>& value, TStringBuf spec)
{
if (value.has_value()) {
@@ -542,7 +542,7 @@ void FormatValue(TStringBuilderBase* builder, const std::optional<T>& value, TSt
}
// std::pair
-template <class A, class B>
+template <CFormattable A, CFormattable B>
void FormatValue(TStringBuilderBase* builder, const std::pair<A, B>& value, TStringBuf spec)
{
builder->AppendChar('{');
@@ -553,7 +553,7 @@ void FormatValue(TStringBuilderBase* builder, const std::pair<A, B>& value, TStr
}
// std::tuple
-template <class... Ts>
+template <CFormattable... Ts>
void FormatValue(TStringBuilderBase* builder, const std::tuple<Ts...>& value, TStringBuf spec)
{
builder->AppendChar('{');
@@ -571,7 +571,7 @@ void FormatValue(TStringBuilderBase* builder, const std::tuple<Ts...>& value, TS
}
// TEnumIndexedArray
-template <class E, class T>
+template <class E, CFormattable T>
void FormatValue(TStringBuilderBase* builder, const TEnumIndexedArray<E, T>& collection, TStringBuf spec)
{
builder->AppendChar('{');
diff --git a/library/cpp/yt/string/format_arg-inl.h b/library/cpp/yt/string/format_arg-inl.h
index 82a77a1249..e2f08e540d 100644
--- a/library/cpp/yt/string/format_arg-inl.h
+++ b/library/cpp/yt/string/format_arg-inl.h
@@ -27,6 +27,13 @@ constexpr bool IsNYTName()
return qualidName.find("NYT::") == 0;
}
+template <class T>
+constexpr bool IsStdName()
+{
+ constexpr auto qualidName = QualidName<T>();
+ return qualidName.find("std::") == 0;
+}
+
} // namespace NDetail
////////////////////////////////////////////////////////////////////////////////
diff --git a/library/cpp/yt/string/format_arg.h b/library/cpp/yt/string/format_arg.h
index da7d13a19b..6240059ed9 100644
--- a/library/cpp/yt/string/format_arg.h
+++ b/library/cpp/yt/string/format_arg.h
@@ -21,9 +21,6 @@ constexpr std::string_view QualidName();
template <class T>
constexpr bool IsNYTName();
-template <class T>
-concept CYtName = IsNYTName<T>();
-
} // namespace NDetail
////////////////////////////////////////////////////////////////////////////////
diff --git a/library/cpp/yt/string/string_builder-inl.h b/library/cpp/yt/string/string_builder-inl.h
index 683a241c9c..9fb3ae94f8 100644
--- a/library/cpp/yt/string/string_builder-inl.h
+++ b/library/cpp/yt/string/string_builder-inl.h
@@ -118,7 +118,7 @@ inline void TStringBuilder::DoReserve(size_t newLength)
////////////////////////////////////////////////////////////////////////////////
-inline void FormatValue(TStringBuilderBase* builder, const TStringBuilder& value, TStringBuf /*format*/)
+inline void FormatValue(TStringBuilderBase* builder, const TStringBuilder& value, TStringBuf /*spec*/)
{
builder->AppendString(value.GetBuffer());
}
@@ -165,14 +165,17 @@ TString ToStringIgnoringFormatValue(const T& t)
#include <util/string/cast.h>
-// util/string/cast.h extension for yt types only
+// util/string/cast.h extension for yt and std types only
// TODO(arkady-e1ppa): Abolish ::ToString in
// favour of either NYT::ToString or
// automatic formatting wherever it is needed.
namespace NPrivate {
template <class T>
- requires (NYT::NDetail::CYtName<T> && NYT::CFormattable<T>)
+ requires (
+ (NYT::NDetail::IsNYTName<T>() ||
+ NYT::NDetail::IsStdName<T>()) &&
+ NYT::CFormattable<T>)
struct TToString<T, false>
{
static TString Cvt(const T& t)
diff --git a/yt/yt/client/chaos_client/replication_card_cache.cpp b/yt/yt/client/chaos_client/replication_card_cache.cpp
index 543d8f789c..22d1706110 100644
--- a/yt/yt/client/chaos_client/replication_card_cache.cpp
+++ b/yt/yt/client/chaos_client/replication_card_cache.cpp
@@ -28,11 +28,6 @@ void FormatValue(TStringBuilderBase* builder, const TReplicationCardCacheKey& ke
key.FetchOptions);
}
-TString ToString(const TReplicationCardCacheKey& key)
-{
- return ToStringViaBuilder(key);
-}
-
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT::NChaosClient
diff --git a/yt/yt/client/chaos_client/replication_card_cache.h b/yt/yt/client/chaos_client/replication_card_cache.h
index 167bb8fdba..ac75ab752d 100644
--- a/yt/yt/client/chaos_client/replication_card_cache.h
+++ b/yt/yt/client/chaos_client/replication_card_cache.h
@@ -18,7 +18,6 @@ struct TReplicationCardCacheKey
};
void FormatValue(TStringBuilderBase* builder, const TReplicationCardCacheKey& key, TStringBuf /*spec*/);
-TString ToString(const TReplicationCardCacheKey& key);
////////////////////////////////////////////////////////////////////////////////
diff --git a/yt/yt/client/chunk_client/data_statistics.cpp b/yt/yt/client/chunk_client/data_statistics.cpp
index 7e536dd03e..3511c8ccae 100644
--- a/yt/yt/client/chunk_client/data_statistics.cpp
+++ b/yt/yt/client/chunk_client/data_statistics.cpp
@@ -165,11 +165,6 @@ void FormatValue(TStringBuilderBase* builder, const TDataStatistics* statistics,
}
}
-TString ToString(const TDataStatistics& statistics)
-{
- return ToStringViaBuilder(statistics);
-}
-
////////////////////////////////////////////////////////////////////////////////
} // namespace NProto
diff --git a/yt/yt/client/chunk_client/data_statistics.h b/yt/yt/client/chunk_client/data_statistics.h
index 9a9cbed0a3..251a77105f 100644
--- a/yt/yt/client/chunk_client/data_statistics.h
+++ b/yt/yt/client/chunk_client/data_statistics.h
@@ -33,7 +33,6 @@ void SetDataStatisticsField(TDataStatistics& statistics, TStringBuf key, i64 val
void FormatValue(TStringBuilderBase* builder, const TDataStatistics& statistics, TStringBuf spec);
void FormatValue(TStringBuilderBase* builder, const TDataStatistics* statistics, TStringBuf spec);
-TString ToString(const TDataStatistics& statistics);
} // namespace NProto
diff --git a/yt/yt/client/chunk_client/read_limit.cpp b/yt/yt/client/chunk_client/read_limit.cpp
index 3218442a28..5b1156e3c6 100644
--- a/yt/yt/client/chunk_client/read_limit.cpp
+++ b/yt/yt/client/chunk_client/read_limit.cpp
@@ -246,51 +246,40 @@ size_t TLegacyReadLimit::SpaceUsed() const
////////////////////////////////////////////////////////////////////////////////
-TString ToString(const TLegacyReadLimit& limit)
+void FormatValue(TStringBuilderBase* builder, const TLegacyReadLimit& limit, TStringBuf /*spec*/)
{
- using ::ToString;
-
- TStringBuilder builder;
- builder.AppendChar('{');
+ builder->AppendChar('{');
bool firstToken = true;
- auto append = [&] (const char* label, TStringBuf value) {
+ auto append = [&] (const char* label, const auto& value) {
if (!firstToken) {
- builder.AppendString(", ");
+ builder->AppendString(", ");
}
firstToken = false;
- builder.AppendString(label);
- builder.AppendString(": ");
- builder.AppendString(value);
+ builder->AppendFormat("%v: %v", label, value);
};
if (limit.HasLegacyKey()) {
- append("Key", ToString(limit.GetLegacyKey()));
+ append("Key", limit.GetLegacyKey());
}
if (limit.HasRowIndex()) {
- append("RowIndex", ToString(limit.GetRowIndex()));
+ append("RowIndex", limit.GetRowIndex());
}
if (limit.HasOffset()) {
- append("Offset", ToString(limit.GetOffset()));
+ append("Offset", limit.GetOffset());
}
if (limit.HasChunkIndex()) {
- append("ChunkIndex", ToString(limit.GetChunkIndex()));
+ append("ChunkIndex", limit.GetChunkIndex());
}
if (limit.HasTabletIndex()) {
- append("TabletIndex", ToString(limit.GetTabletIndex()));
+ append("TabletIndex", limit.GetTabletIndex());
}
- builder.AppendChar('}');
- return builder.Flush();
-}
-
-void FormatValue(TStringBuilderBase* builder, const TLegacyReadLimit& limit, TStringBuf spec)
-{
- FormatValue(builder, ToString(limit), spec);
+ builder->AppendChar('}');
}
bool IsTrivial(const TLegacyReadLimit& limit)
@@ -688,51 +677,40 @@ bool TReadLimit::operator == (const TReadLimit& other) const
////////////////////////////////////////////////////////////////////////////////
-TString ToString(const TReadLimit& readLimit)
+void FormatValue(TStringBuilderBase* builder, const TReadLimit& readLimit, TStringBuf /*spec*/)
{
- using ::ToString;
-
- TStringBuilder builder;
- builder.AppendChar('{');
+ builder->AppendChar('{');
bool firstToken = true;
- auto append = [&] (const char* label, TStringBuf value) {
+ auto append = [&] (const char* label, const auto& value) {
if (!firstToken) {
- builder.AppendString(", ");
+ builder->AppendString(", ");
}
firstToken = false;
- builder.AppendString(label);
- builder.AppendString(": ");
- builder.AppendString(value);
+ builder->AppendFormat("%v: %v", label, value);
};
if (readLimit.KeyBound()) {
- append("Key", ToString(readLimit.KeyBound()));
+ append("Key", readLimit.KeyBound());
}
if (readLimit.GetRowIndex()) {
- append("RowIndex", ToString(readLimit.GetRowIndex()));
+ append("RowIndex", readLimit.GetRowIndex());
}
if (readLimit.GetOffset()) {
- append("Offset", ToString(readLimit.GetOffset()));
+ append("Offset", readLimit.GetOffset());
}
if (readLimit.GetChunkIndex()) {
- append("ChunkIndex", ToString(readLimit.GetChunkIndex()));
+ append("ChunkIndex", readLimit.GetChunkIndex());
}
if (readLimit.GetTabletIndex()) {
- append("TabletIndex", ToString(readLimit.GetTabletIndex()));
+ append("TabletIndex", readLimit.GetTabletIndex());
}
- builder.AppendChar('}');
- return builder.Flush();
-}
-
-void FormatValue(TStringBuilderBase* builder, const TReadLimit& readLimit, TStringBuf spec)
-{
- FormatValue(builder, ToString(readLimit), spec);
+ builder->AppendChar('}');
}
void ToProto(NProto::TReadLimit* protoReadLimit, const TReadLimit& readLimit)
diff --git a/yt/yt/client/chunk_client/read_limit.h b/yt/yt/client/chunk_client/read_limit.h
index 5faa08a654..07474b880b 100644
--- a/yt/yt/client/chunk_client/read_limit.h
+++ b/yt/yt/client/chunk_client/read_limit.h
@@ -80,7 +80,6 @@ private:
////////////////////////////////////////////////////////////////////////////////
-TString ToString(const TLegacyReadLimit& limit);
void FormatValue(TStringBuilderBase* builder, const TLegacyReadLimit& limit, TStringBuf spec);
bool IsTrivial(const TLegacyReadLimit& limit);
@@ -180,7 +179,6 @@ public:
////////////////////////////////////////////////////////////////////////////////
-TString ToString(const TReadLimit& readLimit);
void FormatValue(TStringBuilderBase* builder, const TReadLimit& readLimit, TStringBuf spec);
void ToProto(NProto::TReadLimit* protoReadLimit, const TReadLimit& readLimit);
diff --git a/yt/yt/client/driver/helpers.cpp b/yt/yt/client/driver/helpers.cpp
index 007fba71e8..9ccf3675c2 100644
--- a/yt/yt/client/driver/helpers.cpp
+++ b/yt/yt/client/driver/helpers.cpp
@@ -44,9 +44,9 @@ TErrorOr<TEtag> ParseEtag(TStringBuf etagString)
return result;
}
-TString ToString(const TEtag& Etag)
+void FormatValue(TStringBuilderBase* builder, const TEtag& tag, TStringBuf /*spec*/)
{
- return Format("%v:%v", Etag.Id, Etag.Revision);
+ builder->AppendFormat("%v:%v", tag.Id, tag.Revision);
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/yt/yt/client/driver/helpers.h b/yt/yt/client/driver/helpers.h
index b10b9bd543..dca1a54e62 100644
--- a/yt/yt/client/driver/helpers.h
+++ b/yt/yt/client/driver/helpers.h
@@ -20,7 +20,7 @@ struct TEtag
bool operator==(const TEtag& lhs, const TEtag& rhs);
TErrorOr<TEtag> ParseEtag(TStringBuf etagString);
-TString ToString(const TEtag& Etag);
+void FormatValue(TStringBuilderBase* builder, const TEtag& tag, TStringBuf spec);
////////////////////////////////////////////////////////////////////////////////
diff --git a/yt/yt/client/driver/proxy_discovery_cache.cpp b/yt/yt/client/driver/proxy_discovery_cache.cpp
index 6d98deb970..772f526231 100644
--- a/yt/yt/client/driver/proxy_discovery_cache.cpp
+++ b/yt/yt/client/driver/proxy_discovery_cache.cpp
@@ -45,11 +45,6 @@ void FormatValue(TStringBuilderBase* builder, const TProxyDiscoveryRequest& requ
request.IgnoreBalancers);
}
-TString ToString(const TProxyDiscoveryRequest& request)
-{
- return ToStringViaBuilder(request);
-}
-
////////////////////////////////////////////////////////////////////////////////
class TProxyDiscoveryCache
diff --git a/yt/yt/client/driver/proxy_discovery_cache.h b/yt/yt/client/driver/proxy_discovery_cache.h
index 6dfb29c053..7b5871d1d4 100644
--- a/yt/yt/client/driver/proxy_discovery_cache.h
+++ b/yt/yt/client/driver/proxy_discovery_cache.h
@@ -26,7 +26,6 @@ struct TProxyDiscoveryRequest
};
void FormatValue(TStringBuilderBase* builder, const TProxyDiscoveryRequest& request, TStringBuf spec);
-TString ToString(const TProxyDiscoveryRequest& request);
////////////////////////////////////////////////////////////////////////////////
diff --git a/yt/yt/client/hydra/version.cpp b/yt/yt/client/hydra/version.cpp
index 904f090db6..782ece82e5 100644
--- a/yt/yt/client/hydra/version.cpp
+++ b/yt/yt/client/hydra/version.cpp
@@ -24,11 +24,6 @@ void FormatValue(TStringBuilderBase* builder, TReachableState state, TStringBuf
builder->AppendFormat("%v:%v", state.SegmentId, state.SequenceNumber);
}
-TString ToString(TReachableState state)
-{
- return ToStringViaBuilder(state);
-}
-
////////////////////////////////////////////////////////////////////////////////
TElectionPriority::TElectionPriority(int lastMutationTerm, int segmentId, i64 sequenceNumber) noexcept
@@ -56,11 +51,6 @@ void FormatValue(TStringBuilderBase* builder, TElectionPriority priority, TStrin
priority.ReachableState);
}
-TString ToString(TElectionPriority state)
-{
- return ToStringViaBuilder(state);
-}
-
////////////////////////////////////////////////////////////////////////////////
TVersion::TVersion(int segmentId, int recordId) noexcept
@@ -102,11 +92,6 @@ void FormatValue(TStringBuilderBase* builder, TVersion version, TStringBuf /* sp
builder->AppendFormat("%v:%v", version.SegmentId, version.RecordId);
}
-TString ToString(TVersion version)
-{
- return ToStringViaBuilder(version);
-}
-
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT::NHydra
diff --git a/yt/yt/client/hydra/version.h b/yt/yt/client/hydra/version.h
index 4ef7bfc7f5..79e60dff44 100644
--- a/yt/yt/client/hydra/version.h
+++ b/yt/yt/client/hydra/version.h
@@ -21,7 +21,6 @@ struct TReachableState
};
void FormatValue(TStringBuilderBase* builder, TReachableState state, TStringBuf /*spec*/);
-TString ToString(TReachableState state);
////////////////////////////////////////////////////////////////////////////////
@@ -48,7 +47,6 @@ struct TElectionPriority
};
void FormatValue(TStringBuilderBase* builder, TElectionPriority state, TStringBuf /*spec*/);
-TString ToString(TElectionPriority state);
////////////////////////////////////////////////////////////////////////////////
@@ -71,7 +69,6 @@ struct TVersion
};
void FormatValue(TStringBuilderBase* builder, TVersion version, TStringBuf spec);
-TString ToString(TVersion version);
////////////////////////////////////////////////////////////////////////////////
diff --git a/yt/yt/client/misc/workload.cpp b/yt/yt/client/misc/workload.cpp
index 7882062ff5..4bc605f0f8 100644
--- a/yt/yt/client/misc/workload.cpp
+++ b/yt/yt/client/misc/workload.cpp
@@ -157,7 +157,7 @@ void FromProto(TWorkloadDescriptor* descriptor, const NYT::NProto::TWorkloadDesc
void FormatValue(
TStringBuilderBase* builder,
const TWorkloadDescriptor& descriptor,
- TStringBuf /*format*/)
+ TStringBuf /*spec*/)
{
builder->AppendFormat("%v:%v",
descriptor.Category,
@@ -178,11 +178,6 @@ void FormatValue(
}
}
-TString ToString(const TWorkloadDescriptor& descriptor)
-{
- return ToStringViaBuilder(descriptor);
-}
-
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT
diff --git a/yt/yt/client/misc/workload.h b/yt/yt/client/misc/workload.h
index 4fa95201e9..99a8bd1d5e 100644
--- a/yt/yt/client/misc/workload.h
+++ b/yt/yt/client/misc/workload.h
@@ -58,8 +58,7 @@ IInvokerPtr GetCompressionInvoker(const TWorkloadDescriptor& workloadDescriptor)
void FormatValue(
TStringBuilderBase* builder,
const TWorkloadDescriptor& descriptor,
- TStringBuf format);
-TString ToString(const TWorkloadDescriptor& descriptor);
+ TStringBuf spec);
void ToProto(NYT::NProto::TWorkloadDescriptor* protoDescriptor, const TWorkloadDescriptor& descriptor);
void FromProto(TWorkloadDescriptor* descriptor, const NYT::NProto::TWorkloadDescriptor& protoDescriptor);
diff --git a/yt/yt/client/node_tracker_client/helpers.cpp b/yt/yt/client/node_tracker_client/helpers.cpp
index 6f9d7b5365..2fd52e8ead 100644
--- a/yt/yt/client/node_tracker_client/helpers.cpp
+++ b/yt/yt/client/node_tracker_client/helpers.cpp
@@ -31,11 +31,6 @@ void FormatValue(TStringBuilderBase* builder, const TDiskLocationResources& loca
locationResources.medium_index());
}
-TString ToString(const TDiskLocationResources& locationResources)
-{
- return ToStringViaBuilder(locationResources);
-}
-
void FormatValue(TStringBuilderBase* builder, const TDiskResources& diskResources, TStringBuf /*spec*/)
{
builder->AppendFormat(
@@ -45,11 +40,6 @@ void FormatValue(TStringBuilderBase* builder, const TDiskResources& diskResource
}));
}
-TString ToString(const TDiskResources& diskResources)
-{
- return ToStringViaBuilder(diskResources);
-}
-
} // namespace NProto
////////////////////////////////////////////////////////////////////////////////
diff --git a/yt/yt/client/node_tracker_client/helpers.h b/yt/yt/client/node_tracker_client/helpers.h
index 43e17db4d6..888bc839a9 100644
--- a/yt/yt/client/node_tracker_client/helpers.h
+++ b/yt/yt/client/node_tracker_client/helpers.h
@@ -17,10 +17,8 @@ NYPath::TYPath GetExecNodesPath();
namespace NProto {
void FormatValue(TStringBuilderBase* builder, const TDiskLocationResources& locationResources, TStringBuf spec);
-TString ToString(const TDiskLocationResources& locationResources);
void FormatValue(TStringBuilderBase* builder, const TDiskResources& diskResources, TStringBuf spec);
-TString ToString(const TDiskResources& diskResources);
} // namespace NProto
diff --git a/yt/yt/client/node_tracker_client/node_directory.cpp b/yt/yt/client/node_tracker_client/node_directory.cpp
index 84b2a1d6ec..52e873447c 100644
--- a/yt/yt/client/node_tracker_client/node_directory.cpp
+++ b/yt/yt/client/node_tracker_client/node_directory.cpp
@@ -203,11 +203,6 @@ void FormatValue(TStringBuilderBase* builder, const TNodeDescriptor& descriptor,
}
}
-TString ToString(const TNodeDescriptor& descriptor)
-{
- return ToStringViaBuilder(descriptor);
-}
-
std::optional<TString> FindDefaultAddress(const TAddressMap& addresses)
{
if (addresses.empty()) {
diff --git a/yt/yt/client/node_tracker_client/node_directory.h b/yt/yt/client/node_tracker_client/node_directory.h
index 8e92564179..847018b2f5 100644
--- a/yt/yt/client/node_tracker_client/node_directory.h
+++ b/yt/yt/client/node_tracker_client/node_directory.h
@@ -88,7 +88,6 @@ bool operator == (const TNodeDescriptor& lhs, const TNodeDescriptor& rhs);
bool operator == (const TNodeDescriptor& lhs, const NProto::TNodeDescriptor& rhs);
void FormatValue(TStringBuilderBase* builder, const TNodeDescriptor& descriptor, TStringBuf spec);
-TString ToString(const TNodeDescriptor& descriptor);
// Accessors for some well-known addresses.
std::optional<TString> FindDefaultAddress(const TAddressMap& addresses);
diff --git a/yt/yt/client/object_client/public.cpp b/yt/yt/client/object_client/public.cpp
index 11eb2f1a6b..958a266120 100644
--- a/yt/yt/client/object_client/public.cpp
+++ b/yt/yt/client/object_client/public.cpp
@@ -42,11 +42,6 @@ void FormatValue(TStringBuilderBase* builder, const TVersionedObjectId& id, TStr
builder->AppendFormat("%v:%v", id.ObjectId, id.TransactionId);
}
-TString ToString(const TVersionedObjectId& id)
-{
- return ToStringViaBuilder(id);
-}
-
bool operator == (const TVersionedObjectId& lhs, const TVersionedObjectId& rhs)
{
return memcmp(&lhs, &rhs, sizeof (TVersionedObjectId)) == 0;
diff --git a/yt/yt/client/object_client/public.h b/yt/yt/client/object_client/public.h
index dc838bdabc..3e755b4d8b 100644
--- a/yt/yt/client/object_client/public.h
+++ b/yt/yt/client/object_client/public.h
@@ -399,9 +399,6 @@ struct TVersionedObjectId
//! Formats id into a string (for debugging and logging purposes mainly).
void FormatValue(TStringBuilderBase* builder, const TVersionedObjectId& id, TStringBuf spec);
-//! Converts id into a string (for debugging and logging purposes mainly).
-TString ToString(const TVersionedObjectId& id);
-
//! Compares TVersionedNodeId s for equality.
bool operator == (const TVersionedObjectId& lhs, const TVersionedObjectId& rhs);
diff --git a/yt/yt/client/scheduler/operation_id_or_alias.cpp b/yt/yt/client/scheduler/operation_id_or_alias.cpp
index 5711c11c69..8e446ec20e 100644
--- a/yt/yt/client/scheduler/operation_id_or_alias.cpp
+++ b/yt/yt/client/scheduler/operation_id_or_alias.cpp
@@ -28,7 +28,7 @@ TOperationIdOrAlias TOperationIdOrAlias::FromString(TString operationIdOrAlias)
}
}
-void FormatValue(TStringBuilderBase* builder, const TOperationIdOrAlias& operationIdOrAlias, TStringBuf /*format*/)
+void FormatValue(TStringBuilderBase* builder, const TOperationIdOrAlias& operationIdOrAlias, TStringBuf /*spec*/)
{
Visit(operationIdOrAlias.Payload,
[&] (const TString& alias) {
@@ -39,11 +39,6 @@ void FormatValue(TStringBuilderBase* builder, const TOperationIdOrAlias& operati
});
}
-TString ToString(const TOperationIdOrAlias& operationIdOrAlias)
-{
- return ToStringViaBuilder(operationIdOrAlias);
-}
-
TOperationIdOrAlias::operator size_t() const
{
size_t result = 0;
diff --git a/yt/yt/client/scheduler/operation_id_or_alias.h b/yt/yt/client/scheduler/operation_id_or_alias.h
index db1d7bf956..96ceaedb69 100644
--- a/yt/yt/client/scheduler/operation_id_or_alias.h
+++ b/yt/yt/client/scheduler/operation_id_or_alias.h
@@ -26,8 +26,7 @@ struct TOperationIdOrAlias
operator size_t() const;
};
-void FormatValue(TStringBuilderBase* builder, const TOperationIdOrAlias& operationIdOrAlias, TStringBuf format);
-TString ToString(const TOperationIdOrAlias& operationIdOrAlias);
+void FormatValue(TStringBuilderBase* builder, const TOperationIdOrAlias& operationIdOrAlias, TStringBuf spec);
// NB: TOperationIdOrAlias corresponds to a oneof group of fields in proto representation,
// so we use an enclosing proto message object to properly serialize or deserialize it.
diff --git a/yt/yt/client/table_client/column_sort_schema.cpp b/yt/yt/client/table_client/column_sort_schema.cpp
index f2263b2a56..964f7549a4 100644
--- a/yt/yt/client/table_client/column_sort_schema.cpp
+++ b/yt/yt/client/table_client/column_sort_schema.cpp
@@ -97,18 +97,13 @@ void FromProto(
}
}
-void FormatValue(TStringBuilderBase* builder, const TSortColumns& sortColumns, TStringBuf /* format */)
+void FormatValue(TStringBuilderBase* builder, const TSortColumns& sortColumns, TStringBuf /* spec */)
{
builder->AppendFormat("{ColumnNames: %v, Comparator: %v}",
GetColumnNames(sortColumns),
GetComparator(sortColumns));
}
-TString ToString(const TSortColumns& sortColumns)
-{
- return ToStringViaBuilder(sortColumns);
-}
-
////////////////////////////////////////////////////////////////////////////////
TKeyColumns GetColumnNames(const TSortColumns& sortColumns)
diff --git a/yt/yt/client/table_client/column_sort_schema.h b/yt/yt/client/table_client/column_sort_schema.h
index ed7830d779..70a8b62596 100644
--- a/yt/yt/client/table_client/column_sort_schema.h
+++ b/yt/yt/client/table_client/column_sort_schema.h
@@ -35,8 +35,7 @@ void FromProto(
TSortColumns* sortColumns,
const NProto::TSortColumnsExt& protoSortColumns);
-void FormatValue(TStringBuilderBase* builder, const TSortColumns& key, TStringBuf format);
-TString ToString(const TSortColumns& key);
+void FormatValue(TStringBuilderBase* builder, const TSortColumns& key, TStringBuf spec);
////////////////////////////////////////////////////////////////////////////////
diff --git a/yt/yt/client/table_client/comparator.cpp b/yt/yt/client/table_client/comparator.cpp
index 0d215415fe..bd0d980d87 100644
--- a/yt/yt/client/table_client/comparator.cpp
+++ b/yt/yt/client/table_client/comparator.cpp
@@ -336,11 +336,6 @@ void FormatValue(TStringBuilderBase* builder, const TComparator& comparator, TSt
builder->AppendChar('}');
}
-TString ToString(const TComparator& comparator)
-{
- return ToStringViaBuilder(comparator);
-}
-
void Serialize(const TComparator& comparator, IYsonConsumer* consumer)
{
BuildYsonFluently(consumer)
diff --git a/yt/yt/client/table_client/comparator.h b/yt/yt/client/table_client/comparator.h
index b272c6569e..5221cec3e9 100644
--- a/yt/yt/client/table_client/comparator.h
+++ b/yt/yt/client/table_client/comparator.h
@@ -94,7 +94,6 @@ private:
};
void FormatValue(TStringBuilderBase* builder, const TComparator& comparator, TStringBuf spec);
-TString ToString(const TComparator& comparator);
void Serialize(const TComparator& comparator, NYson::IYsonConsumer* consumer);
diff --git a/yt/yt/client/table_client/key.cpp b/yt/yt/client/table_client/key.cpp
index e2a7f67d44..984dc7d592 100644
--- a/yt/yt/client/table_client/key.cpp
+++ b/yt/yt/client/table_client/key.cpp
@@ -125,7 +125,7 @@ bool operator==(const TKey& lhs, const TKey& rhs)
return CompareValueRanges(lhs.Elements(), rhs.Elements()) == 0;
}
-void FormatValue(TStringBuilderBase* builder, const TKey& key, TStringBuf /*format*/)
+void FormatValue(TStringBuilderBase* builder, const TKey& key, TStringBuf /*spec*/)
{
if (key) {
builder->AppendFormat("[%v]", JoinToString(key.Begin(), key.End()));
@@ -134,11 +134,6 @@ void FormatValue(TStringBuilderBase* builder, const TKey& key, TStringBuf /*form
}
}
-TString ToString(const TKey& key)
-{
- return ToStringViaBuilder(key);
-}
-
void Serialize(const TKey& key, IYsonConsumer* consumer)
{
if (key) {
diff --git a/yt/yt/client/table_client/key.h b/yt/yt/client/table_client/key.h
index 9fbca56154..9ebc581120 100644
--- a/yt/yt/client/table_client/key.h
+++ b/yt/yt/client/table_client/key.h
@@ -50,8 +50,7 @@ private:
bool operator==(const TKey& lhs, const TKey& rhs);
-void FormatValue(TStringBuilderBase* builder, const TKey& key, TStringBuf format);
-TString ToString(const TKey& key);
+void FormatValue(TStringBuilderBase* builder, const TKey& key, TStringBuf spec);
void Serialize(const TKey& key, NYson::IYsonConsumer* consumer);
diff --git a/yt/yt/client/table_client/key_bound.cpp b/yt/yt/client/table_client/key_bound.cpp
index a4612c0df1..3274df5ce2 100644
--- a/yt/yt/client/table_client/key_bound.cpp
+++ b/yt/yt/client/table_client/key_bound.cpp
@@ -251,16 +251,11 @@ TOwningKeyBound::operator TKeyBound() const
return result;
}
-void FormatValue(TStringBuilderBase* builder, const TOwningKeyBound& keyBound, TStringBuf /*format*/)
+void FormatValue(TStringBuilderBase* builder, const TOwningKeyBound& keyBound, TStringBuf /*spec*/)
{
return keyBound.FormatValue(builder);
}
-TString ToString(const TOwningKeyBound& keyBound)
-{
- return ToStringViaBuilder(keyBound);
-}
-
void PrintTo(const TOwningKeyBound& keyBound, ::std::ostream* os)
{
*os << ToString(keyBound);
@@ -282,16 +277,11 @@ TOwningKeyBound TKeyBound::ToOwning() const
return result;
}
-void FormatValue(TStringBuilderBase* builder, const TKeyBound& keyBound, TStringBuf /*format*/)
+void FormatValue(TStringBuilderBase* builder, const TKeyBound& keyBound, TStringBuf /*spec*/)
{
return keyBound.FormatValue(builder);
}
-TString ToString(const TKeyBound& keyBound)
-{
- return ToStringViaBuilder(keyBound);
-}
-
void PrintTo(const TKeyBound& keyBound, ::std::ostream* os)
{
*os << ToString(keyBound);
diff --git a/yt/yt/client/table_client/key_bound.h b/yt/yt/client/table_client/key_bound.h
index cad65bc5dd..e37c695e7e 100644
--- a/yt/yt/client/table_client/key_bound.h
+++ b/yt/yt/client/table_client/key_bound.h
@@ -119,8 +119,7 @@ public:
TOwningKeyBound ToOwning() const;
};
-void FormatValue(TStringBuilderBase* builder, const TKeyBound& keyBound, TStringBuf format);
-TString ToString(const TKeyBound& keyBound);
+void FormatValue(TStringBuilderBase* builder, const TKeyBound& keyBound, TStringBuf spec);
void Serialize(const TKeyBound& keyBound, NYson::IYsonConsumer* consumer);
@@ -133,8 +132,7 @@ public:
operator TKeyBound() const;
};
-void FormatValue(TStringBuilderBase* builder, const TOwningKeyBound& keyBound, TStringBuf format);
-TString ToString(const TOwningKeyBound& keyBound);
+void FormatValue(TStringBuilderBase* builder, const TOwningKeyBound& keyBound, TStringBuf spec);
void Serialize(const TOwningKeyBound& keyBound, NYson::IYsonConsumer* consumer);
void Deserialize(TOwningKeyBound& keyBound, const NYTree::INodePtr& node);
diff --git a/yt/yt/client/table_client/versioned_row.cpp b/yt/yt/client/table_client/versioned_row.cpp
index 0be4e4d08b..d28b98b33a 100644
--- a/yt/yt/client/table_client/versioned_row.cpp
+++ b/yt/yt/client/table_client/versioned_row.cpp
@@ -443,7 +443,7 @@ void FormatValue(TStringBuilderBase* builder, const TVersionedValue& value, TStr
value.Timestamp);
}
-void FormatValue(TStringBuilderBase* builder, TVersionedRow row, TStringBuf /*format*/)
+void FormatValue(TStringBuilderBase* builder, const TVersionedRow& row, TStringBuf /*format*/)
{
if (!row) {
builder->AppendString("<null>");
@@ -479,34 +479,14 @@ void FormatValue(TStringBuilderBase* builder, TVersionedRow row, TStringBuf /*fo
builder->AppendChar(']');
}
-void FormatValue(TStringBuilderBase* builder, TMutableVersionedRow row, TStringBuf /*format*/)
+void FormatValue(TStringBuilderBase* builder, const TMutableVersionedRow& row, TStringBuf /*spec*/)
{
- FormatValue(builder, TVersionedRow(row), {});
+ FormatValue(builder, TVersionedRow(row), TStringBuf{"v"});
}
-void FormatValue(TStringBuilderBase* builder, TVersionedOwningRow row, TStringBuf /*format*/)
+void FormatValue(TStringBuilderBase* builder, const TVersionedOwningRow& row, TStringBuf /*spec*/)
{
- FormatValue(builder, TVersionedRow(row), {});
-}
-
-TString ToString(const TVersionedValue& value)
-{
- return ToStringViaBuilder(value);
-}
-
-TString ToString(TVersionedRow row)
-{
- return ToStringViaBuilder(row);
-}
-
-TString ToString(TMutableVersionedRow row)
-{
- return ToString(TVersionedRow(row));
-}
-
-TString ToString(const TVersionedOwningRow& row)
-{
- return ToString(row.Get());
+ FormatValue(builder, TVersionedRow(row), TStringBuf{"v"});
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/yt/yt/client/table_client/versioned_row.h b/yt/yt/client/table_client/versioned_row.h
index 8d72048d0c..3ae88b5839 100644
--- a/yt/yt/client/table_client/versioned_row.h
+++ b/yt/yt/client/table_client/versioned_row.h
@@ -626,15 +626,10 @@ private:
////////////////////////////////////////////////////////////////////////////////
-void FormatValue(TStringBuilderBase* builder, const TVersionedValue& value, TStringBuf format);
-void FormatValue(TStringBuilderBase* builder, TVersionedRow row, TStringBuf format);
-void FormatValue(TStringBuilderBase* builder, TMutableVersionedRow row, TStringBuf format);
-void FormatValue(TStringBuilderBase* builder, const TVersionedOwningRow& row, TStringBuf format);
-
-TString ToString(const TVersionedValue& value);
-TString ToString(TVersionedRow row);
-TString ToString(TMutableVersionedRow row);
-TString ToString(const TVersionedOwningRow& row);
+void FormatValue(TStringBuilderBase* builder, const TVersionedValue& value, TStringBuf spec);
+void FormatValue(TStringBuilderBase* builder, const TVersionedRow& row, TStringBuf spec);
+void FormatValue(TStringBuilderBase* builder, const TMutableVersionedRow& row, TStringBuf spec);
+void FormatValue(TStringBuilderBase* builder, const TVersionedOwningRow& row, TStringBuf spec);
////////////////////////////////////////////////////////////////////////////////
diff --git a/yt/yt/client/ypath/rich.cpp b/yt/yt/client/ypath/rich.cpp
index a41e34961a..0b87501ba9 100644
--- a/yt/yt/client/ypath/rich.cpp
+++ b/yt/yt/client/ypath/rich.cpp
@@ -689,15 +689,10 @@ TString ConvertToString(const TRichYPath& path, EYsonFormat ysonFormat)
return builder.Flush();
}
-TString ToString(const TRichYPath& path)
-{
- // NB: we intentionally use Text format since string-representation of rich ypath should be readable.
- return ConvertToString(path, EYsonFormat::Text);
-}
-
void FormatValue(TStringBuilderBase* builder, const TRichYPath& path, TStringBuf spec)
{
- FormatValue(builder, ToString(path), spec);
+ // NB: we intentionally use Text format since string-representation of rich ypath should be readable.
+ FormatValue(builder, ConvertToString(path, EYsonFormat::Text), spec);
}
std::vector<TRichYPath> Normalize(const std::vector<TRichYPath>& paths)
diff --git a/yt/yt/client/ypath/rich.h b/yt/yt/client/ypath/rich.h
index e1dc440db9..1659532208 100644
--- a/yt/yt/client/ypath/rich.h
+++ b/yt/yt/client/ypath/rich.h
@@ -176,7 +176,6 @@ bool operator== (const TRichYPath& lhs, const TRichYPath& rhs);
////////////////////////////////////////////////////////////////////////////////
-TString ToString(const TRichYPath& path);
void FormatValue(TStringBuilderBase* builder, const TRichYPath& path, TStringBuf spec);
std::vector<TRichYPath> Normalize(const std::vector<TRichYPath>& paths);
diff --git a/yt/yt/core/dns/dns_resolver.cpp b/yt/yt/core/dns/dns_resolver.cpp
index f12d4cf117..afbd435a24 100644
--- a/yt/yt/core/dns/dns_resolver.cpp
+++ b/yt/yt/core/dns/dns_resolver.cpp
@@ -11,11 +11,6 @@ void FormatValue(TStringBuilderBase* builder, const TDnsResolveOptions options,
options.EnableIPv6);
}
-TString ToString(const TDnsResolveOptions& options)
-{
- return ToStringViaBuilder(options);
-}
-
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT::NDns
diff --git a/yt/yt/core/dns/dns_resolver.h b/yt/yt/core/dns/dns_resolver.h
index 46ed2f76ab..c19ab9e66d 100644
--- a/yt/yt/core/dns/dns_resolver.h
+++ b/yt/yt/core/dns/dns_resolver.h
@@ -17,7 +17,6 @@ struct TDnsResolveOptions
};
void FormatValue(TStringBuilderBase* builder, const TDnsResolveOptions options, TStringBuf spec);
-TString ToString(const TDnsResolveOptions& options);
////////////////////////////////////////////////////////////////////////////////
diff --git a/yt/yt/core/misc/arithmetic_formula.cpp b/yt/yt/core/misc/arithmetic_formula.cpp
index f1ed44e43f..345bc341c6 100644
--- a/yt/yt/core/misc/arithmetic_formula.cpp
+++ b/yt/yt/core/misc/arithmetic_formula.cpp
@@ -907,12 +907,7 @@ void Deserialize(TBooleanFormulaTags& tags, NYTree::INodePtr node)
tags = TBooleanFormulaTags(ConvertTo<THashSet<TString>>(node));
}
-TString ToString(const TBooleanFormulaTags& tags)
-{
- return ToStringViaBuilder(tags);
-}
-
-void FormatValue(TStringBuilderBase* builder, const TBooleanFormulaTags& tags, TStringBuf /*format*/)
+void FormatValue(TStringBuilderBase* builder, const TBooleanFormulaTags& tags, TStringBuf /*spec*/)
{
builder->AppendFormat("%v", tags.GetSourceTags());
}
@@ -1041,12 +1036,7 @@ void TBooleanFormula::Load(TStreamLoadContext& context)
Impl_ = MakeGenericFormulaImpl(formula, EEvaluationContext::Boolean);
}
-TString ToString(const TBooleanFormula& booleanFormula)
-{
- return ToStringViaBuilder(booleanFormula);
-}
-
-void FormatValue(TStringBuilderBase* builder, const TBooleanFormula& booleanFormula, TStringBuf /*format*/)
+void FormatValue(TStringBuilderBase* builder, const TBooleanFormula& booleanFormula, TStringBuf /*spec*/)
{
builder->AppendFormat("%v", booleanFormula.GetFormula());
}
diff --git a/yt/yt/core/misc/arithmetic_formula.h b/yt/yt/core/misc/arithmetic_formula.h
index ab0242acb4..ddc15d9def 100644
--- a/yt/yt/core/misc/arithmetic_formula.h
+++ b/yt/yt/core/misc/arithmetic_formula.h
@@ -97,8 +97,7 @@ private:
void Serialize(const TBooleanFormulaTags& tags, NYson::IYsonConsumer* consumer);
void Deserialize(TBooleanFormulaTags& tags, NYTree::INodePtr node);
-TString ToString(const TBooleanFormulaTags& tags);
-void FormatValue(TStringBuilderBase* builder, const TBooleanFormulaTags& tags, TStringBuf /*format*/);
+void FormatValue(TStringBuilderBase* builder, const TBooleanFormulaTags& tags, TStringBuf /*spec*/);
////////////////////////////////////////////////////////////////////////////////
@@ -154,8 +153,7 @@ void Serialize(const TBooleanFormula& booleanFormula, NYson::IYsonConsumer* cons
void Deserialize(TBooleanFormula& booleanFormula, NYTree::INodePtr node);
void Deserialize(TBooleanFormula& booleanFormula, NYson::TYsonPullParserCursor* cursor);
-TString ToString(const TBooleanFormula& booleanFormula);
-void FormatValue(TStringBuilderBase* builder, const TBooleanFormula& booleanFormula, TStringBuf /*format*/);
+void FormatValue(TStringBuilderBase* builder, const TBooleanFormula& booleanFormula, TStringBuf /*spec*/);
////////////////////////////////////////////////////////////////////////////////
diff --git a/yt/yt/core/misc/error-inl.h b/yt/yt/core/misc/error-inl.h
index 79dc4108f9..df5afad615 100644
--- a/yt/yt/core/misc/error-inl.h
+++ b/yt/yt/core/misc/error-inl.h
@@ -316,12 +316,6 @@ void FormatValue(TStringBuilderBase* builder, const TErrorOr<T>& error, TStringB
FormatValue(builder, static_cast<const TError&>(error), spec);
}
-template <class T>
-TString ToString(const TErrorOr<T>& valueOrError)
-{
- return ToString(TError(valueOrError));
-}
-
////////////////////////////////////////////////////////////////////////////////
template <class TException>
diff --git a/yt/yt/core/misc/error.cpp b/yt/yt/core/misc/error.cpp
index 788ac0c020..2e63016b86 100644
--- a/yt/yt/core/misc/error.cpp
+++ b/yt/yt/core/misc/error.cpp
@@ -64,11 +64,6 @@ void FormatValue(TStringBuilderBase* builder, TErrorCode code, TStringBuf spec)
FormatValue(builder, static_cast<int>(code), spec);
}
-TString ToString(TErrorCode code)
-{
- return ToStringViaBuilder(code);
-}
-
////////////////////////////////////////////////////////////////////////////////
YT_DEFINE_THREAD_LOCAL(bool, ErrorSanitizerEnabled, false);
@@ -1081,13 +1076,6 @@ void FormatValue(TStringBuilderBase* builder, const TError& error, TStringBuf /*
AppendError(builder, error, 0);
}
-TString ToString(const TError& error)
-{
- TStringBuilder builder;
- AppendError(&builder, error, 0);
- return builder.Flush();
-}
-
void ToProto(NYT::NProto::TError* protoError, const TError& error)
{
if (!error.Impl_) {
diff --git a/yt/yt/core/misc/error.h b/yt/yt/core/misc/error.h
index 8d69a120ac..0fb97e5c81 100644
--- a/yt/yt/core/misc/error.h
+++ b/yt/yt/core/misc/error.h
@@ -62,7 +62,6 @@ private:
};
void FormatValue(TStringBuilderBase* builder, TErrorCode code, TStringBuf spec);
-TString ToString(TErrorCode code);
////////////////////////////////////////////////////////////////////////////////
@@ -281,7 +280,6 @@ void Deserialize(
const NYTree::INodePtr& node);
void FormatValue(TStringBuilderBase* builder, const TError& error, TStringBuf spec);
-TString ToString(const TError& error);
////////////////////////////////////////////////////////////////////////////////
@@ -428,9 +426,6 @@ private:
template <class T>
void FormatValue(TStringBuilderBase* builder, const TErrorOr<T>& error, TStringBuf spec);
-template <class T>
-TString ToString(const TErrorOr<T>& valueOrError);
-
////////////////////////////////////////////////////////////////////////////////
template <class F, class... As>
diff --git a/yt/yt/core/misc/maybe_inf-inl.h b/yt/yt/core/misc/maybe_inf-inl.h
index cb8c46ea5c..cd8b98c91d 100644
--- a/yt/yt/core/misc/maybe_inf-inl.h
+++ b/yt/yt/core/misc/maybe_inf-inl.h
@@ -114,23 +114,15 @@ T TMaybeInf<T>::UnsafeToUnderlying() const noexcept
////////////////////////////////////////////////////////////////////////////////
template <class T>
-void FormatValue(TStringBuilderBase* builder, TMaybeInf<T> value, TStringBuf format)
+void FormatValue(TStringBuilderBase* builder, TMaybeInf<T> value, TStringBuf spec)
{
if (value.IsFinite()) {
- FormatValue(builder, value.ToUnderlying(), format);
+ FormatValue(builder, value.ToUnderlying(), spec);
} else {
- FormatValue(builder, "inf", format);
+ FormatValue(builder, "inf", spec);
}
}
-template <class T>
-TString ToString(TMaybeInf<T> value)
-{
- TStringBuilder builder;
- FormatValue(&builder, value);
- return builder.Flush();
-}
-
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT
diff --git a/yt/yt/core/misc/maybe_inf.h b/yt/yt/core/misc/maybe_inf.h
index 3c77c9cf4d..f842d5158b 100644
--- a/yt/yt/core/misc/maybe_inf.h
+++ b/yt/yt/core/misc/maybe_inf.h
@@ -72,9 +72,6 @@ protected:
template <class T>
void FormatValue(TStringBuilderBase* builder, TMaybeInf<T> value, TStringBuf format);
-template <class T>
-TString ToString(TMaybeInf<T> value);
-
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT
diff --git a/yt/yt/core/net/address.cpp b/yt/yt/core/net/address.cpp
index 3044ddeb4f..4801474056 100644
--- a/yt/yt/core/net/address.cpp
+++ b/yt/yt/core/net/address.cpp
@@ -751,11 +751,6 @@ void FormatValue(TStringBuilderBase* builder, const TIP6Address& address, TStrin
}
}
-TString ToString(const TIP6Address& address)
-{
- return ToStringViaBuilder(address);
-}
-
bool operator == (const TIP6Address& lhs, const TIP6Address& rhs)
{
return ::memcmp(lhs.GetRawBytes(), rhs.GetRawBytes(), TIP6Address::ByteSize) == 0;
@@ -948,11 +943,6 @@ void FormatValue(TStringBuilderBase* builder, const TIP6Network& network, TStrin
}
}
-TString ToString(const TIP6Network& network)
-{
- return ToStringViaBuilder(network);
-}
-
void Deserialize(TIP6Network& value, INodePtr node)
{
value = TIP6Network::FromString(node->AsString()->GetValue());
diff --git a/yt/yt/core/net/address.h b/yt/yt/core/net/address.h
index 9e139c5af4..8bca3e4add 100644
--- a/yt/yt/core/net/address.h
+++ b/yt/yt/core/net/address.h
@@ -128,7 +128,6 @@ private:
};
void FormatValue(TStringBuilderBase* builder, const TIP6Address& address, TStringBuf spec);
-TString ToString(const TIP6Address& address);
bool operator == (const TIP6Address& lhs, const TIP6Address& rhs);
@@ -168,7 +167,6 @@ private:
};
void FormatValue(TStringBuilderBase* builder, const TIP6Network& network, TStringBuf spec);
-TString ToString(const TIP6Network& network);
void Deserialize(TIP6Network& value, NYTree::INodePtr node);
void Deserialize(TIP6Network& value, NYson::TYsonPullParserCursor* cursor);
diff --git a/yt/yt/core/rpc/authentication_identity.cpp b/yt/yt/core/rpc/authentication_identity.cpp
index b22880c637..17aec51d46 100644
--- a/yt/yt/core/rpc/authentication_identity.cpp
+++ b/yt/yt/core/rpc/authentication_identity.cpp
@@ -60,7 +60,7 @@ void SetCurrentAuthenticationIdentity(const TAuthenticationIdentity* identity)
*GetCurrentAuthenticationIdentityPtr() = identity;
}
-void FormatValue(TStringBuilderBase* builder, const TAuthenticationIdentity& value, TStringBuf /*format*/)
+void FormatValue(TStringBuilderBase* builder, const TAuthenticationIdentity& value, TStringBuf /*spec*/)
{
builder->AppendFormat("{User: %v", value.User);
if (!value.UserTag.Empty() && value.UserTag != value.User) {
@@ -69,11 +69,6 @@ void FormatValue(TStringBuilderBase* builder, const TAuthenticationIdentity& val
builder->AppendChar('}');
}
-TString ToString(const TAuthenticationIdentity& value)
-{
- return ToStringViaBuilder(value);
-}
-
////////////////////////////////////////////////////////////////////////////////
TCurrentAuthenticationIdentityGuard::TCurrentAuthenticationIdentityGuard()
diff --git a/yt/yt/core/rpc/authentication_identity.h b/yt/yt/core/rpc/authentication_identity.h
index 6ee22ed2fe..d1b7ff8b1a 100644
--- a/yt/yt/core/rpc/authentication_identity.h
+++ b/yt/yt/core/rpc/authentication_identity.h
@@ -33,8 +33,7 @@ void SetCurrentAuthenticationIdentity(const TAuthenticationIdentity* identity);
//! Returns the root identity, which is the default one.
const TAuthenticationIdentity& GetRootAuthenticationIdentity();
-void FormatValue(TStringBuilderBase* builder, const TAuthenticationIdentity& value, TStringBuf format);
-TString ToString(const TAuthenticationIdentity& value);
+void FormatValue(TStringBuilderBase* builder, const TAuthenticationIdentity& value, TStringBuf spec);
void Serialize(const TAuthenticationIdentity& identity, NYson::IYsonConsumer* consumer);
diff --git a/yt/yt/core/rpc/grpc/helpers.cpp b/yt/yt/core/rpc/grpc/helpers.cpp
index 1ed525b1e0..a42d958a11 100644
--- a/yt/yt/core/rpc/grpc/helpers.cpp
+++ b/yt/yt/core/rpc/grpc/helpers.cpp
@@ -49,11 +49,6 @@ TStringBuf ToStringBuf(const grpc_slice& slice)
GRPC_SLICE_LENGTH(slice));
}
-TString ToString(const grpc_slice& slice)
-{
- return TString(ToStringBuf(slice));
-}
-
////////////////////////////////////////////////////////////////////////////////
TStringBuf TGrpcMetadataArray::Find(const char* key) const
@@ -73,7 +68,7 @@ THashMap<TString, TString> TGrpcMetadataArray::ToMap() const
THashMap<TString, TString> result;
for (size_t index = 0; index < Native_.count; ++index) {
const auto& metadata = Native_.metadata[index];
- result[ToString(metadata.key)] = ToString(metadata.value);
+ result[NYT::ToString(metadata.key)] = NYT::ToString(metadata.value);
}
return result;
}
@@ -108,7 +103,7 @@ size_t TGrpcSlice::Size() const
TString TGrpcSlice::AsString() const
{
- return NGrpc::ToString(Native_);
+ return NYT::ToString(Native_);
}
////////////////////////////////////////////////////////////////////////////////
@@ -612,3 +607,8 @@ void TGuardedGrpcCompletionQueue::Release()
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT::NRpc::NGrpc
+
+void FormatValue(NYT::TStringBuilderBase* builder, const grpc_slice& slice, TStringBuf spec)
+{
+ FormatValue(builder, NYT::NRpc::NGrpc::ToStringBuf(slice), spec);
+}
diff --git a/yt/yt/core/rpc/grpc/helpers.h b/yt/yt/core/rpc/grpc/helpers.h
index 020ba03a4c..8c3d2ec565 100644
--- a/yt/yt/core/rpc/grpc/helpers.h
+++ b/yt/yt/core/rpc/grpc/helpers.h
@@ -24,7 +24,6 @@ using TGprString = std::unique_ptr<char, void(*)(void*)>;
TGprString MakeGprString(char* str);
TStringBuf ToStringBuf(const grpc_slice& slice);
-TString ToString(const grpc_slice& slice);
////////////////////////////////////////////////////////////////////////////////
@@ -296,6 +295,8 @@ std::optional<TString> ParseIssuerFromX509(TStringBuf x509String);
} // namespace NYT::NRpc::NGrpc
+void FormatValue(NYT::TStringBuilderBase* builder, const grpc_slice& slice, TStringBuf spec);
+
#define HELPERS_INL_H_
#include "helpers-inl.h"
#undef HELPERS_INL_H_
diff --git a/yt/yt/core/rpc/protocol_version.cpp b/yt/yt/core/rpc/protocol_version.cpp
index 66610f2687..683f6dd323 100644
--- a/yt/yt/core/rpc/protocol_version.cpp
+++ b/yt/yt/core/rpc/protocol_version.cpp
@@ -39,11 +39,6 @@ void FormatValue(TStringBuilderBase* builder, TProtocolVersion version, TStringB
builder->AppendFormat("%v.%v", version.Major, version.Minor);
}
-TString ToString(TProtocolVersion version)
-{
- return ToStringViaBuilder(version);
-}
-
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT::NRpc
diff --git a/yt/yt/core/rpc/protocol_version.h b/yt/yt/core/rpc/protocol_version.h
index 7d87d49597..c1301ae133 100644
--- a/yt/yt/core/rpc/protocol_version.h
+++ b/yt/yt/core/rpc/protocol_version.h
@@ -19,7 +19,6 @@ struct TProtocolVersion
};
void FormatValue(TStringBuilderBase* builder, TProtocolVersion version, TStringBuf spec);
-TString ToString(TProtocolVersion protocolVersion);
////////////////////////////////////////////////////////////////////////////////
diff --git a/yt/yt/core/rpc/service.cpp b/yt/yt/core/rpc/service.cpp
index 23e76917aa..6387738d91 100644
--- a/yt/yt/core/rpc/service.cpp
+++ b/yt/yt/core/rpc/service.cpp
@@ -77,14 +77,16 @@ TServiceId::TServiceId(std::string serviceName, TRealmId realmId)
, RealmId(realmId)
{ }
-TString ToString(const TServiceId& serviceId)
+void FormatValue(TStringBuilderBase* builder, const TServiceId& id, TStringBuf /*spec*/)
{
- auto result = TString(serviceId.ServiceName);
- if (!serviceId.RealmId.IsEmpty()) {
- result.append(':');
- result.append(ToString(serviceId.RealmId));
- }
- return result;
+ builder->AppendFormat(
+ "%v%v",
+ id.ServiceName,
+ MakeFormatterWrapper([&] (TStringBuilderBase* builder) {
+ if (!id.RealmId.IsEmpty()) {
+ builder->AppendFormat(":%v", id.RealmId);
+ }
+ }));
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/yt/yt/core/rpc/service.h b/yt/yt/core/rpc/service.h
index 4fd36abb97..b97eee9adf 100644
--- a/yt/yt/core/rpc/service.h
+++ b/yt/yt/core/rpc/service.h
@@ -20,6 +20,8 @@
#include <library/cpp/yt/memory/ref.h>
+#include <library/cpp/yt/string/guid.h>
+
namespace NYT::NRpc {
////////////////////////////////////////////////////////////////////////////////
@@ -289,7 +291,7 @@ struct TServiceId
TRealmId RealmId;
};
-TString ToString(const TServiceId& serviceId);
+void FormatValue(TStringBuilderBase* builder, const TServiceId& id, TStringBuf spec);
////////////////////////////////////////////////////////////////////////////////
diff --git a/yt/yt/core/tracing/trace_context.cpp b/yt/yt/core/tracing/trace_context.cpp
index 7e5b1140f1..385dde5546 100644
--- a/yt/yt/core/tracing/trace_context.cpp
+++ b/yt/yt/core/tracing/trace_context.cpp
@@ -224,11 +224,6 @@ void FormatValue(TStringBuilderBase* builder, const TSpanContext& context, TStri
(context.Sampled ? 1u : 0) | (context.Debug ? 2u : 0));
}
-TString ToString(const TSpanContext& context)
-{
- return ToStringViaBuilder(context);
-}
-
////////////////////////////////////////////////////////////////////////////////
TTraceContext::TTraceContext(
@@ -598,21 +593,11 @@ void FormatValue(TStringBuilderBase* builder, const TTraceContext* context, TStr
}
}
-TString ToString(const TTraceContext* context)
-{
- return ToStringViaBuilder(context);
-}
-
void FormatValue(TStringBuilderBase* builder, const TTraceContextPtr& context, TStringBuf spec)
{
FormatValue(builder, context.Get(), spec);
}
-TString ToString(const TTraceContextPtr& context)
-{
- return ToStringViaBuilder(context);
-}
-
////////////////////////////////////////////////////////////////////////////////
void ToProto(NProto::TTracingExt* ext, const TTraceContextPtr& context)
diff --git a/yt/yt/core/tracing/trace_context.h b/yt/yt/core/tracing/trace_context.h
index 957e6d45a2..66e9424455 100644
--- a/yt/yt/core/tracing/trace_context.h
+++ b/yt/yt/core/tracing/trace_context.h
@@ -33,7 +33,6 @@ struct TSpanContext
};
void FormatValue(TStringBuilderBase* builder, const TSpanContext& context, TStringBuf spec);
-TString ToString(const TSpanContext& context);
////////////////////////////////////////////////////////////////////////////////
@@ -272,8 +271,6 @@ DEFINE_REFCOUNTED_TYPE(TTraceContext)
void FormatValue(TStringBuilderBase* builder, const TTraceContextPtr& context, TStringBuf spec);
void FormatValue(TStringBuilderBase* builder, const TTraceContext* context, TStringBuf spec);
-TString ToString(const TTraceContextPtr& context);
-TString ToString(const TTraceContextPtr* context);
////////////////////////////////////////////////////////////////////////////////
diff --git a/yt/yt/core/ytree/attribute_filter.cpp b/yt/yt/core/ytree/attribute_filter.cpp
index b38c432804..c5536e50a2 100644
--- a/yt/yt/core/ytree/attribute_filter.cpp
+++ b/yt/yt/core/ytree/attribute_filter.cpp
@@ -484,7 +484,7 @@ void Deserialize(TAttributeFilter& attributeFilter, TYsonPullParserCursor* curso
void FormatValue(
TStringBuilderBase* builder,
const TAttributeFilter& attributeFilter,
- TStringBuf /*format*/)
+ TStringBuf /*spec*/)
{
if (attributeFilter) {
builder->AppendFormat("{Keys: %v, Paths: %v}", attributeFilter.Keys, attributeFilter.Paths);
@@ -493,11 +493,6 @@ void FormatValue(
}
}
-TString ToString(const TAttributeFilter& attributeFilter)
-{
- return ToStringViaBuilder(attributeFilter);
-}
-
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT::NYTree
diff --git a/yt/yt/core/ytree/attribute_filter.h b/yt/yt/core/ytree/attribute_filter.h
index f3dafe86c7..461d024fd3 100644
--- a/yt/yt/core/ytree/attribute_filter.h
+++ b/yt/yt/core/ytree/attribute_filter.h
@@ -156,8 +156,7 @@ void Deserialize(TAttributeFilter& attributeFilter, NYson::TYsonPullParserCursor
void FormatValue(
TStringBuilderBase* builder,
const TAttributeFilter& attributeFilter,
- TStringBuf /*format*/);
-TString ToString(const TAttributeFilter& attributeFilter);
+ TStringBuf /*spec*/);
////////////////////////////////////////////////////////////////////////////////
diff --git a/yt/yt/core/ytree/ypath_service.cpp b/yt/yt/core/ytree/ypath_service.cpp
index cc31e0b7b4..16d400780a 100644
--- a/yt/yt/core/ytree/ypath_service.cpp
+++ b/yt/yt/core/ytree/ypath_service.cpp
@@ -56,9 +56,11 @@ struct TCacheKey
TRef::AreBitwiseEqual(RequestBody, other.RequestBody);
}
- friend TString ToString(const TCacheKey& key)
+ friend void FormatValue(TStringBuilderBase* builder, const TCacheKey& key, TStringBuf /*spec*/)
{
- return Format("{%v %v %x}",
+ Format(
+ builder,
+ "{%v %v %x}",
key.Method,
key.Path,
key.RequestBodyHash);
diff --git a/yt/yt/library/numeric/double_array_format.h b/yt/yt/library/numeric/double_array_format.h
index 2fddfbc264..52a1bfe5ba 100644
--- a/yt/yt/library/numeric/double_array_format.h
+++ b/yt/yt/library/numeric/double_array_format.h
@@ -1,9 +1,8 @@
#pragma once
-#include "vector_format.h"
#include "double_array.h"
-#include <util/string/builder.h>
+#include <library/cpp/yt/string/format.h>
namespace NYT::NDetail {
@@ -13,7 +12,7 @@ namespace NYT::NDetail {
template <class TDerived, class = std::enable_if_t<IsDoubleArray<TDerived>>>
std::ostream& operator<<(std::ostream& os, const TDerived& vec)
{
- os << ToString(vec);
+ os << NYT::ToString(vec);
return os;
}
diff --git a/yt/yt/library/numeric/piecewise_linear_function-inl.h b/yt/yt/library/numeric/piecewise_linear_function-inl.h
index dd50fbe60a..e8c994f3a1 100644
--- a/yt/yt/library/numeric/piecewise_linear_function-inl.h
+++ b/yt/yt/library/numeric/piecewise_linear_function-inl.h
@@ -4,6 +4,8 @@
#include "piecewise_linear_function.h"
#endif
+#include <library/cpp/yt/string/format.h>
+
namespace NYT {
////////////////////////////////////////////////////////////////////////////////
@@ -391,7 +393,7 @@ TPiecewiseLinearFunction<TValue> TPiecewiseLinearFunction<TValue>::Create(
if (criticalPoints.front() != leftBound) {
throw yexception()
<< "Left bound of the function must be its first critical point (CriticalPoints: ["
- << NDetail::ToString(criticalPoints)
+ << NYT::ToString(criticalPoints)
<< "], LeftBound: " << leftBound << ")";
}
YT_VERIFY(criticalPoints.front() == leftBound);
diff --git a/yt/yt/library/numeric/piecewise_linear_function.h b/yt/yt/library/numeric/piecewise_linear_function.h
index f305307760..d831a25d97 100644
--- a/yt/yt/library/numeric/piecewise_linear_function.h
+++ b/yt/yt/library/numeric/piecewise_linear_function.h
@@ -2,7 +2,6 @@
#include "algorithm_helpers.h"
#include "binary_search.h"
-#include "vector_format.h"
#include <library/cpp/testing/gtest/friend.h>
diff --git a/yt/yt/library/numeric/unittests/piecewise_linear_function_ut.cpp b/yt/yt/library/numeric/unittests/piecewise_linear_function_ut.cpp
index 9d738c7122..3d4b832db2 100644
--- a/yt/yt/library/numeric/unittests/piecewise_linear_function_ut.cpp
+++ b/yt/yt/library/numeric/unittests/piecewise_linear_function_ut.cpp
@@ -10,7 +10,6 @@
namespace NYT {
using ::ToString;
-using NDetail::ToString;
////////////////////////////////////////////////////////////////////////////////
@@ -92,10 +91,13 @@ TEST_F(TPiecewiseLinearFunctionTest, TestInterpolationProperties)
// Test that interpolation is monotonic and is exact at bounds on different segments.
for (int segmentIdx = 0; segmentIdx < std::ssize(segments); segmentIdx++) {
const auto& segment = segments[segmentIdx];
- auto msg = TStringBuilder()
- << "For segment #" << segmentIdx << "equal to {"
- << "{" << segment.LeftBound() << ", " << segment.LeftValue() << "}, "
- << "{" << segment.RightBound() << ", " << segment.RightValue() << "}}";
+ auto msg = NYT::Format(
+ "For segment #%vequal to { {%v, %v}, {%v, %v} }",
+ segmentIdx,
+ segment.LeftBound(),
+ segment.LeftValue(),
+ segment.RightBound(),
+ segment.RightValue());
// Test on endpoints.
{
@@ -291,7 +293,7 @@ TEST_F(TPiecewiseLinearFunctionTest, TestSortOrMergeImpl)
};
for (const auto& testCase : testCases) {
- auto testCaseMsg = TStringBuilder() << "In the test case " << testCase.Name;
+ auto testCaseMsg = NYT::Format("In the test case %v", testCase.Name);
std::vector<double> vec = testCase.Input;
std::vector<double> buffer(vec.size());
@@ -484,14 +486,14 @@ TEST_F(TPiecewiseLinearFunctionTest, TestSum)
};
for (const auto& testCase : testCases) {
- auto testCaseMsg = TStringBuilder() << "In the test case " << testCase.Name;
+ auto testCaseMsg = NYT::Format("In the test case %v", testCase.Name);
auto sumResult = TPiecewiseLinearFunction<double>::Sum(testCase.Functions);
EXPECT_EQ(testCase.ExpectedLeftBound, sumResult.LeftFunctionBound()) << testCaseMsg;
EXPECT_EQ(testCase.ExpectedRightBound, sumResult.RightFunctionBound()) << testCaseMsg;
for (const auto& sample : testCase.Samples) {
- auto sampleMsg = TStringBuilder() << "At point " << sample.Argument;
+ auto sampleMsg = NYT::Format("At point %v", sample.Argument);
EXPECT_EQ(sample.ExpectedLeftLimit, sumResult.ValueAt(sample.Argument)) << testCaseMsg << sampleMsg;
EXPECT_EQ(sample.ExpectedLeftLimit, sumResult.LeftLimitAt(sample.Argument)) << testCaseMsg << sampleMsg;
@@ -733,14 +735,14 @@ TEST_F(TPiecewiseLinearFunctionTest, TestPointwiseMin)
};
for (const auto& testCase : testCases) {
- auto testCaseMsg = TStringBuilder() << "In the test case " << testCase.Name;
+ auto testCaseMsg = NYT::Format("In the test case %v", testCase.Name);
auto minResult = PointwiseMin<double>(testCase.Functions);
EXPECT_EQ(testCase.ExpectedLeftBound, minResult.LeftFunctionBound()) << testCaseMsg;
EXPECT_EQ(testCase.ExpectedRightBound, minResult.RightFunctionBound()) << testCaseMsg;
for (const auto& sample : testCase.Samples) {
- auto sampleMsg = TStringBuilder() << "At point %v" << sample.Argument;
+ auto sampleMsg = NYT::Format("At point %v", sample.Argument);
EXPECT_EQ(sample.ExpectedLeftLimit, minResult.ValueAt(sample.Argument)) << testCaseMsg << sampleMsg;
EXPECT_EQ(sample.ExpectedLeftLimit, minResult.LeftLimitAt(sample.Argument)) << testCaseMsg << sampleMsg;
@@ -993,14 +995,14 @@ TEST_F(TPiecewiseLinearFunctionTest, TestCompose)
};
for (const auto& testCase : testCases) {
- auto testCaseMsg = TStringBuilder() << "In the test case " << testCase.Name;
+ auto testCaseMsg = NYT::Format("In the test case %v", testCase.Name);
auto result = testCase.Lhs.Compose(testCase.Rhs);
EXPECT_EQ(testCase.Rhs.LeftFunctionBound(), result.LeftFunctionBound()) << testCaseMsg;
EXPECT_EQ(testCase.Rhs.RightFunctionBound(), result.RightFunctionBound()) << testCaseMsg;
for (const auto& sample : testCase.Samples) {
- auto sampleMsg = TStringBuilder() << "At point %v" << sample.Argument;
+ auto sampleMsg = NYT::Format("At point %v", sample.Argument);
EXPECT_EQ(sample.ExpectedLeftLimit, result.ValueAt(sample.Argument)) << testCaseMsg << sampleMsg;
EXPECT_EQ(sample.ExpectedLeftLimit, result.LeftLimitAt(sample.Argument)) << testCaseMsg << sampleMsg;
@@ -1043,7 +1045,7 @@ TEST_F(TPiecewiseLinearFunctionTest, TestTransformations)
};
for (const auto& testCase : testCases) {
- auto testCaseMsg = TStringBuilder() << "In the test case " << testCase.Name;
+ auto testCaseMsg = NYT::Format("In the test case %v", testCase.Name);
const auto& function = testCase.Function;
EXPECT_EQ(testCase.ExpectedTransposedFunction, function.Transpose()) << testCaseMsg;
@@ -1191,7 +1193,7 @@ TEST_F(TPiecewiseLinearFunctionTest, TestPiecewiseSegmentScalar)
};
for (const auto& testCase : testCases) {
- auto testCaseMsg = TStringBuilder() << "In the test case " << testCase.Name;
+ auto testCaseMsg = NYT::Format("In the test case %v", testCase.Name);
const auto& segment = testCase.Segment;
@@ -1201,13 +1203,13 @@ TEST_F(TPiecewiseLinearFunctionTest, TestPiecewiseSegmentScalar)
EXPECT_EQ(testCase.ExpectedValues.second, segment.RightValue()) << testCaseMsg;
for (const auto& [leftBound, rightBound, expectedIsDefined] : testCase.Intervals) {
- auto sampleMsg = TStringBuilder() << "At interval [" << leftBound << ", " << rightBound << "]";
+ auto sampleMsg = NYT::Format("At interval [ %v, %v ]", leftBound, rightBound);
EXPECT_EQ(expectedIsDefined, segment.IsDefinedOn(leftBound, rightBound)) << testCaseMsg << ". " << sampleMsg;
}
for (const auto& [arg, expectedLeftLimit, expectedRightLimit] : testCase.Samples) {
- auto sampleMsg = TStringBuilder() << "At point " << arg;
+ auto sampleMsg = NYT::Format("At point %v", arg);
EXPECT_TRUE(segment.IsDefinedAt(arg)) << testCaseMsg << ". " << sampleMsg;
EXPECT_EQ(expectedLeftLimit, segment.LeftLimitAt(arg)) << testCaseMsg << ". " << sampleMsg;
@@ -1341,20 +1343,20 @@ TEST_F(TPiecewiseLinearFunctionTest, TestPiecewiseSegmentTransformationsScalar)
};
for (const auto& testCase : testCases) {
- auto testCaseMsg = TStringBuilder() << "In the test case " << testCase.Name;
+ auto testCaseMsg = NYT::Format("In the test case %v", testCase.Name);
const auto& segment = testCase.Segment;
EXPECT_EQ(testCase.ExpectedTransposedSegment, segment.Transpose()) << testCaseMsg;
for (const auto& [scale, expectedSegment] : testCase.ExpectedScaledSegments) {
- auto sampleMsg = TStringBuilder() << "At scale " << scale;
+ auto sampleMsg = NYT::Format("At scale %v", scale);
EXPECT_EQ(expectedSegment, segment.ScaleArgument(scale)) << testCaseMsg << ". " << sampleMsg;
}
for (const auto& [deltaBound, deltaValue, expectedSegment] : testCase.ExpectedShiftedSegments) {
- auto sampleMsg = TStringBuilder() << "At shift [" << deltaBound << ", " << deltaValue << "]";
+ auto sampleMsg = NYT::Format("At shift [ %v, %v ]", deltaBound, deltaValue);
EXPECT_EQ(expectedSegment, segment.Shift(deltaBound, deltaValue)) << testCaseMsg << ". " << sampleMsg;
}
diff --git a/yt/yt/library/numeric/vector_format.h b/yt/yt/library/numeric/vector_format.h
deleted file mode 100644
index 6a4e5ebe98..0000000000
--- a/yt/yt/library/numeric/vector_format.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#pragma once
-
-#include <util/string/builder.h>
-
-namespace NYT::NDetail {
-
-////////////////////////////////////////////////////////////////////////////////
-
-template <class T>
-TString ToString(const std::vector<T>& vec)
-{
- ::TStringBuilder outputStream;
- outputStream << "[";
- for (size_t index = 0; index < vec.size(); ++index) {
- outputStream << vec[index];
- if (index + 1 < vec.size()) {
- outputStream << ", ";
- }
- }
- outputStream << "]";
- return std::move(outputStream);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-} // namespace NYT::NDetail
diff --git a/yt/yt/library/numeric/ya.make b/yt/yt/library/numeric/ya.make
index 39fc663491..9c4c37c661 100644
--- a/yt/yt/library/numeric/ya.make
+++ b/yt/yt/library/numeric/ya.make
@@ -8,6 +8,7 @@ SRCS(
PEERDIR(
library/cpp/yt/small_containers
+ library/cpp/yt/string
util
)
diff --git a/yt/yt/library/profiling/sensor.cpp b/yt/yt/library/profiling/sensor.cpp
index beb76248cc..cec63b40ea 100644
--- a/yt/yt/library/profiling/sensor.cpp
+++ b/yt/yt/library/profiling/sensor.cpp
@@ -232,9 +232,10 @@ TRateHistogram::operator bool() const
////////////////////////////////////////////////////////////////////////////////
-TString ToString(const TSensorOptions& options)
+void FormatValue(TStringBuilderBase* builder, const TSensorOptions& options, TStringBuf /*spec*/)
{
- return Format(
+ Format(
+ builder,
"{sparse=%v;global=%v;hot=%v;histogram_min=%v;histogram_max=%v;time_histogram_bounds=%v;histogram_bounds=%v;summary_policy=%v}",
options.Sparse,
options.Global,
diff --git a/yt/yt/library/profiling/sensor.h b/yt/yt/library/profiling/sensor.h
index bd6c61706d..bd8ff2005c 100644
--- a/yt/yt/library/profiling/sensor.h
+++ b/yt/yt/library/profiling/sensor.h
@@ -15,6 +15,8 @@
#include <library/cpp/yt/misc/enum.h>
+#include <library/cpp/yt/string/format.h>
+
#include <vector>
namespace NYT::NProfiling {
@@ -219,7 +221,7 @@ struct TSensorOptions
bool IsCompatibleWith(const TSensorOptions& other) const;
};
-TString ToString(const TSensorOptions& options);
+void FormatValue(TStringBuilderBase* builder, const TSensorOptions& options, TStringBuf spec);
////////////////////////////////////////////////////////////////////////////////