diff options
author | ilnaz <ilnaz@ydb.tech> | 2022-09-11 17:30:43 +0300 |
---|---|---|
committer | ilnaz <ilnaz@ydb.tech> | 2022-09-11 17:30:43 +0300 |
commit | d8a7d202e3306ff3a4c14144abf3fae7aadad3a3 (patch) | |
tree | f9b26eb0c7c3d9b61e24536132a0c5fe95f9f1ea | |
parent | e6a7bb384bbe7e480192a4aad4f8f9067a76e47f (diff) | |
download | ydb-d8a7d202e3306ff3a4c14144abf3fae7aadad3a3.tar.gz |
Describe changefeed as well as topic
3 files changed, 64 insertions, 8 deletions
diff --git a/contrib/restricted/boost/date_time/include/boost/date_time/special_values_parser.hpp b/contrib/restricted/boost/date_time/include/boost/date_time/special_values_parser.hpp index b0813cbdbc..7b493c8945 100644 --- a/contrib/restricted/boost/date_time/include/boost/date_time/special_values_parser.hpp +++ b/contrib/restricted/boost/date_time/include/boost/date_time/special_values_parser.hpp @@ -97,7 +97,7 @@ namespace boost { namespace date_time { //! match() should be called and return value checked. //! \param[in] str the string to check //! \returns false if it is definitely not a special value - static bool likely2(const string_type& str) // XXX: change name because it conflicts with macro likely defined in clickhouse + static bool should_call_match(const string_type& str) { if (!str.empty()) { switch (str[0]) { diff --git a/contrib/restricted/boost/date_time/include/boost/date_time/time_parsing.hpp b/contrib/restricted/boost/date_time/include/boost/date_time/time_parsing.hpp index b47faf58e9..9e7a3fb5f9 100644 --- a/contrib/restricted/boost/date_time/include/boost/date_time/time_parsing.hpp +++ b/contrib/restricted/boost/date_time/include/boost/date_time/time_parsing.hpp @@ -309,7 +309,7 @@ namespace date_time { // then from_iso_string should be able to read a special value string // the special_values_parser is expensive to set up and not thread-safe // so it cannot be static, so we need to be careful about when we use it - if (svp_type::likely2(s)) { + if (svp_type::should_call_match(s)) { typedef typename svp_type::stringstream_type ss_type; typedef typename svp_type::stream_itr_type itr_type; typedef typename svp_type::match_results mr_type; diff --git a/ydb/core/grpc_services/rpc_describe_path.cpp b/ydb/core/grpc_services/rpc_describe_path.cpp index 7960f50779..9a3702e81a 100644 --- a/ydb/core/grpc_services/rpc_describe_path.cpp +++ b/ydb/core/grpc_services/rpc_describe_path.cpp @@ -5,12 +5,14 @@ #include "rpc_common.h" #include <ydb/core/protos/flat_tx_scheme.pb.h> #include <ydb/core/tx/schemeshard/schemeshard.h> +#include <ydb/core/tx/scheme_cache/scheme_cache.h> #include <ydb/core/ydb_convert/ydb_convert.h> namespace NKikimr { namespace NGRpcService { using namespace NActors; +using namespace NSchemeCache; using namespace Ydb; using TEvListDirectoryRequest = TGrpcRequestOperationCall<Ydb::Scheme::ListDirectoryRequest, @@ -29,22 +31,70 @@ public: void Bootstrap(const TActorContext &ctx) { TBase::Bootstrap(ctx); - - SendProposeRequest(ctx); - this->Become(&TDerived::StateWork); + ResolvePath(ctx); } private: - void SendProposeRequest(const TActorContext &ctx) { - const auto req = this->GetProtoRequest(); + void ResolvePath(const TActorContext& ctx) { + auto request = MakeHolder<TSchemeCacheNavigate>(); + request->DatabaseName = NKikimr::CanonizePath(this->Request_->GetDatabaseName().GetOrElse("")); + + auto& entry = request->ResultSet.emplace_back(); + entry.Operation = TSchemeCacheNavigate::OpList; // we need ListNodeEntry + entry.Path = NKikimr::SplitPath(this->GetProtoRequest()->path()); + + ctx.Send(MakeSchemeCacheID(), new TEvTxProxySchemeCache::TEvNavigateKeySet(request.Release())); + this->Become(&TDerived::StateResolvePath); + } + + void StateResolvePath(TAutoPtr<IEventHandle>& ev, const TActorContext& ctx) { + switch (ev->GetTypeRewrite()) { + HFunc(TEvTxProxySchemeCache::TEvNavigateKeySetResult, Handle); + default: TBase::StateWork(ev, ctx); + } + } + + void Handle(TEvTxProxySchemeCache::TEvNavigateKeySetResult::TPtr& ev, const TActorContext& ctx) { + const auto& request = ev->Get()->Request; + if (request->ResultSet.size() != 1) { + return this->Reply(Ydb::StatusIds::INTERNAL_ERROR, ctx); + } + + const auto& entry = request->ResultSet.front(); + if (entry.Status != TSchemeCacheNavigate::EStatus::Ok) { + return SendProposeRequest(ctx, this->GetProtoRequest()->path()); + } + if (entry.Kind != TSchemeCacheNavigate::EKind::KindCdcStream) { + return SendProposeRequest(ctx, this->GetProtoRequest()->path()); + } + + if (!entry.Self || !entry.ListNodeEntry) { + return SendProposeRequest(ctx, this->GetProtoRequest()->path()); + } + + if (entry.ListNodeEntry->Children.size() != 1) { + // not created yet + return this->Reply(Ydb::StatusIds::SCHEME_ERROR, ctx); + } + + OverrideName = entry.Self->Info.GetName(); + const auto& topicName = entry.ListNodeEntry->Children.at(0).Name; + + return SendProposeRequest(ctx, + NKikimr::JoinPath(NKikimr::ChildPath(NKikimr::SplitPath(this->GetProtoRequest()->path()), topicName))); + } + + void SendProposeRequest(const TActorContext& ctx, const TString& path) { std::unique_ptr<TEvTxUserProxy::TEvNavigate> navigateRequest(new TEvTxUserProxy::TEvNavigate()); SetAuthToken(navigateRequest, *this->Request_); SetDatabase(navigateRequest.get(), *this->Request_); NKikimrSchemeOp::TDescribePath* record = navigateRequest->Record.MutableDescribePath(); - record->SetPath(req->path()); + record->SetPath(path); + record->MutableOptions()->SetShowPrivateTable(OverrideName.Defined()); ctx.Send(MakeTxProxyID(), navigateRequest.release()); + this->Become(&TDerived::StateWork); } void StateWork(TAutoPtr<IEventHandle>& ev, const TActorContext& ctx) { @@ -68,6 +118,9 @@ private: case NKikimrScheme::StatusSuccess: { const auto& pathDescription = record.GetPathDescription(); ConvertDirectoryEntry(pathDescription, result.mutable_self(), true); + if (OverrideName) { + result.mutable_self()->set_name(*OverrideName); + } if constexpr (ListChildren) { for (const auto& child : pathDescription.GetChildren()) { ConvertDirectoryEntry(child, result.add_children(), false); @@ -90,6 +143,9 @@ private: } } } + +private: + TMaybe<TString> OverrideName; }; class TListDirectoryRPC : public TBaseDescribe<TListDirectoryRPC, TEvListDirectoryRequest, Ydb::Scheme::ListDirectoryResult, true> { |