Skip to content

Commit 65a239f

Browse files
committed
streamlookup/generic actor: replace direct actor usage with events (UB)
1 parent 93881c1 commit 65a239f

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

ydb/library/yql/dq/actors/input_transforms/dq_input_transform_lookup.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ class TInputTransformStreamLookupBase
9090
.MaxKeysInRequest = 1000 // TODO configure me
9191
};
9292
auto guard = Guard(*Alloc);
93-
LookupSource = Factory->CreateDqLookupSource(Settings.GetRightSource().GetProviderName(), std::move(lookupSourceArgs));
94-
RegisterWithSameMailbox(LookupSource.second);
93+
auto LookupSource = Factory->CreateDqLookupSource(Settings.GetRightSource().GetProviderName(), std::move(lookupSourceArgs));
94+
MaxKeysInRequest = LookupSource.first->GetMaxSupportedKeysInRequest();
95+
LookupSourceId = RegisterWithSameMailbox(LookupSource.second);
9596
}
9697
protected:
9798
virtual NUdf::EFetchStatus FetchWideInputValue(NUdf::TUnboxedValue* inputRowItems) = 0;
@@ -165,7 +166,7 @@ class TInputTransformStreamLookupBase
165166
}
166167

167168
void PassAway() final {
168-
Send(LookupSource.second->SelfId(), new NActors::TEvents::TEvPoison{});
169+
Send(LookupSourceId, new NActors::TEvents::TEvPoison{});
169170
auto guard = BindAllocator();
170171
//All resources, held by this class, that have been created with mkql allocator, must be deallocated here
171172
KeysForLookup.reset();
@@ -193,11 +194,10 @@ class TInputTransformStreamLookupBase
193194
NUdf::TUnboxedValue* inputRowItems;
194195
NUdf::TUnboxedValue inputRow = HolderFactory.CreateDirectArrayHolder(InputRowType->GetElementsCount(), inputRowItems);
195196
const auto now = std::chrono::steady_clock::now();
196-
const auto maxKeysInRequest = LookupSource.first->GetMaxSupportedKeysInRequest();
197-
KeysForLookup = std::make_shared<IDqAsyncLookupSource::TUnboxedValueMap>(maxKeysInRequest, KeyTypeHelper->GetValueHash(), KeyTypeHelper->GetValueEqual());
197+
KeysForLookup = std::make_shared<IDqAsyncLookupSource::TUnboxedValueMap>(MaxKeysInRequest, KeyTypeHelper->GetValueHash(), KeyTypeHelper->GetValueEqual());
198198
LruCache->Prune(now);
199199
while (
200-
(KeysForLookup->size() < maxKeysInRequest) &&
200+
(KeysForLookup->size() < MaxKeysInRequest) &&
201201
((InputFlowFetchStatus = FetchWideInputValue(inputRowItems)) == NUdf::EFetchStatus::Ok)) {
202202
NUdf::TUnboxedValue* keyItems;
203203
NUdf::TUnboxedValue key = HolderFactory.CreateDirectArrayHolder(LookupInputIndexes.size(), keyItems);
@@ -217,7 +217,7 @@ class TInputTransformStreamLookupBase
217217
}
218218
}
219219
if (!KeysForLookup->empty()) {
220-
LookupSource.first->AsyncLookup(KeysForLookup);
220+
Send(LookupSourceId, new IDqAsyncLookupSource::TEvLookupRequest(KeysForLookup));
221221
} else {
222222
KeysForLookup.reset();
223223
}
@@ -261,7 +261,8 @@ class TInputTransformStreamLookupBase
261261
IDqAsyncIoFactory::TPtr Factory;
262262
NDqProto::TDqInputTransformLookupSettings Settings;
263263
protected:
264-
std::pair<IDqAsyncLookupSource*, NActors::IActor*> LookupSource;
264+
NActors::TActorId LookupSourceId;
265+
size_t MaxKeysInRequest;
265266
const TVector<size_t> LookupInputIndexes;
266267
const TVector<size_t> OtherInputIndexes;
267268
const NMiniKQL::TMultiType* const InputRowType;

ydb/library/yql/providers/generic/actors/yql_generic_lookup_actor.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ namespace NYql::NDq {
128128

129129
private: // events
130130
STRICT_STFUNC(StateFunc,
131+
hFunc(TEvLookupRequest, Handle);
131132
hFunc(TEvListSplitsIterator, Handle);
132133
hFunc(TEvListSplitsPart, Handle);
133134
hFunc(TEvReadSplitsIterator, Handle);
@@ -201,6 +202,11 @@ namespace NYql::NDq {
201202
PassAway();
202203
}
203204

205+
void Handle(TEvLookupRequest::TPtr ev) {
206+
auto guard = Guard(*Alloc);
207+
CreateRequest(ev->Get()->Request.lock());
208+
}
209+
204210
private:
205211
void CreateRequest(std::shared_ptr<IDqAsyncLookupSource::TUnboxedValueMap> request) {
206212
if (!request) {

0 commit comments

Comments
 (0)