aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormakostrov <makostrov@yandex-team.com>2023-10-06 15:12:31 +0300
committermakostrov <makostrov@yandex-team.com>2023-10-06 16:28:48 +0300
commit468c345e7b8b338497bf46fd15d94ea316689ad7 (patch)
tree13f4d2b22b6d9e89a17378cbb21e472b5c0ff492
parent80e0282a2e4592c7b71963ebadfb13b4900afa67 (diff)
downloadydb-468c345e7b8b338497bf46fd15d94ea316689ad7.tar.gz
RegisterSource - change name and signature
KIKIMR-19032 Этот PR - доработка предыдущего PR по данной задаче Теперь две функции RegisterSource называются одинаково и в комментариях я объяснил в чём их различие и когда какую нужно использовать
-rw-r--r--ydb/core/kqp/runtime/kqp_read_actor.cpp2
-rw-r--r--ydb/library/yql/dq/actors/compute/dq_compute_actor_async_io_factory.h18
2 files changed, 14 insertions, 6 deletions
diff --git a/ydb/core/kqp/runtime/kqp_read_actor.cpp b/ydb/core/kqp/runtime/kqp_read_actor.cpp
index b00a5e64bf9..e2348c29370 100644
--- a/ydb/core/kqp/runtime/kqp_read_actor.cpp
+++ b/ydb/core/kqp/runtime/kqp_read_actor.cpp
@@ -1446,7 +1446,7 @@ private:
void RegisterKqpReadActor(NYql::NDq::TDqAsyncIoFactory& factory, TIntrusivePtr<TKqpCounters> counters) {
- factory.RegisterSourceWithPtr<NKikimrTxDataShard::TKqpReadRangesSourceSettings>(
+ factory.RegisterSource<NKikimrTxDataShard::TKqpReadRangesSourceSettings>(
TString(NYql::KqpReadRangesSourceName),
[counters] (const NKikimrTxDataShard::TKqpReadRangesSourceSettings* settings, NYql::NDq::TDqAsyncIoFactory::TSourceArguments&& args) {
auto* actor = new TKqpReadActor(settings, args, counters);
diff --git a/ydb/library/yql/dq/actors/compute/dq_compute_actor_async_io_factory.h b/ydb/library/yql/dq/actors/compute/dq_compute_actor_async_io_factory.h
index 53b3e2762e3..e6a4a07a576 100644
--- a/ydb/library/yql/dq/actors/compute/dq_compute_actor_async_io_factory.h
+++ b/ydb/library/yql/dq/actors/compute/dq_compute_actor_async_io_factory.h
@@ -21,7 +21,7 @@ concept TSourceCreatorFunc = requires(T f, TProto&& settings, IDqAsyncIoFactory:
};
template <class T, class TProto>
-concept TSourceCreatorFuncMove = requires(T f, TProto* settings, IDqAsyncIoFactory::TSourceArguments&& args) {
+concept TSourceCreatorFuncPtr = requires(T f, TProto* settings, IDqAsyncIoFactory::TSourceArguments&& args) {
{ f(settings, std::move(args)) } -> TCastsToAsyncInputPair;
};
@@ -54,17 +54,24 @@ public:
// Registration
void RegisterSource(const TString& type, TSourceCreatorFunction creator);
+ // There are 2 functions to register source
+ // The main difference between them is:
+ // First function uses Arena to allocate SourceSettings
+ // Second function doesn't use Arena, instead it allocates SourceSettings on the stack
- // This function expects to have Arena where SourceSettings are allocated or will be allocated
- template <class TProtoMsg, TSourceCreatorFuncMove<TProtoMsg> TCreatorFunc>
- void RegisterSourceWithPtr(const TString& type, TCreatorFunc creator) { // WithArena
+ // This function expects to have Arena where SourceSettings (are / would be) allocated
+ // This function expects to have CreatorFunc with ( TProto* settings ),
+ template <class TProtoMsg, TSourceCreatorFuncPtr<TProtoMsg> TCreatorFunc>
+ void RegisterSource(const TString& type, TCreatorFunc creator) {
RegisterSource(type,
[creator = std::move(creator), type](TSourceArguments&& args)
{
YQL_ENSURE(args.Arena, "args are expected to have Arena for SourceSettings");
if (args.SourceSettings != nullptr) {
const TProtoMsg* settingsPtr = dynamic_cast<const TProtoMsg*>(args.SourceSettings);
- YQL_ENSURE(settingsPtr);
+ YQL_ENSURE(settingsPtr, "Wrong type of source settings");
+ YQL_ENSURE(settingsPtr->GetArena(), "Source settings are expected to be allocated in arena");
+ YQL_ENSURE(settingsPtr->GetArena() == args.Arena->Get(), "(Given Arena) and (Arena from SourceSettings) are not the same");
return creator(settingsPtr, std::move(args));
} else {
const google::protobuf::Any& settingsAny = args.InputDesc.GetSource().GetSettings();
@@ -78,6 +85,7 @@ public:
});
}
+ // This function doesn't use Arena, and SourceSettings are passed to CreatorFunc by rvalue reference
template <class TProtoMsg, TSourceCreatorFunc<TProtoMsg> TCreatorFunc>
void RegisterSource(const TString& type, TCreatorFunc creator) {
RegisterSource(type,