Skip to content

Commit e152490

Browse files
authored
YQL-17542 get rid of std::any in handling sources state (#1635)
1 parent f79fd8f commit e152490

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

ydb/core/kqp/compute_actor/kqp_scan_compute_actor.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -156,22 +156,18 @@ void TKqpScanComputeActor::Handle(TEvScanExchange::TEvFetcherFinished::TPtr& ev)
156156
}
157157
}
158158

159-
void TKqpScanComputeActor::PollSources(std::any prev) {
159+
void TKqpScanComputeActor::PollSources(ui64 prevFreeSpace) {
160160
if (!ScanData || ScanData->IsFinished()) {
161161
return;
162162
}
163163
const auto hasNewMemoryPred = [&]() {
164-
if (!prev.has_value()) {
165-
return false;
166-
}
167164
const ui64 freeSpace = CalculateFreeSpace();
168-
const ui64 prevFreeSpace = std::any_cast<ui64>(prev);
169165
return freeSpace > prevFreeSpace;
170166
};
171167
if (!hasNewMemoryPred() && ScanData->GetStoredBytes()) {
172168
return;
173169
}
174-
const ui32 freeSpace = CalculateFreeSpace();
170+
const ui64 freeSpace = CalculateFreeSpace();
175171
CA_LOG_D("POLL_SOURCES:START:" << Fetchers.size() << ";fs=" << freeSpace);
176172
for (auto&& i : Fetchers) {
177173
Send(i, new TEvScanExchange::TEvAckData(freeSpace));

ydb/core/kqp/compute_actor/kqp_scan_compute_actor.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ class TKqpScanComputeActor: public NYql::NDq::TDqSyncComputeActorBase<TKqpScanCo
8282
: 0ul;
8383
}
8484

85-
std::any GetSourcesState() override {
85+
ui64 GetSourcesState() {
8686
if (!ScanData) {
8787
return 0;
8888
}
8989
return CalculateFreeSpace();
9090
}
9191

92-
void PollSources(std::any prev) override;
92+
void PollSources(ui64 prevFreeSpace);
9393

9494
void PassAway() override {
9595
if (TaskRunner) {

ydb/library/yql/dq/actors/compute/dq_compute_actor_impl.h

+11-9
Original file line numberDiff line numberDiff line change
@@ -311,15 +311,15 @@ class TDqComputeActorBase : public NActors::TActorBootstrapped<TDerived>
311311
}
312312

313313
virtual void DoExecuteImpl() {
314-
auto sourcesState = GetSourcesState();
314+
auto sourcesState = static_cast<TDerived*>(this)->GetSourcesState();
315315

316316
PollAsyncInput();
317317
ERunStatus status = TaskRunner->Run();
318318

319319
CA_LOG_T("Resume execution, run status: " << status);
320320

321321
if (status != ERunStatus::Finished) {
322-
PollSources(std::move(sourcesState));
322+
static_cast<TDerived*>(this)->PollSources(std::move(sourcesState));
323323
}
324324

325325
if ((status == ERunStatus::PendingInput || status == ERunStatus::Finished) && Checkpoints && Checkpoints->HasPendingCheckpoint() && !Checkpoints->ComputeActorStateSaved() && ReadyToCheckpoint()) {
@@ -1049,13 +1049,6 @@ class TDqComputeActorBase : public NActors::TActorBootstrapped<TDerived>
10491049
protected:
10501050
// virtual methods (TODO: replace with static_cast<TDerived*>(this)->Foo()
10511051

1052-
virtual std::any GetSourcesState() {
1053-
return nullptr;
1054-
}
1055-
1056-
virtual void PollSources(std::any /* state */) {
1057-
}
1058-
10591052
virtual void TerminateSources(const TIssues& /* issues */, bool /* success */) {
10601053
}
10611054

@@ -1071,6 +1064,15 @@ class TDqComputeActorBase : public NActors::TActorBootstrapped<TDerived>
10711064
return true;
10721065
}
10731066

1067+
protected:
1068+
// methods that are called via static_cast<TDerived*>(this) and may be overriden by a dervied class
1069+
void* GetSourcesState() const {
1070+
return nullptr;
1071+
}
1072+
void PollSources(void* /* state */) {
1073+
}
1074+
1075+
10741076
protected:
10751077
void HandleExecuteBase(TEvDqCompute::TEvResumeExecution::TPtr&) {
10761078
ResumeEventScheduled = false;

0 commit comments

Comments
 (0)