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 7ad66ba832fa..0a873284bffe 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 LeftPacker; - std::optional 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 LeftPacker; + mutable std::optional RightPacker; }; struct TMyValueCompare { TMyValueCompare(const std::vector& 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 Keys; + const std::vector Keys; }; using TComparePtr = int(*)(const bool*, const NUdf::TUnboxedValuePod*, const NUdf::TUnboxedValuePod*);