aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcherepashka <cherepashka@yandex-team.com>2025-06-26 11:02:50 +0300
committercherepashka <cherepashka@yandex-team.com>2025-06-26 11:52:34 +0300
commit1fb55d96e53be6c82452a54d6bd1c838464d10d3 (patch)
treee6ed160fc2e31270d63996528b432fb8e041c46b
parentd1fe3a9fc27420b89499153408c5d2bbbe24d812 (diff)
downloadydb-1fb55d96e53be6c82452a54d6bd1c838464d10d3.tar.gz
YT-23994: Making TAttributeFilter to be a class with private keys and paths
* Changelog entry Type: fix Component: master Fix TAttributeFilter \[nodiff:caesar\] commit_hash:e041b639c8f8df217a8fd94e57f9a545408a897b
-rw-r--r--yt/yt/core/ytree/attribute_filter-inl.h2
-rw-r--r--yt/yt/core/ytree/attribute_filter.cpp21
-rw-r--r--yt/yt/core/ytree/attribute_filter.h11
-rw-r--r--yt/yt/core/ytree/public.h2
4 files changed, 10 insertions, 26 deletions
diff --git a/yt/yt/core/ytree/attribute_filter-inl.h b/yt/yt/core/ytree/attribute_filter-inl.h
index 34c1934284d..0f6a0d34d94 100644
--- a/yt/yt/core/ytree/attribute_filter-inl.h
+++ b/yt/yt/core/ytree/attribute_filter-inl.h
@@ -11,7 +11,7 @@ namespace NYT::NYTree {
template <class T>
TAttributeFilter::TAttributeFilter(std::initializer_list<T> keys)
: Keys_({keys.begin(), keys.end()})
- , Universal(false)
+ , Universal_(false)
{ }
////////////////////////////////////////////////////////////////////////////////
diff --git a/yt/yt/core/ytree/attribute_filter.cpp b/yt/yt/core/ytree/attribute_filter.cpp
index a129bbc5ed3..614365c7d9e 100644
--- a/yt/yt/core/ytree/attribute_filter.cpp
+++ b/yt/yt/core/ytree/attribute_filter.cpp
@@ -199,22 +199,22 @@ std::unique_ptr<IHeterogenousFilterConsumer> CreateFilteringConsumerImpl(
TAttributeFilter::TAttributeFilter(std::vector<IAttributeDictionary::TKey> keys, std::vector<TYPath> paths)
: Keys_(std::move(keys))
, Paths_(std::move(paths))
- , Universal(false)
+ , Universal_(false)
{ }
TAttributeFilter::TAttributeFilter(std::initializer_list<TString> keys)
: Keys_({keys.begin(), keys.end()})
- , Universal(false)
+ , Universal_(false)
{ }
TAttributeFilter::TAttributeFilter(const std::vector<TString>& keys)
: Keys_({keys.begin(), keys.end()})
- , Universal(false)
+ , Universal_(false)
{ }
TAttributeFilter::operator bool() const
{
- return !Universal;
+ return !Universal_;
}
void TAttributeFilter::ValidateKeysOnly(TStringBuf context) const
@@ -226,18 +226,7 @@ void TAttributeFilter::ValidateKeysOnly(TStringBuf context) const
bool TAttributeFilter::IsEmpty() const
{
- return !Universal && Keys_.empty() && Paths_.empty();
-}
-
-void TAttributeFilter::AddKey(IAttributeDictionary::TKey key)
-{
- Universal = false;
- Keys_.emplace_back(std::move(key));
-}
-
-void TAttributeFilter::ReserveKeys(size_t capacity)
-{
- Keys_.reserve(capacity);
+ return !Universal_ && Keys_.empty() && Paths_.empty();
}
bool TAttributeFilter::AdmitsKeySlow(TStringBuf key) const
diff --git a/yt/yt/core/ytree/attribute_filter.h b/yt/yt/core/ytree/attribute_filter.h
index 1ec190f71a8..ba74a4bfa12 100644
--- a/yt/yt/core/ytree/attribute_filter.h
+++ b/yt/yt/core/ytree/attribute_filter.h
@@ -63,7 +63,7 @@ namespace NYT::NYTree {
* Filter = {.Keys = {}; .Paths = {}, .Universal = true}
* Result depends on implementation.
*/
-struct TAttributeFilter
+class TAttributeFilter
{
//! Whitelist of top-level keys to be returned.
DEFINE_BYREF_RO_PROPERTY(std::vector<IAttributeDictionary::TKey>, Keys);
@@ -71,8 +71,9 @@ struct TAttributeFilter
//! If true, filter is universal, i.e. behavior depends on service's own policy;
//! in such case #Keys and #Paths are always empty.
- bool Universal = true;
+ DEFINE_BYVAL_RO_BOOLEAN_PROPERTY(Universal, true);
+public:
//! Creates a universal filter.
TAttributeFilter() = default;
@@ -100,12 +101,6 @@ struct TAttributeFilter
//! error message.
void ValidateKeysOnly(TStringBuf context = "this context") const;
- //! Adds key. Makes attribute filter not universal if it was universal.
- void AddKey(IAttributeDictionary::TKey key);
-
- //! Reserve keys.
- void ReserveKeys(size_t capacity);
-
//! Returns true if #key appears in Keys or "/#key" appears in Paths using linear search.
bool AdmitsKeySlow(IAttributeDictionary::TKeyView key) const;
diff --git a/yt/yt/core/ytree/public.h b/yt/yt/core/ytree/public.h
index deac48ae912..10a22d674be 100644
--- a/yt/yt/core/ytree/public.h
+++ b/yt/yt/core/ytree/public.h
@@ -17,7 +17,7 @@ class TAttributeFilter;
} // namespace NProto
-struct TAttributeFilter;
+class TAttributeFilter;
struct IYsonStructMeta;
class TYsonStructBase;