Skip to content

Commit d2ecf39

Browse files
authored
[KIKIMR-22131] Add temporary feature-flag for new pattern cache in yql/essentials (#14891)
1 parent a3ac0d2 commit d2ecf39

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

ydb/library/yql/dq/runtime/dq_tasks_runner.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ class TDqTaskRunner : public IDqTaskRunner {
441441
std::shared_ptr<TPatternCacheEntry> entry;
442442
bool canBeCached;
443443
if (UseSeparatePatternAlloc(task) && Context.PatternCache) {
444+
#if !defined(NEW_PATTERN_CACHE_IN_MKQL)
444445
auto& cache = Context.PatternCache;
445446
auto ticket = cache->FindOrSubscribe(program.GetRaw());
446447
if (!ticket.HasFuture()) {
@@ -454,6 +455,27 @@ class TDqTaskRunner : public IDqTaskRunner {
454455
} else {
455456
entry = ticket.GetValueSync();
456457
}
458+
#else
459+
auto& cache = Context.PatternCache;
460+
auto future = cache->FindOrSubscribe(program.GetRaw());
461+
if (!future.HasValue()) {
462+
try {
463+
entry = CreateComputationPattern(task, program.GetRaw(), true, canBeCached);
464+
if (canBeCached && entry->Pattern->GetSuitableForCache()) {
465+
cache->EmplacePattern(task.GetProgram().GetRaw(), entry);
466+
} else {
467+
cache->IncNotSuitablePattern();
468+
cache->NotifyPatternMissing(program.GetRaw());
469+
}
470+
} catch (...) {
471+
// TODO: not sure if there may be exceptions in the first place.
472+
cache->NotifyPatternMissing(program.GetRaw());
473+
throw;
474+
}
475+
} else {
476+
entry = future.GetValueSync();
477+
}
478+
#endif
457479
}
458480

459481
if (!entry) {

0 commit comments

Comments
 (0)