aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbabenko <babenko@yandex-team.com>2024-09-21 18:48:04 +0300
committerbabenko <babenko@yandex-team.com>2024-09-21 18:59:06 +0300
commit3e1c76c643ee8d5657bbecf22188cc720ff41dd9 (patch)
treea556f59578c28c137c266883dccbdac659166537
parent22ec41df66d0db33b7c3870298dc2973c51c6241 (diff)
downloadydb-3e1c76c643ee8d5657bbecf22188cc720ff41dd9.tar.gz
YT-22593: Switch roles and tags to std::string
commit_hash:95b4390ea7180acad42fdcea90a9f30053184498
-rw-r--r--yt/yt/client/api/public.h4
-rw-r--r--yt/yt/client/driver/proxy_discovery_cache.cpp2
-rw-r--r--yt/yt/client/node_tracker_client/node_directory.cpp12
-rw-r--r--yt/yt/client/node_tracker_client/node_directory.h6
-rw-r--r--yt/yt/core/misc/arithmetic_formula.cpp98
-rw-r--r--yt/yt/core/misc/arithmetic_formula.h38
-rw-r--r--yt/yt/core/misc/unittests/boolean_formula_ut.cpp83
7 files changed, 122 insertions, 121 deletions
diff --git a/yt/yt/client/api/public.h b/yt/yt/client/api/public.h
index 847a60ebe5..be710a04ce 100644
--- a/yt/yt/client/api/public.h
+++ b/yt/yt/client/api/public.h
@@ -203,8 +203,8 @@ inline const TString BannedAttributeName("banned");
inline const TString RoleAttributeName("role");
inline const TString AddressesAttributeName("addresses");
inline const TString BalancersAttributeName("balancers");
-inline const TString DefaultRpcProxyRole("default");
-inline const TString DefaultHttpProxyRole("data");
+inline const std::string DefaultRpcProxyRole("default");
+inline const std::string DefaultHttpProxyRole("data");
inline const TString JournalPayloadKey("payload");
inline const TString HunkPayloadKey("payload");
diff --git a/yt/yt/client/driver/proxy_discovery_cache.cpp b/yt/yt/client/driver/proxy_discovery_cache.cpp
index 772f526231..a17894a93e 100644
--- a/yt/yt/client/driver/proxy_discovery_cache.cpp
+++ b/yt/yt/client/driver/proxy_discovery_cache.cpp
@@ -133,7 +133,7 @@ private:
continue;
}
- if (proxyNode->Attributes().Get<TString>(RoleAttributeName, DefaultRpcProxyRole) != request.Role) {
+ if (proxyNode->Attributes().Get<std::string>(RoleAttributeName, DefaultRpcProxyRole) != request.Role) {
continue;
}
diff --git a/yt/yt/client/node_tracker_client/node_directory.cpp b/yt/yt/client/node_tracker_client/node_directory.cpp
index 0ef4ee4561..7d377febbc 100644
--- a/yt/yt/client/node_tracker_client/node_directory.cpp
+++ b/yt/yt/client/node_tracker_client/node_directory.cpp
@@ -58,9 +58,9 @@ namespace {
constexpr int TypicalTagCount = 16;
// Cf. YT-10645
-TCompactVector<TStringBuf, TypicalTagCount> GetSortedTags(const std::vector<TString>& tags)
+TCompactVector<std::string, TypicalTagCount> GetSortedTags(const std::vector<std::string>& tags)
{
- TCompactVector<TStringBuf, TypicalTagCount> result;
+ TCompactVector<std::string, TypicalTagCount> result;
result.reserve(tags.size());
for (const auto& tag : tags) {
result.push_back(tag);
@@ -94,7 +94,7 @@ TNodeDescriptor::TNodeDescriptor(
const std::optional<std::string>& host,
const std::optional<std::string>& rack,
const std::optional<std::string>& dc,
- const std::vector<TString>& tags,
+ const std::vector<std::string>& tags,
std::optional<TInstant> lastSeenTime)
: Addresses_(std::move(addresses))
, DefaultAddress_(NNodeTrackerClient::GetDefaultAddress(Addresses_))
@@ -145,7 +145,7 @@ const std::optional<std::string>& TNodeDescriptor::GetDataCenter() const
return DataCenter_;
}
-const std::vector<TString>& TNodeDescriptor::GetTags() const
+const std::vector<std::string>& TNodeDescriptor::GetTags() const
{
return Tags_;
}
@@ -380,7 +380,7 @@ void FromProto(NNodeTrackerClient::TNodeDescriptor* descriptor, const NNodeTrack
protoDescriptor.has_host() ? std::make_optional(protoDescriptor.host()) : std::nullopt,
protoDescriptor.has_rack() ? std::make_optional(protoDescriptor.rack()) : std::nullopt,
protoDescriptor.has_data_center() ? std::make_optional(protoDescriptor.data_center()) : std::nullopt,
- FromProto<std::vector<TString>>(protoDescriptor.tags()),
+ FromProto<std::vector<std::string>>(protoDescriptor.tags()),
protoDescriptor.has_last_seen_time() ? std::make_optional(FromProto<TInstant>(protoDescriptor.last_seen_time())) : std::nullopt);
}
@@ -434,7 +434,7 @@ bool operator == (const TNodeDescriptor& lhs, const NProto::TNodeDescriptor& rhs
}
const auto& lhsTags = lhs.GetTags();
- auto rhsTags = FromProto<std::vector<TString>>(rhs.tags());
+ auto rhsTags = FromProto<std::vector<std::string>>(rhs.tags());
if (GetSortedTags(lhsTags) != GetSortedTags(rhsTags)) {
return false;
}
diff --git a/yt/yt/client/node_tracker_client/node_directory.h b/yt/yt/client/node_tracker_client/node_directory.h
index f8ebc1ba0c..eafef00686 100644
--- a/yt/yt/client/node_tracker_client/node_directory.h
+++ b/yt/yt/client/node_tracker_client/node_directory.h
@@ -35,7 +35,7 @@ public:
const std::optional<std::string>& host = {},
const std::optional<std::string>& rack = {},
const std::optional<std::string>& dc = {},
- const std::vector<TString>& tags = {},
+ const std::vector<std::string>& tags = {},
std::optional<TInstant> lastSeenTime = {});
TNodeDescriptor& operator=(const TNodeDescriptor& other) = default;
@@ -55,7 +55,7 @@ public:
const std::optional<std::string>& GetRack() const;
const std::optional<std::string>& GetDataCenter() const;
- const std::vector<TString>& GetTags() const;
+ const std::vector<std::string>& GetTags() const;
//! GetLastSeenTime returns last instant when node was seen online on some master.
/*!
@@ -76,7 +76,7 @@ private:
std::optional<std::string> Host_;
std::optional<std::string> Rack_;
std::optional<std::string> DataCenter_;
- std::vector<TString> Tags_;
+ std::vector<std::string> Tags_;
// Not persisted.
mutable TCopyableAtomic<TCpuInstant> LastSeenTime_;
diff --git a/yt/yt/core/misc/arithmetic_formula.cpp b/yt/yt/core/misc/arithmetic_formula.cpp
index 8fe147ef65..143e3de8f6 100644
--- a/yt/yt/core/misc/arithmetic_formula.cpp
+++ b/yt/yt/core/misc/arithmetic_formula.cpp
@@ -42,7 +42,7 @@ bool IsSymbolAllowedInName(char c, EEvaluationContext context, bool isFirst)
return false;
}
-void ValidateFormulaVariable(const TString& variable, EEvaluationContext context)
+void ValidateFormulaVariable(const std::string& variable, EEvaluationContext context)
{
if (variable.empty()) {
THROW_ERROR_EXCEPTION("Variable should not be empty");
@@ -67,12 +67,12 @@ void ValidateFormulaVariable(const TString& variable, EEvaluationContext context
////////////////////////////////////////////////////////////////////////////////
-void ValidateArithmeticFormulaVariable(const TString& variable)
+void ValidateArithmeticFormulaVariable(const std::string& variable)
{
ValidateFormulaVariable(variable, EEvaluationContext::Arithmetic);
}
-void ValidateBooleanFormulaVariable(const TString& variable)
+void ValidateBooleanFormulaVariable(const std::string& variable)
{
ValidateFormulaVariable(variable, EEvaluationContext::Boolean);
}
@@ -81,12 +81,12 @@ void ValidateBooleanFormulaVariable(const TString& variable)
namespace {
-void ThrowError(const TString& formula, int position, const TString& message, EEvaluationContext evaluationContext)
+void ThrowError(const std::string& formula, int position, const std::string& message, EEvaluationContext evaluationContext)
{
const static int maxContextSize = 30;
int contextStart = std::max(0, position - maxContextSize / 2);
- TString context = formula.substr(contextStart, maxContextSize);
+ std::string context = formula.substr(contextStart, maxContextSize);
int contextPosition = std::min(position, maxContextSize / 2);
TStringBuilder builder;
@@ -154,7 +154,7 @@ struct TFormulaToken
{
EFormulaTokenType Type;
int Position;
- TString Name;
+ std::string Name;
i64 Number = 0;
};
@@ -171,11 +171,11 @@ class TGenericFormulaImpl
: public TRefCounted
{
public:
- DEFINE_BYVAL_RO_PROPERTY(TString, Formula);
+ DEFINE_BYVAL_RO_PROPERTY(std::string, Formula);
DEFINE_BYVAL_RO_PROPERTY(size_t, Hash);
public:
- TGenericFormulaImpl(const TString& formula, size_t hash, std::vector<TFormulaToken> parsedFormula);
+ TGenericFormulaImpl(const std::string& formula, size_t hash, std::vector<TFormulaToken> parsedFormula);
bool operator==(const TGenericFormulaImpl& other) const;
@@ -183,31 +183,31 @@ public:
int Size() const;
- i64 Eval(const THashMap<TString, i64>& values, EEvaluationContext context) const;
+ i64 Eval(const THashMap<std::string, i64>& values, EEvaluationContext context) const;
- THashSet<TString> GetVariables() const;
+ THashSet<std::string> GetVariables() const;
private:
std::vector<TFormulaToken> ParsedFormula_;
- static std::vector<TFormulaToken> Tokenize(const TString& formula, EEvaluationContext context);
+ static std::vector<TFormulaToken> Tokenize(const std::string& formula, EEvaluationContext context);
static std::vector<TFormulaToken> Parse(
- const TString& formula,
+ const std::string& formula,
const std::vector<TFormulaToken>& tokens,
EEvaluationContext context);
static size_t CalculateHash(const std::vector<TFormulaToken>& tokens);
static void CheckTypeConsistency(
- const TString& formula,
+ const std::string& formula,
const std::vector<TFormulaToken>& tokens,
EEvaluationContext context);
- friend TIntrusivePtr<TGenericFormulaImpl> MakeGenericFormulaImpl(const TString& formula, EEvaluationContext context);
+ friend TIntrusivePtr<TGenericFormulaImpl> MakeGenericFormulaImpl(const std::string& formula, EEvaluationContext context);
};
////////////////////////////////////////////////////////////////////////////////
TGenericFormulaImpl::TGenericFormulaImpl(
- const TString& formula,
+ const std::string& formula,
size_t hash,
std::vector<TFormulaToken> parsedFormula)
: Formula_(formula)
@@ -234,9 +234,9 @@ int TGenericFormulaImpl::Size() const
return ParsedFormula_.size();
}
-i64 TGenericFormulaImpl::Eval(const THashMap<TString, i64>& values, EEvaluationContext context) const
+i64 TGenericFormulaImpl::Eval(const THashMap<std::string, i64>& values, EEvaluationContext context) const
{
- auto variableValue = [&] (const TString& var) -> i64 {
+ auto variableValue = [&] (const std::string& var) -> i64 {
auto iter = values.find(var);
if (iter == values.end()) {
if (context == EEvaluationContext::Boolean) {
@@ -389,9 +389,9 @@ i64 TGenericFormulaImpl::Eval(const THashMap<TString, i64>& values, EEvaluationC
#undef APPLY_BINARY_OP
}
-THashSet<TString> TGenericFormulaImpl::GetVariables() const
+THashSet<std::string> TGenericFormulaImpl::GetVariables() const
{
- THashSet<TString> variables;
+ THashSet<std::string> variables;
for (const auto& token : ParsedFormula_) {
if (token.Type == EFormulaTokenType::Variable) {
variables.insert(token.Name);
@@ -400,12 +400,12 @@ THashSet<TString> TGenericFormulaImpl::GetVariables() const
return variables;
}
-std::vector<TFormulaToken> TGenericFormulaImpl::Tokenize(const TString& formula, EEvaluationContext context)
+std::vector<TFormulaToken> TGenericFormulaImpl::Tokenize(const std::string& formula, EEvaluationContext context)
{
std::vector<TFormulaToken> result;
size_t pos = 0;
- auto throwError = [&] (int position, const TString& message) {
+ auto throwError = [&] (int position, const std::string& message) {
ThrowError(formula, position, message, context);
};
@@ -526,7 +526,7 @@ std::vector<TFormulaToken> TGenericFormulaImpl::Tokenize(const TString& formula,
};
auto extractVariable = [&] {
- TString name;
+ std::string name;
while (pos < formula.size() && IsSymbolAllowedInName(formula[pos], context, /*isFirst*/ name.empty())) {
name += formula[pos++];
}
@@ -595,7 +595,7 @@ std::vector<TFormulaToken> TGenericFormulaImpl::Tokenize(const TString& formula,
}
std::vector<TFormulaToken> TGenericFormulaImpl::Parse(
- const TString& formula,
+ const std::string& formula,
const std::vector<TFormulaToken>& tokens,
EEvaluationContext context)
{
@@ -607,7 +607,7 @@ std::vector<TFormulaToken> TGenericFormulaImpl::Parse(
return result;
}
- auto throwError = [&] (int position, const TString& message) {
+ auto throwError = [&] (int position, const std::string& message) {
ThrowError(formula, position, message, context);
};
@@ -712,7 +712,7 @@ size_t TGenericFormulaImpl::CalculateHash(const std::vector<TFormulaToken>& toke
}
void TGenericFormulaImpl::CheckTypeConsistency(
- const TString& formula,
+ const std::string& formula,
const std::vector<TFormulaToken>& tokens,
EEvaluationContext context)
{
@@ -775,7 +775,7 @@ void TGenericFormulaImpl::CheckTypeConsistency(
}
}
-TIntrusivePtr<TGenericFormulaImpl> MakeGenericFormulaImpl(const TString& formula, EEvaluationContext context)
+TIntrusivePtr<TGenericFormulaImpl> MakeGenericFormulaImpl(const std::string& formula, EEvaluationContext context)
{
auto tokens = TGenericFormulaImpl::Tokenize(formula, context);
auto parsed = TGenericFormulaImpl::Parse(formula, tokens, context);
@@ -786,7 +786,7 @@ TIntrusivePtr<TGenericFormulaImpl> MakeGenericFormulaImpl(const TString& formula
////////////////////////////////////////////////////////////////////////////////
TArithmeticFormula::TArithmeticFormula()
- : Impl_(MakeGenericFormulaImpl(TString(), EEvaluationContext::Arithmetic))
+ : Impl_(MakeGenericFormulaImpl(std::string(), EEvaluationContext::Arithmetic))
{ }
TArithmeticFormula::TArithmeticFormula(TIntrusivePtr<TGenericFormulaImpl> impl)
@@ -819,22 +819,22 @@ size_t TArithmeticFormula::GetHash() const
return Impl_->GetHash();
}
-TString TArithmeticFormula::GetFormula() const
+std::string TArithmeticFormula::GetFormula() const
{
return Impl_->GetFormula();
}
-i64 TArithmeticFormula::Eval(const THashMap<TString, i64>& values) const
+i64 TArithmeticFormula::Eval(const THashMap<std::string, i64>& values) const
{
return Impl_->Eval(values, EEvaluationContext::Arithmetic);
}
-THashSet<TString> TArithmeticFormula::GetVariables() const
+THashSet<std::string> TArithmeticFormula::GetVariables() const
{
return Impl_->GetVariables();
}
-TArithmeticFormula MakeArithmeticFormula(const TString& formula)
+TArithmeticFormula MakeArithmeticFormula(const std::string& formula)
{
auto impl = MakeGenericFormulaImpl(formula, EEvaluationContext::Arithmetic);
return TArithmeticFormula(std::move(impl));
@@ -860,13 +860,13 @@ void TArithmeticFormula::Save(TStreamSaveContext& context) const
void TArithmeticFormula::Load(TStreamLoadContext& context)
{
using NYT::Load;
- auto formula = Load<TString>(context);
+ auto formula = Load<std::string>(context);
Impl_ = MakeGenericFormulaImpl(formula, EEvaluationContext::Arithmetic);
}
////////////////////////////////////////////////////////////////////////////////
-TBooleanFormulaTags::TBooleanFormulaTags(THashSet<TString> tags)
+TBooleanFormulaTags::TBooleanFormulaTags(THashSet<std::string> tags)
: Tags_(std::move(tags))
{
for (const auto& key: Tags_) {
@@ -874,7 +874,7 @@ TBooleanFormulaTags::TBooleanFormulaTags(THashSet<TString> tags)
}
}
-const THashSet<TString>& TBooleanFormulaTags::GetSourceTags() const
+const THashSet<std::string>& TBooleanFormulaTags::GetSourceTags() const
{
return Tags_;
}
@@ -888,7 +888,7 @@ void TBooleanFormulaTags::Save(TStreamSaveContext& context) const
void TBooleanFormulaTags::Load(TStreamLoadContext& context)
{
using NYT::Load;
- *this = TBooleanFormulaTags(Load<THashSet<TString>>(context));
+ *this = TBooleanFormulaTags(Load<THashSet<std::string>>(context));
}
bool TBooleanFormulaTags::operator==(const TBooleanFormulaTags& other) const
@@ -904,7 +904,7 @@ void Serialize(const TBooleanFormulaTags& tags, NYson::IYsonConsumer* consumer)
void Deserialize(TBooleanFormulaTags& tags, NYTree::INodePtr node)
{
- tags = TBooleanFormulaTags(ConvertTo<THashSet<TString>>(node));
+ tags = TBooleanFormulaTags(ConvertTo<THashSet<std::string>>(node));
}
void FormatValue(TStringBuilderBase* builder, const TBooleanFormulaTags& tags, TStringBuf /*spec*/)
@@ -915,7 +915,7 @@ void FormatValue(TStringBuilderBase* builder, const TBooleanFormulaTags& tags, T
////////////////////////////////////////////////////////////////////////////////
TBooleanFormula::TBooleanFormula()
- : Impl_(MakeGenericFormulaImpl(TString(), EEvaluationContext::Boolean))
+ : Impl_(MakeGenericFormulaImpl(std::string(), EEvaluationContext::Boolean))
{ }
TBooleanFormula::TBooleanFormula(TIntrusivePtr<TGenericFormulaImpl> impl)
@@ -948,23 +948,23 @@ size_t TBooleanFormula::GetHash() const
return Impl_->GetHash();
}
-TString TBooleanFormula::GetFormula() const
+std::string TBooleanFormula::GetFormula() const
{
return Impl_->GetFormula();
}
-bool TBooleanFormula::IsSatisfiedBy(const std::vector<TString>& value) const
+bool TBooleanFormula::IsSatisfiedBy(const std::vector<std::string>& value) const
{
- THashMap<TString, i64> values;
+ THashMap<std::string, i64> values;
for (const auto& key: value) {
values[key] = 1;
}
return Impl_->Eval(values, EEvaluationContext::Boolean);
}
-bool TBooleanFormula::IsSatisfiedBy(const THashSet<TString>& value) const
+bool TBooleanFormula::IsSatisfiedBy(const THashSet<std::string>& value) const
{
- return IsSatisfiedBy(std::vector<TString>(value.begin(), value.end()));
+ return IsSatisfiedBy(std::vector<std::string>(value.begin(), value.end()));
}
bool TBooleanFormula::IsSatisfiedBy(const TBooleanFormulaTags& tags) const
@@ -972,7 +972,7 @@ bool TBooleanFormula::IsSatisfiedBy(const TBooleanFormulaTags& tags) const
return Impl_->Eval(tags.PreparedTags_, EEvaluationContext::Boolean);
}
-TBooleanFormula MakeBooleanFormula(const TString& formula)
+TBooleanFormula MakeBooleanFormula(const std::string& formula)
{
auto impl = MakeGenericFormulaImpl(formula, EEvaluationContext::Boolean);
return TBooleanFormula(std::move(impl));
@@ -1020,7 +1020,7 @@ void Deserialize(TBooleanFormula& booleanFormula, TYsonPullParserCursor* cursor)
{
MaybeSkipAttributes(cursor);
EnsureYsonToken("TBooleanFormula", *cursor, EYsonItemType::StringValue);
- booleanFormula = MakeBooleanFormula(ExtractTo<TString>(cursor));
+ booleanFormula = MakeBooleanFormula(ExtractTo<std::string>(cursor));
}
void TBooleanFormula::Save(TStreamSaveContext& context) const
@@ -1032,7 +1032,7 @@ void TBooleanFormula::Save(TStreamSaveContext& context) const
void TBooleanFormula::Load(TStreamLoadContext& context)
{
using NYT::Load;
- auto formula = Load<TString>(context);
+ auto formula = Load<std::string>(context);
Impl_ = MakeGenericFormulaImpl(formula, EEvaluationContext::Boolean);
}
@@ -1070,7 +1070,7 @@ size_t TTimeFormula::GetHash() const
return Formula_.GetHash();
}
-TString TTimeFormula::GetFormula() const
+std::string TTimeFormula::GetFormula() const
{
return Formula_.GetFormula();
}
@@ -1088,9 +1088,9 @@ TTimeFormula::TTimeFormula(TArithmeticFormula&& arithmeticFormula)
: Formula_(std::move(arithmeticFormula))
{ }
-TTimeFormula MakeTimeFormula(const TString& formula)
+TTimeFormula MakeTimeFormula(const std::string& formula)
{
- const static THashSet<TString> allowedVariables{"minutes", "hours"};
+ const static THashSet<std::string> allowedVariables{"minutes", "hours"};
auto arithmeticFormula = MakeArithmeticFormula(formula);
@@ -1119,7 +1119,7 @@ void Deserialize(TTimeFormula& timeFormula, TYsonPullParserCursor* cursor)
{
MaybeSkipAttributes(cursor);
EnsureYsonToken("TTimeFormula", *cursor, EYsonItemType::StringValue);
- timeFormula = MakeTimeFormula(ExtractTo<TString>(cursor));
+ timeFormula = MakeTimeFormula(ExtractTo<std::string>(cursor));
}
void TTimeFormula::Save(TStreamSaveContext& context) const
diff --git a/yt/yt/core/misc/arithmetic_formula.h b/yt/yt/core/misc/arithmetic_formula.h
index ddc15d9def..fdb2bcfc00 100644
--- a/yt/yt/core/misc/arithmetic_formula.h
+++ b/yt/yt/core/misc/arithmetic_formula.h
@@ -12,10 +12,10 @@ namespace NYT {
////////////////////////////////////////////////////////////////////////////////
//! Validates that a string is a correct arithmetic formula variable name.
-void ValidateArithmeticFormulaVariable(const TString& variable);
+void ValidateArithmeticFormulaVariable(const std::string& variable);
//! Validates that a string is a correct boolean formula variable name.
-void ValidateBooleanFormulaVariable(const TString& variable);
+void ValidateBooleanFormulaVariable(const std::string& variable);
////////////////////////////////////////////////////////////////////////////////
@@ -47,13 +47,13 @@ public:
size_t GetHash() const;
//! Returns a human-readable representation of the formula.
- TString GetFormula() const;
+ std::string GetFormula() const;
//! Evaluate the formula given values of variables.
- i64 Eval(const THashMap<TString, i64>& values) const;
+ i64 Eval(const THashMap<std::string, i64>& values) const;
//! Returns the list of variables used in the formula.
- THashSet<TString> GetVariables() const;
+ THashSet<std::string> GetVariables() const;
void Save(TStreamSaveContext& context) const;
void Load(TStreamLoadContext& context);
@@ -63,11 +63,11 @@ private:
explicit TArithmeticFormula(TIntrusivePtr<TGenericFormulaImpl> impl);
- friend TArithmeticFormula MakeArithmeticFormula(const TString& formula);
+ friend TArithmeticFormula MakeArithmeticFormula(const std::string& formula);
};
//! Parse string and return arithmetic formula.
-TArithmeticFormula MakeArithmeticFormula(const TString& formula);
+TArithmeticFormula MakeArithmeticFormula(const std::string& formula);
void Serialize(const TArithmeticFormula& arithmeticFormula, NYson::IYsonConsumer* consumer);
void Deserialize(TArithmeticFormula& arithmeticFormula, NYTree::INodePtr node);
@@ -78,9 +78,9 @@ class TBooleanFormulaTags
{
public:
TBooleanFormulaTags() = default;
- explicit TBooleanFormulaTags(THashSet<TString> tags);
+ explicit TBooleanFormulaTags(THashSet<std::string> tags);
- const THashSet<TString>& GetSourceTags() const;
+ const THashSet<std::string>& GetSourceTags() const;
void Save(TStreamSaveContext& context) const;
void Load(TStreamLoadContext& context);
@@ -88,8 +88,8 @@ public:
bool operator==(const TBooleanFormulaTags& other) const;
private:
- THashSet<TString> Tags_;
- THashMap<TString, i64> PreparedTags_;
+ THashSet<std::string> Tags_;
+ THashMap<std::string, i64> PreparedTags_;
friend class TBooleanFormula;
};
@@ -123,11 +123,11 @@ public:
size_t GetHash() const;
//! Returns a human-readable representation of the formula.
- TString GetFormula() const;
+ std::string GetFormula() const;
//! Check that a given set of true-variables satisfies the formula.
- bool IsSatisfiedBy(const std::vector<TString>& value) const;
- bool IsSatisfiedBy(const THashSet<TString>& value) const;
+ bool IsSatisfiedBy(const std::vector<std::string>& value) const;
+ bool IsSatisfiedBy(const THashSet<std::string>& value) const;
bool IsSatisfiedBy(const TBooleanFormulaTags& tags) const;
void Save(TStreamSaveContext& context) const;
@@ -138,11 +138,11 @@ private:
explicit TBooleanFormula(TIntrusivePtr<TGenericFormulaImpl> impl);
- friend TBooleanFormula MakeBooleanFormula(const TString& formula);
+ friend TBooleanFormula MakeBooleanFormula(const std::string& formula);
};
//! Parse string and return boolean formula.
-TBooleanFormula MakeBooleanFormula(const TString& formula);
+TBooleanFormula MakeBooleanFormula(const std::string& formula);
//! Make conjunction, disjunction and negation of formulas.
TBooleanFormula operator&(const TBooleanFormula& lhs, const TBooleanFormula& rhs);
@@ -179,7 +179,7 @@ public:
size_t GetHash() const;
//! Returns a human-readable representation of the formula.
- TString GetFormula() const;
+ std::string GetFormula() const;
//! Check that given time satisfies the formula.
bool IsSatisfiedBy(TInstant time) const;
@@ -192,11 +192,11 @@ private:
explicit TTimeFormula(TArithmeticFormula&& arithmeticFormula);
- friend TTimeFormula MakeTimeFormula(const TString& formula);
+ friend TTimeFormula MakeTimeFormula(const std::string& formula);
};
//! Parse string and return time formula.
-TTimeFormula MakeTimeFormula(const TString& formula);
+TTimeFormula MakeTimeFormula(const std::string& formula);
void Serialize(const TTimeFormula& timeFormula, NYson::IYsonConsumer* consumer);
void Deserialize(TTimeFormula& timeFormula, NYTree::INodePtr node);
diff --git a/yt/yt/core/misc/unittests/boolean_formula_ut.cpp b/yt/yt/core/misc/unittests/boolean_formula_ut.cpp
index 0bae531297..94e43cbf2d 100644
--- a/yt/yt/core/misc/unittests/boolean_formula_ut.cpp
+++ b/yt/yt/core/misc/unittests/boolean_formula_ut.cpp
@@ -12,8 +12,9 @@ class TBooleanFormulaTest
: public ::testing::Test
, public ::testing::WithParamInterface<std::tuple<
const char*,
- std::vector<TString>,
- bool>>
+ std::vector<std::string>,
+ bool
+ >>
{ };
TEST_P(TBooleanFormulaTest, Test)
@@ -35,31 +36,31 @@ INSTANTIATE_TEST_SUITE_P(
TBooleanFormulaTest,
TBooleanFormulaTest,
::testing::Values(
- std::tuple("", std::vector<TString>{}, true),
- std::tuple("", std::vector<TString>{"b"}, true),
- std::tuple("a", std::vector<TString>{"b"}, false),
- std::tuple("!a", std::vector<TString>{"b"}, true),
- std::tuple("b", std::vector<TString>{"b"}, true),
- std::tuple("a|b", std::vector<TString>{"b"}, true),
- std::tuple("a & b", std::vector<TString>{"b"}, false),
- std::tuple("(b)", std::vector<TString>{"b"}, true),
- std::tuple("a|(a|b)", std::vector<TString>{"b"}, true),
- std::tuple("(a|b)&(!a&b)", std::vector<TString>{"b"}, true),
- std::tuple("a&b", std::vector<TString>{"a", "b"}, true),
- std::tuple("(a|c)&(b|c)", std::vector<TString>{"a", "b"}, true),
- std::tuple("(a|b)&c", std::vector<TString>{"a", "b"}, false),
- std::tuple("a|b|c", std::vector<TString>{"b"}, true),
- std::tuple("!a & b & !c", std::vector<TString>{"b"}, true),
- std::tuple("var-1 | !var/2", std::vector<TString>{"var-1"}, true),
- std::tuple("var-1 | !var/2", std::vector<TString>{"var/2"}, false),
- std::tuple("var-1 | !var/2", std::vector<TString>{}, true),
- std::tuple("!in-", std::vector<TString>{}, true),
- std::tuple("in/|x", std::vector<TString>{"in/"}, true),
- std::tuple("%true", std::vector<TString>{""}, true),
- std::tuple("%false", std::vector<TString>{"false"}, false),
- std::tuple("%true|%false", std::vector<TString>{""}, true),
- std::tuple("a.b.c-d.e:1234", std::vector<TString>{"a.b.c-d.e:1234"}, true),
- std::tuple("!a.b.c-d.e:1234", std::vector<TString>{"a.b.c-d.e:1234"}, false)
+ std::tuple("", std::vector<std::string>{}, true),
+ std::tuple("", std::vector<std::string>{"b"}, true),
+ std::tuple("a", std::vector<std::string>{"b"}, false),
+ std::tuple("!a", std::vector<std::string>{"b"}, true),
+ std::tuple("b", std::vector<std::string>{"b"}, true),
+ std::tuple("a|b", std::vector<std::string>{"b"}, true),
+ std::tuple("a & b", std::vector<std::string>{"b"}, false),
+ std::tuple("(b)", std::vector<std::string>{"b"}, true),
+ std::tuple("a|(a|b)", std::vector<std::string>{"b"}, true),
+ std::tuple("(a|b)&(!a&b)", std::vector<std::string>{"b"}, true),
+ std::tuple("a&b", std::vector<std::string>{"a", "b"}, true),
+ std::tuple("(a|c)&(b|c)", std::vector<std::string>{"a", "b"}, true),
+ std::tuple("(a|b)&c", std::vector<std::string>{"a", "b"}, false),
+ std::tuple("a|b|c", std::vector<std::string>{"b"}, true),
+ std::tuple("!a & b & !c", std::vector<std::string>{"b"}, true),
+ std::tuple("var-1 | !var/2", std::vector<std::string>{"var-1"}, true),
+ std::tuple("var-1 | !var/2", std::vector<std::string>{"var/2"}, false),
+ std::tuple("var-1 | !var/2", std::vector<std::string>{}, true),
+ std::tuple("!in-", std::vector<std::string>{}, true),
+ std::tuple("in/|x", std::vector<std::string>{"in/"}, true),
+ std::tuple("%true", std::vector<std::string>{""}, true),
+ std::tuple("%false", std::vector<std::string>{"false"}, false),
+ std::tuple("%true|%false", std::vector<std::string>{""}, true),
+ std::tuple("a.b.c-d.e:1234", std::vector<std::string>{"a.b.c-d.e:1234"}, true),
+ std::tuple("!a.b.c-d.e:1234", std::vector<std::string>{"a.b.c-d.e:1234"}, false)
));
////////////////////////////////////////////////////////////////////////////////
@@ -165,7 +166,7 @@ TEST(TBooleanFormulaTest, ExternalOperators)
auto aOrB = formulaA | formulaB;
auto notA = !formulaA;
- for (auto vars : std::vector<std::vector<TString>>{{}, {"a"}, {"b"}, {"a", "b"}}) {
+ for (auto vars : std::vector<std::vector<std::string>>{{}, {"a"}, {"b"}, {"a", "b"}}) {
bool resA = formulaA.IsSatisfiedBy(vars);
bool resB = formulaB.IsSatisfiedBy(vars);
@@ -175,25 +176,25 @@ TEST(TBooleanFormulaTest, ExternalOperators)
}
EXPECT_FALSE((!MakeBooleanFormula("a | b"))
- .IsSatisfiedBy(std::vector<TString>{"b"}));
+ .IsSatisfiedBy(std::vector<std::string>{"b"}));
EXPECT_EQ((formulaA & formulaB).GetFormula(), "(a) & (b)");
EXPECT_EQ((formulaA | formulaB).GetFormula(), "(a) | (b)");
EXPECT_EQ((!formulaA).GetFormula(), "!(a)");
auto empty = MakeBooleanFormula("");
- EXPECT_TRUE(empty.IsSatisfiedBy(THashSet<TString>{}));
- EXPECT_FALSE((!empty).IsSatisfiedBy(THashSet<TString>{}));
- EXPECT_TRUE((empty | !empty).IsSatisfiedBy(THashSet<TString>{}));
-
- EXPECT_TRUE((empty | formulaA).IsSatisfiedBy(THashSet<TString>{}));
- EXPECT_TRUE((empty | formulaA).IsSatisfiedBy(THashSet<TString>{"a"}));
- EXPECT_TRUE((formulaA | empty).IsSatisfiedBy(THashSet<TString>{}));
- EXPECT_TRUE((formulaA | empty).IsSatisfiedBy(THashSet<TString>{"a"}));
- EXPECT_FALSE((empty & formulaA).IsSatisfiedBy(THashSet<TString>{}));
- EXPECT_TRUE((empty & formulaA).IsSatisfiedBy(THashSet<TString>{"a"}));
- EXPECT_FALSE((formulaA & empty).IsSatisfiedBy(THashSet<TString>{}));
- EXPECT_TRUE((formulaA & empty).IsSatisfiedBy(THashSet<TString>{"a"}));
+ EXPECT_TRUE(empty.IsSatisfiedBy(THashSet<std::string>{}));
+ EXPECT_FALSE((!empty).IsSatisfiedBy(THashSet<std::string>{}));
+ EXPECT_TRUE((empty | !empty).IsSatisfiedBy(THashSet<std::string>{}));
+
+ EXPECT_TRUE((empty | formulaA).IsSatisfiedBy(THashSet<std::string>{}));
+ EXPECT_TRUE((empty | formulaA).IsSatisfiedBy(THashSet<std::string>{"a"}));
+ EXPECT_TRUE((formulaA | empty).IsSatisfiedBy(THashSet<std::string>{}));
+ EXPECT_TRUE((formulaA | empty).IsSatisfiedBy(THashSet<std::string>{"a"}));
+ EXPECT_FALSE((empty & formulaA).IsSatisfiedBy(THashSet<std::string>{}));
+ EXPECT_TRUE((empty & formulaA).IsSatisfiedBy(THashSet<std::string>{"a"}));
+ EXPECT_FALSE((formulaA & empty).IsSatisfiedBy(THashSet<std::string>{}));
+ EXPECT_TRUE((formulaA & empty).IsSatisfiedBy(THashSet<std::string>{"a"}));
}
////////////////////////////////////////////////////////////////////////////////