diff options
author | danilalexeev <danilalexeev@yandex-team.com> | 2024-04-23 12:40:06 +0300 |
---|---|---|
committer | danilalexeev <danilalexeev@yandex-team.com> | 2024-04-23 12:54:36 +0300 |
commit | 74b23032a9cb2895736ba19d0052edd34327342a (patch) | |
tree | 184d93461dcb68639c5fdd3ac50bf6c5221fea08 | |
parent | ae5472d0928c374dc719b154c9dcb2be6e0a0695 (diff) | |
download | ydb-74b23032a9cb2895736ba19d0052edd34327342a.tar.gz |
YT-21382: Introduce new classes for relative and absolute YPath entities
New classes are introduced, splitting the existing NSequoiaClient::TYPath in two. TAbsoluteYPath represents an absolute path in Cypress, i.e. anything what starts with a root designator. TYPath is restricted to relative paths only, beginning with a single / (or maybe an ampersand).
3efc67fddbb83f10f449bee6f3bd18d3c1f425f8
-rw-r--r-- | yt/yt/core/ypath/helpers.cpp | 11 | ||||
-rw-r--r-- | yt/yt/core/ypath/helpers.h | 3 | ||||
-rw-r--r-- | yt/yt/core/ytree/helpers.cpp | 2 | ||||
-rw-r--r-- | yt/yt/core/ytree/helpers.h | 2 | ||||
-rw-r--r-- | yt/yt/core/ytree/public.h | 1 | ||||
-rw-r--r-- | yt/yt/core/ytree/ypath_client.cpp | 4 | ||||
-rw-r--r-- | yt/yt/core/ytree/ypath_client.h | 2 | ||||
-rw-r--r-- | yt/yt/core/ytree/ypath_detail.h | 12 |
8 files changed, 12 insertions, 25 deletions
diff --git a/yt/yt/core/ypath/helpers.cpp b/yt/yt/core/ypath/helpers.cpp index add594da57..3a8675a3b3 100644 --- a/yt/yt/core/ypath/helpers.cpp +++ b/yt/yt/core/ypath/helpers.cpp @@ -75,17 +75,6 @@ TYPath StripAttributes(const TYPath& path) return path; } -TString ToStringLiteral(const TYPath& path) -{ - TStringBuilder builder; - for (TTokenizer tokenizer(path); tokenizer.GetType() != ETokenType::EndOfStream; tokenizer.Advance()) { - builder.AppendString(tokenizer.GetType() == ETokenType::Literal - ? tokenizer.GetLiteralValue() - : TString(tokenizer.GetToken())); - } - return builder.Flush(); -} - //////////////////////////////////////////////////////////////////////////////// } // namespace NYT::NYPath diff --git a/yt/yt/core/ypath/helpers.h b/yt/yt/core/ypath/helpers.h index e9eb3551bb..ca675f4eaf 100644 --- a/yt/yt/core/ypath/helpers.h +++ b/yt/yt/core/ypath/helpers.h @@ -23,9 +23,6 @@ TYPath StripAttributes(const TYPath& path); template <typename ...TArgs> TYPath YPathJoin(const TYPath& path, TArgs&&... literals); -//! Changes all literal tokens in YPath to their literal values. -TString ToStringLiteral(const TYPath& path); - //////////////////////////////////////////////////////////////////////////////// } // namespace NYT::NYPath diff --git a/yt/yt/core/ytree/helpers.cpp b/yt/yt/core/ytree/helpers.cpp index ed5dd5a0d5..348cfc32fc 100644 --- a/yt/yt/core/ytree/helpers.cpp +++ b/yt/yt/core/ytree/helpers.cpp @@ -313,7 +313,7 @@ void ValidateYTreeKey(TStringBuf key) #endif } -void ValidateYPathResolutionDepth(const TYPath& path, int depth) +void ValidateYPathResolutionDepth(TYPathBuf path, int depth) { if (depth > MaxYPathResolveIterations) { THROW_ERROR_EXCEPTION( diff --git a/yt/yt/core/ytree/helpers.h b/yt/yt/core/ytree/helpers.h index b7308f30de..2d5b4fc8ec 100644 --- a/yt/yt/core/ytree/helpers.h +++ b/yt/yt/core/ytree/helpers.h @@ -48,7 +48,7 @@ struct TAttributeDictionarySerializer void ValidateYTreeKey(TStringBuf key); -void ValidateYPathResolutionDepth(const NYPath::TYPath& path, int depth); +void ValidateYPathResolutionDepth(TYPathBuf path, int depth); //! Helps implementing IAttributeDictionary::ListPairs by delegating to //! IAttributeDictionary::ListKeys and IAttributeDictionary::FindYson for those not capable diff --git a/yt/yt/core/ytree/public.h b/yt/yt/core/ytree/public.h index 2c51214527..76e104d285 100644 --- a/yt/yt/core/ytree/public.h +++ b/yt/yt/core/ytree/public.h @@ -65,6 +65,7 @@ class TTypedYPathResponse; DECLARE_REFCOUNTED_CLASS(TServiceCombiner) using NYPath::TYPath; +using NYPath::TYPathBuf; //! Default limit for List and Get requests to virtual nodes. constexpr i64 DefaultVirtualChildLimit = 1000; diff --git a/yt/yt/core/ytree/ypath_client.cpp b/yt/yt/core/ytree/ypath_client.cpp index ef2fbaf76c..b7bf13d3dd 100644 --- a/yt/yt/core/ytree/ypath_client.cpp +++ b/yt/yt/core/ytree/ypath_client.cpp @@ -261,10 +261,10 @@ TYPathMaybeRef GetOriginalRequestTargetYPath(const NRpc::NProto::TRequestHeader& : TYPathMaybeRef(ypathExt.target_path()); } -void SetRequestTargetYPath(NRpc::NProto::TRequestHeader* header, TYPath path) +void SetRequestTargetYPath(NRpc::NProto::TRequestHeader* header, TYPathBuf path) { auto* ypathExt = header->MutableExtension(NProto::TYPathHeaderExt::ypath_header_ext); - ypathExt->set_target_path(std::move(path)); + ypathExt->set_target_path(TYPath(path)); } bool IsRequestMutating(const NRpc::NProto::TRequestHeader& header) diff --git a/yt/yt/core/ytree/ypath_client.h b/yt/yt/core/ytree/ypath_client.h index bb13e650d6..58bcae8da2 100644 --- a/yt/yt/core/ytree/ypath_client.h +++ b/yt/yt/core/ytree/ypath_client.h @@ -204,7 +204,7 @@ using TYPathMaybeRef = std::conditional_t<IsArcadiaProtobuf, const TYPath&, TYPa TYPathMaybeRef GetRequestTargetYPath(const NRpc::NProto::TRequestHeader& header); TYPathMaybeRef GetOriginalRequestTargetYPath(const NRpc::NProto::TRequestHeader& header); -void SetRequestTargetYPath(NRpc::NProto::TRequestHeader* header, TYPath path); +void SetRequestTargetYPath(NRpc::NProto::TRequestHeader* header, TYPathBuf path); bool IsRequestMutating(const NRpc::NProto::TRequestHeader& header); diff --git a/yt/yt/core/ytree/ypath_detail.h b/yt/yt/core/ytree/ypath_detail.h index b952736463..856a225c8e 100644 --- a/yt/yt/core/ytree/ypath_detail.h +++ b/yt/yt/core/ytree/ypath_detail.h @@ -145,8 +145,8 @@ protected: protected: \ DECLARE_YPATH_SERVICE_METHOD(::NYT::NYTree::NProto, method); \ virtual void method##Self(TReq##method* request, TRsp##method* response, const TCtx##method##Ptr& context); \ - virtual void method##Recursive(const TYPath& path, TReq##method* request, TRsp##method* response, const TCtx##method##Ptr& context); \ - virtual void method##Attribute(const TYPath& path, TReq##method* request, TRsp##method* response, const TCtx##method##Ptr& context); \ + virtual void method##Recursive(const NYPath::TYPath& path, TReq##method* request, TRsp##method* response, const TCtx##method##Ptr& context); \ + virtual void method##Attribute(const NYPath::TYPath& path, TReq##method* request, TRsp##method* response, const TCtx##method##Ptr& context); \ } #define IMPLEMENT_SUPPORTS_METHOD_RESOLVE(method, onPathError) \ @@ -163,9 +163,9 @@ protected: return; \ } \ if (tokenizer.Advance() == NYPath::ETokenType::At) { \ - method##Attribute(TYPath(tokenizer.GetSuffix()), request, response, context); \ + method##Attribute(NYPath::TYPath(tokenizer.GetSuffix()), request, response, context); \ } else { \ - method##Recursive(TYPath(tokenizer.GetInput()), request, response, context); \ + method##Recursive(NYPath::TYPath(tokenizer.GetInput()), request, response, context); \ } \ } @@ -177,7 +177,7 @@ protected: } \ ) \ \ - void TSupports##method::method##Attribute(const TYPath& /*path*/, TReq##method* /*request*/, TRsp##method* /*response*/, const TCtx##method##Ptr& context) \ + void TSupports##method::method##Attribute(const NYPath::TYPath& /*path*/, TReq##method* /*request*/, TRsp##method* /*response*/, const TCtx##method##Ptr& context) \ { \ ThrowMethodNotSupported(context->GetMethod(), TString("attribute")); \ } \ @@ -187,7 +187,7 @@ protected: ThrowMethodNotSupported(context->GetMethod(), TString("self")); \ } \ \ - void TSupports##method::method##Recursive(const TYPath& /*path*/, TReq##method* /*request*/, TRsp##method* /*response*/, const TCtx##method##Ptr& context) \ + void TSupports##method::method##Recursive(const NYPath::TYPath& /*path*/, TReq##method* /*request*/, TRsp##method* /*response*/, const TCtx##method##Ptr& context) \ { \ ThrowMethodNotSupported(context->GetMethod(), TString("recursive")); \ } |