summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Neporada <[email protected]>2024-01-23 07:16:57 +0300
committerGitHub <[email protected]>2024-01-23 07:16:57 +0300
commitfa1ae5e61d1f21983b869b0537de88af29e7f6cc (patch)
treef5ea0b68665ea8ddd96b03efad0c37312986baf9
parentd856b1bf8ed685b9b388a9ed67326d0769dacb1b (diff)
[YQL-17298] Fix data race on ICompare::TPtr (#1213)
-rw-r--r--ydb/library/yql/minikql/comp_nodes/mkql_wide_top_sort.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/ydb/library/yql/minikql/comp_nodes/mkql_wide_top_sort.cpp b/ydb/library/yql/minikql/comp_nodes/mkql_wide_top_sort.cpp
index 7ad66ba832f..0a873284bff 100644
--- a/ydb/library/yql/minikql/comp_nodes/mkql_wide_top_sort.cpp
+++ b/ydb/library/yql/minikql/comp_nodes/mkql_wide_top_sort.cpp
@@ -20,20 +20,31 @@ struct TKeyInfo {
bool IsOptional;
NUdf::ICompare::TPtr Compare;
TType* PresortType = nullptr;
- std::optional<TGenericPresortEncoder> LeftPacker;
- std::optional<TGenericPresortEncoder> RightPacker;
+};
+
+struct TRuntimeKeyInfo {
+ TRuntimeKeyInfo(const TKeyInfo& keyInfo)
+ : Slot(keyInfo.Slot)
+ , IsOptional(keyInfo.IsOptional)
+ , Compare(keyInfo.Compare.Get())
+ {
+ if (keyInfo.PresortType) {
+ LeftPacker = keyInfo.PresortType;
+ RightPacker = keyInfo.PresortType;
+ }
+ }
+
+ const NUdf::EDataSlot Slot;
+ const bool IsOptional;
+ const NUdf::ICompare* const Compare;
+ mutable std::optional<TGenericPresortEncoder> LeftPacker;
+ mutable std::optional<TGenericPresortEncoder> RightPacker;
};
struct TMyValueCompare {
TMyValueCompare(const std::vector<TKeyInfo>& keys)
- : Keys(keys)
+ : Keys(keys.cbegin(), keys.cend())
{
- for (auto& key : Keys) {
- if (key.PresortType) {
- key.LeftPacker.emplace(key.PresortType);
- key.RightPacker.emplace(key.PresortType);
- }
- }
}
int operator()(const bool* directions, const NUdf::TUnboxedValuePod* left, const NUdf::TUnboxedValuePod* right) const {
@@ -64,7 +75,7 @@ struct TMyValueCompare {
return 0;
}
- mutable std::vector<TKeyInfo> Keys;
+ const std::vector<TRuntimeKeyInfo> Keys;
};
using TComparePtr = int(*)(const bool*, const NUdf::TUnboxedValuePod*, const NUdf::TUnboxedValuePod*);