Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make RANGE deterministic by default #4589

Merged
merged 2 commits into from
May 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions ydb/library/yql/providers/yt/gateway/native/yql_yt_native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1755,7 +1755,6 @@ class TYtNativeGateway : public IYtGateway {
auto pos = execCtx->Options_.Pos();
try {
auto entry = execCtx->GetOrCreateEntry();
auto deterministicMode = execCtx->Session_->DeterministicMode_;

TString prefix = execCtx->Options_.Prefix();
TString suffix = execCtx->Options_.Suffix();
Expand All @@ -1764,7 +1763,7 @@ class TYtNativeGateway : public IYtGateway {
with_lock(entry->Lock_) {
if (auto p = entry->RangeCache.FindPtr(cacheKey)) {
YQL_CLOG(INFO, ProviderYt) << "Found range in cache for key ('" << prefix << "','" << suffix << "',<filter with size " << filterLambda.Size() << ">) - number of items " << p->size();
return MakeFuture(MakeTableRangeResult(*p, deterministicMode));
return MakeFuture(MakeTableRangeResult(*p));
}
}

Expand Down Expand Up @@ -1889,7 +1888,7 @@ class TYtNativeGateway : public IYtGateway {

auto logCtx = execCtx->LogCtx_;
return ExecCalc(filterLambda, extraUsage, tmpTablePath, execCtx, entry, TNodeResultFactory())
.Apply([logCtx, prefix, suffix, entry, deterministicMode, pos, errors = std::move(errors), cacheKey = std::move(cacheKey)](const TFuture<NYT::TNode>& f) mutable {
.Apply([logCtx, prefix, suffix, entry, pos, errors = std::move(errors), cacheKey = std::move(cacheKey)](const TFuture<NYT::TNode>& f) mutable {
YQL_LOG_CTX_ROOT_SESSION_SCOPE(logCtx);
std::vector<TString> names;
try {
Expand All @@ -1902,20 +1901,20 @@ class TYtNativeGateway : public IYtGateway {
}
names.push_back(n.AsList().at(0).AsString());
}
return MakeTableRangeResult(std::move(names), std::move(cacheKey), prefix, suffix, entry, deterministicMode);
return MakeTableRangeResult(std::move(names), std::move(cacheKey), prefix, suffix, entry);
} catch (...) {
return ResultFromCurrentException<TTableRangeResult>(pos);
}
});
}
return MakeFuture(MakeTableRangeResult(std::move(names), std::move(cacheKey), prefix, suffix, entry, deterministicMode));
return MakeFuture(MakeTableRangeResult(std::move(names), std::move(cacheKey), prefix, suffix, entry));

} catch (...) {
return MakeFuture(ResultFromCurrentException<TTableRangeResult>(pos));
}
}

static TTableRangeResult MakeTableRangeResult(const std::vector<NYT::TRichYPath>& paths, bool deterministicMode) {
static TTableRangeResult MakeTableRangeResult(const std::vector<NYT::TRichYPath>& paths) {
TTableRangeResult rangeRes;
rangeRes.SetSuccess();

Expand All @@ -1928,14 +1927,14 @@ class TYtNativeGateway : public IYtGateway {
canonPath.Ranges = normalizedPath.GetRanges();
rangeRes.Tables.push_back(std::move(canonPath));
}
if (deterministicMode) {
SortBy(rangeRes.Tables, [] (const TCanonizedPath& path) { return path.Path; });
}

SortBy(rangeRes.Tables, [] (const TCanonizedPath& path) { return path.Path; });

return rangeRes;
}

static TTableRangeResult MakeTableRangeResult(std::vector<TString>&& names, std::tuple<TString, TString, TString>&& cacheKey,
TString prefix, TString suffix, const TTransactionCache::TEntry::TPtr& entry, bool deterministicMode)
TString prefix, TString suffix, const TTransactionCache::TEntry::TPtr& entry)
{
TTableRangeResult rangeRes;
rangeRes.SetSuccess();
Expand Down Expand Up @@ -1995,9 +1994,8 @@ class TYtNativeGateway : public IYtGateway {
entry->RangeCache.emplace(std::move(cacheKey), std::move(cached));
}

if (deterministicMode) {
SortBy(rangeRes.Tables, [] (const TCanonizedPath& path) { return path.Path; });
}
SortBy(rangeRes.Tables, [] (const TCanonizedPath& path) { return path.Path; });

return rangeRes;
}

Expand Down
Loading