diff options
author | zverevgeny <zverevgeny@ydb.tech> | 2023-09-25 12:03:17 +0300 |
---|---|---|
committer | zverevgeny <zverevgeny@ydb.tech> | 2023-09-25 12:25:55 +0300 |
commit | c4ace894bce24a13cfb3bebdd3f0046f1000671b (patch) | |
tree | 819f1658dc6c34e5a95780996fbbfd8ec90f57f1 | |
parent | ef92969347d888d1f2bf46a4a9328822447e5225 (diff) | |
download | ydb-c4ace894bce24a13cfb3bebdd3f0046f1000671b.tar.gz |
YQL-16443 remove dupes
6 files changed, 57 insertions, 173 deletions
diff --git a/ydb/library/yql/minikql/comp_nodes/ut/mkql_block_skiptake_ut.cpp b/ydb/library/yql/minikql/comp_nodes/ut/mkql_block_skiptake_ut.cpp index 830ee7152a..166118522a 100644 --- a/ydb/library/yql/minikql/comp_nodes/ut/mkql_block_skiptake_ut.cpp +++ b/ydb/library/yql/minikql/comp_nodes/ut/mkql_block_skiptake_ut.cpp @@ -61,56 +61,17 @@ IComputationNode* WrapTestBlockFlow(TCallable& callable, const TComputationNodeF return new TTestBlockFlowWrapper(ctx.Mutables, 5, 2); } -TIntrusivePtr<IRandomProvider> CreateRandomProvider() { - return CreateDeterministicRandomProvider(1); -} - -TIntrusivePtr<ITimeProvider> CreateTimeProvider() { - return CreateDeterministicTimeProvider(10000000); -} - -TComputationNodeFactory GetTestFactory() { +TComputationNodeFactory GetNodeFactory() { return [](TCallable& callable, const TComputationNodeFactoryContext& ctx) -> IComputationNode* { if (callable.GetType()->GetName() == "TestBlockFlow") { return WrapTestBlockFlow(callable, ctx); } return GetBuiltinFactory()(callable, ctx); }; -} - -struct TSetup_ { - TSetup_() - : Alloc(__LOCATION__) - { - FunctionRegistry = CreateFunctionRegistry(CreateBuiltinRegistry()); - RandomProvider = CreateRandomProvider(); - TimeProvider = CreateTimeProvider(); - Env.Reset(new TTypeEnvironment(Alloc)); - PgmBuilder.Reset(new TProgramBuilder(*Env, *FunctionRegistry)); - } - - TAutoPtr<IComputationGraph> BuildGraph(TRuntimeNode pgm, EGraphPerProcess graphPerProcess = EGraphPerProcess::Multi, const std::vector<TNode*>& entryPoints = std::vector<TNode*>()) { - Explorer.Walk(pgm.GetNode(), *Env); - TComputationPatternOpts opts(Alloc.Ref(), *Env, GetTestFactory(), FunctionRegistry.Get(), - NUdf::EValidateMode::None, NUdf::EValidatePolicy::Exception, "OFF", graphPerProcess); - Pattern = MakeComputationPattern(Explorer, pgm, entryPoints, opts); - return Pattern->Clone(opts.ToComputationOptions(*RandomProvider, *TimeProvider)); - } - - TIntrusivePtr<IFunctionRegistry> FunctionRegistry; - TIntrusivePtr<IRandomProvider> RandomProvider; - TIntrusivePtr<ITimeProvider> TimeProvider; - - TScopedAlloc Alloc; - THolder<TTypeEnvironment> Env; - THolder<TProgramBuilder> PgmBuilder; - - TExploringNodeVisitor Explorer; - IComputationPattern::TPtr Pattern; -}; +} //namespace -TRuntimeNode MakeFlow(TSetup_& setup) { +TRuntimeNode MakeFlow(TSetup<false>& setup) { TProgramBuilder& pb = *setup.PgmBuilder; TCallableBuilder callableBuilder(*setup.Env, "TestBlockFlow", pb.NewFlowType( @@ -127,7 +88,7 @@ TRuntimeNode MakeFlow(TSetup_& setup) { Y_UNIT_TEST_SUITE(TMiniKQLWideTakeSkipBlocks) { Y_UNIT_TEST(TestWideTakeSkipBlocks) { - TSetup_ setup; + TSetup<false> setup(GetNodeFactory()); TProgramBuilder& pb = *setup.PgmBuilder; const auto flow = MakeFlow(setup); diff --git a/ydb/library/yql/minikql/comp_nodes/ut/mkql_blocks_ut.cpp b/ydb/library/yql/minikql/comp_nodes/ut/mkql_blocks_ut.cpp index 04d126bf81..542031997e 100644 --- a/ydb/library/yql/minikql/comp_nodes/ut/mkql_blocks_ut.cpp +++ b/ydb/library/yql/minikql/comp_nodes/ut/mkql_blocks_ut.cpp @@ -721,7 +721,7 @@ Y_UNIT_TEST(WithScalars) { Y_UNIT_TEST(Udf) { TVector<TUdfModuleInfo> modules; modules.emplace_back(TUdfModuleInfo{"", "BlockUT", new TBlockUTModule()}); - TSetup<false> setup({}, std::move(modules)); + TSetup<false> setup(GetTestFactory(), std::move(modules)); auto& pb = *setup.PgmBuilder; diff --git a/ydb/library/yql/minikql/comp_nodes/ut/mkql_combine_ut.cpp b/ydb/library/yql/minikql/comp_nodes/ut/mkql_combine_ut.cpp index 72fe11dc40..3a99392241 100644 --- a/ydb/library/yql/minikql/comp_nodes/ut/mkql_combine_ut.cpp +++ b/ydb/library/yql/minikql/comp_nodes/ut/mkql_combine_ut.cpp @@ -94,15 +94,7 @@ IComputationNode* WrapTestStream(TCallable& callable, const TComputationNodeFact return new TTestStreamWrapper<WithYields>(ctx.Mutables, peakStep); } -TIntrusivePtr<IRandomProvider> CreateRandomProvider() { - return CreateDeterministicRandomProvider(1); -} - -TIntrusivePtr<ITimeProvider> CreateTimeProvider() { - return CreateDeterministicTimeProvider(10000000); -} - -TComputationNodeFactory GetTestFactory() { +TComputationNodeFactory GetNodeFactory() { return [](TCallable& callable, const TComputationNodeFactoryContext& ctx) -> IComputationNode* { if (callable.GetType()->GetName() == "TestList") { return new TExternalComputationNode(ctx.Mutables); @@ -117,41 +109,8 @@ TComputationNodeFactory GetTestFactory() { }; } -template<bool UseLLVM> -struct TSetup_ { - TSetup_() - : Alloc(__LOCATION__) - { - FunctionRegistry = CreateFunctionRegistry(CreateBuiltinRegistry()); - RandomProvider = CreateRandomProvider(); - TimeProvider = CreateTimeProvider(); - - Env.Reset(new TTypeEnvironment(Alloc)); - PgmBuilder.Reset(new TProgramBuilder(*Env, *FunctionRegistry)); - } - - TAutoPtr<IComputationGraph> BuildGraph(TRuntimeNode pgm, EGraphPerProcess graphPerProcess = EGraphPerProcess::Multi, const std::vector<TNode*>& entryPoints = std::vector<TNode*>()) { - Explorer.Walk(pgm.GetNode(), *Env); - TComputationPatternOpts opts(Alloc.Ref(), *Env, GetTestFactory(), FunctionRegistry.Get(), - NUdf::EValidateMode::None, NUdf::EValidatePolicy::Exception, UseLLVM ? "" : "OFF", graphPerProcess); - Pattern = MakeComputationPattern(Explorer, pgm, entryPoints, opts); - return Pattern->Clone(opts.ToComputationOptions(*RandomProvider, *TimeProvider)); - } - - TIntrusivePtr<IFunctionRegistry> FunctionRegistry; - TIntrusivePtr<IRandomProvider> RandomProvider; - TIntrusivePtr<ITimeProvider> TimeProvider; - - TScopedAlloc Alloc; - THolder<TTypeEnvironment> Env; - THolder<TProgramBuilder> PgmBuilder; - - TExploringNodeVisitor Explorer; - IComputationPattern::TPtr Pattern; -}; - template <bool LLVM, bool WithYields = false> -TRuntimeNode MakeStream(TSetup_<LLVM>& setup, ui64 peakStep) { +TRuntimeNode MakeStream(TSetup<LLVM>& setup, ui64 peakStep) { TProgramBuilder& pb = *setup.PgmBuilder; TCallableBuilder callableBuilder(*setup.Env, WithYields ? "TestYieldStream" : "TestStream", @@ -214,7 +173,7 @@ TRuntimeNode StreamToString(TProgramBuilder& pb, TRuntimeNode stream) { Y_UNIT_TEST_SUITE(TMiniKQLCombineStreamTest) { Y_UNIT_TEST_LLVM(TestFullCombineWithOptOut) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); TProgramBuilder& pb = *setup.PgmBuilder; const auto finish = [&](TRuntimeNode /*key*/, TRuntimeNode state) { return pb.NewOptional(pb.Member(state, "a")); @@ -231,7 +190,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineStreamTest) { } Y_UNIT_TEST_LLVM(TestFullCombineWithListOut) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); TProgramBuilder& pb = *setup.PgmBuilder; const auto finish = [&](TRuntimeNode /*key*/, TRuntimeNode state) { const auto item = pb.Member(state, "a"); @@ -253,7 +212,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineStreamTest) { } Y_UNIT_TEST_LLVM(TestFullCombineWithStreamOut) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); TProgramBuilder& pb = *setup.PgmBuilder; const auto finish = [&](TRuntimeNode /*key*/, TRuntimeNode state) { const auto item = pb.Member(state, "a"); @@ -275,7 +234,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineStreamTest) { } Y_UNIT_TEST_LLVM(TestFullCombineWithOptOutAndYields) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); TProgramBuilder& pb = *setup.PgmBuilder; const auto finish = [&](TRuntimeNode /*key*/, TRuntimeNode state) { return pb.NewOptional(pb.Member(state, "a")); @@ -295,7 +254,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineStreamTest) { } Y_UNIT_TEST_LLVM(TestFullCombineWithListAndYields) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); TProgramBuilder& pb = *setup.PgmBuilder; const auto finish = [&](TRuntimeNode /*key*/, TRuntimeNode state) { const auto item = pb.Member(state, "a"); @@ -320,7 +279,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineStreamTest) { } Y_UNIT_TEST_LLVM(TestFullCombineWithStreamAndYields) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); TProgramBuilder& pb = *setup.PgmBuilder; const auto finish = [&](TRuntimeNode /*key*/, TRuntimeNode state) { const auto item = pb.Member(state, "a"); @@ -345,7 +304,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineStreamTest) { } Y_UNIT_TEST_LLVM(TestPartialFlush) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); TProgramBuilder& pb = *setup.PgmBuilder; const auto finish = [&](TRuntimeNode /*key*/, TRuntimeNode state) { return pb.NewOptional(pb.Member(state, "a")); @@ -374,7 +333,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineStreamTest) { } Y_UNIT_TEST_LLVM(TestCombineInSingleProc) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); TProgramBuilder& pb = *setup.PgmBuilder; const auto finish = [&](TRuntimeNode /*key*/, TRuntimeNode state) { return pb.NewOptional(pb.Member(state, "a")); @@ -391,7 +350,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineStreamTest) { } Y_UNIT_TEST_LLVM(TestCombineSwithYield) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); TProgramBuilder& pb = *setup.PgmBuilder; const auto finish = [&](TRuntimeNode /*key*/, TRuntimeNode state) { return pb.NewOptional(pb.Member(state, "a")); @@ -421,7 +380,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineStreamTest) { Y_UNIT_TEST_SUITE(TMiniKQLCombineStreamPerfTest) { Y_UNIT_TEST_LLVM(TestSumDoubleBooleanKeys) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); double positive = 0.0, negative = 0.0; const auto t = TInstant::Now(); @@ -467,7 +426,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineStreamPerfTest) { } Y_UNIT_TEST_LLVM(TestMinMaxSumDoubleBooleanKeys) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); double pSum = 0.0, nSum = 0.0, pMax = 0.0, nMax = -1000.0, pMin = 1000.0, nMin = 0.0; const auto t = TInstant::Now(); @@ -532,7 +491,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineStreamPerfTest) { } Y_UNIT_TEST_LLVM(TestSumDoubleSmallKey) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); std::unordered_map<i8, double> expects(201); const auto t = TInstant::Now(); @@ -589,7 +548,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineStreamPerfTest) { } Y_UNIT_TEST_LLVM(TestMinMaxSumDoubleSmallKey) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); std::unordered_map<i8, std::array<double, 3U>> expects(201); const auto t = TInstant::Now(); @@ -649,7 +608,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineStreamPerfTest) { } Y_UNIT_TEST_LLVM(TestSumDoubleStringKey) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); std::vector<std::pair<std::string, double>> stringI8Samples(I8Samples.size()); std::transform(I8Samples.cbegin(), I8Samples.cend(), stringI8Samples.begin(), [](std::pair<i8, double> src){ return std::make_pair(ToString(src.first), src.second); }); @@ -709,7 +668,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineStreamPerfTest) { } Y_UNIT_TEST_LLVM(TestMinMaxSumDoubleStringKey) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); std::vector<std::pair<std::string, double>> stringI8Samples(I8Samples.size()); std::transform(I8Samples.cbegin(), I8Samples.cend(), stringI8Samples.begin(), [](std::pair<i8, double> src){ return std::make_pair(ToString(src.first), src.second); }); @@ -772,7 +731,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineStreamPerfTest) { } Y_UNIT_TEST_LLVM(TestMinMaxSumTupleKey) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); std::vector<std::pair<std::pair<ui32, std::string>, double>> pairI8Samples(Ui16Samples.size()); std::transform(Ui16Samples.cbegin(), Ui16Samples.cend(), pairI8Samples.begin(), [](std::pair<ui32, double> src){ return std::make_pair(std::make_pair(ui32(src.first / 10U % 100U), ToString(src.first % 10U)), src.second); }); @@ -843,7 +802,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineStreamPerfTest) { #if !defined(MKQL_RUNTIME_VERSION) || MKQL_RUNTIME_VERSION >= 3u Y_UNIT_TEST_SUITE(TMiniKQLCombineFlowTest) { Y_UNIT_TEST_LLVM(TestFullCombineWithOptOut) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); TProgramBuilder& pb = *setup.PgmBuilder; const auto finish = [&](TRuntimeNode /*key*/, TRuntimeNode state) { return pb.NewOptional(pb.Member(state, "a")); @@ -860,7 +819,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineFlowTest) { } Y_UNIT_TEST_LLVM(TestFullCombineWithListOut) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); TProgramBuilder& pb = *setup.PgmBuilder; const auto finish = [&](TRuntimeNode /*key*/, TRuntimeNode state) { const auto item = pb.Member(state, "a"); @@ -882,7 +841,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineFlowTest) { } Y_UNIT_TEST_LLVM(TestFullCombineWithStreamOut) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); TProgramBuilder& pb = *setup.PgmBuilder; const auto finish = [&](TRuntimeNode /*key*/, TRuntimeNode state) { const auto item = pb.Member(state, "a"); @@ -904,7 +863,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineFlowTest) { } Y_UNIT_TEST_LLVM(TestFullCombineWithOptOutAndYields) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); TProgramBuilder& pb = *setup.PgmBuilder; const auto finish = [&](TRuntimeNode /*key*/, TRuntimeNode state) { return pb.NewOptional(pb.Member(state, "a")); @@ -924,7 +883,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineFlowTest) { } Y_UNIT_TEST_LLVM(TestFullCombineWithListAndYields) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); TProgramBuilder& pb = *setup.PgmBuilder; const auto finish = [&](TRuntimeNode /*key*/, TRuntimeNode state) { const auto item = pb.Member(state, "a"); @@ -949,7 +908,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineFlowTest) { } Y_UNIT_TEST_LLVM(TestFullCombineWithStreamAndYields) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); TProgramBuilder& pb = *setup.PgmBuilder; const auto finish = [&](TRuntimeNode /*key*/, TRuntimeNode state) { const auto item = pb.Member(state, "a"); @@ -974,7 +933,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineFlowTest) { } Y_UNIT_TEST_LLVM(TestPartialFlush) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); TProgramBuilder& pb = *setup.PgmBuilder; const auto finish = [&](TRuntimeNode /*key*/, TRuntimeNode state) { return pb.NewOptional(pb.Member(state, "a")); @@ -1003,7 +962,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineFlowTest) { } Y_UNIT_TEST_LLVM(TestCombineInSingleProc) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); TProgramBuilder& pb = *setup.PgmBuilder; const auto finish = [&](TRuntimeNode /*key*/, TRuntimeNode state) { return pb.NewOptional(pb.Member(state, "a")); @@ -1020,7 +979,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineFlowTest) { } Y_UNIT_TEST_LLVM(TestCombineSwithYield) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); TProgramBuilder& pb = *setup.PgmBuilder; const auto finish = [&](TRuntimeNode /*key*/, TRuntimeNode state) { return pb.NewOptional(pb.Member(state, "a")); @@ -1050,7 +1009,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineFlowTest) { Y_UNIT_TEST_SUITE(TMiniKQLCombineFlowPerfTest) { Y_UNIT_TEST_LLVM(TestSumDoubleBooleanKeys) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); double positive = 0.0, negative = 0.0; const auto t = TInstant::Now(); @@ -1096,7 +1055,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineFlowPerfTest) { } Y_UNIT_TEST_LLVM(TestMinMaxSumDoubleBooleanKeys) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); double pSum = 0.0, nSum = 0.0, pMax = 0.0, nMax = -1000.0, pMin = 1000.0, nMin = 0.0; const auto t = TInstant::Now(); @@ -1161,7 +1120,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineFlowPerfTest) { } Y_UNIT_TEST_LLVM(TestSumDoubleSmallKey) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); std::unordered_map<i8, double> expects(201); const auto t = TInstant::Now(); @@ -1218,7 +1177,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineFlowPerfTest) { } Y_UNIT_TEST_LLVM(TestMinMaxSumDoubleSmallKey) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); std::unordered_map<i8, std::array<double, 3U>> expects(201); const auto t = TInstant::Now(); @@ -1278,7 +1237,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineFlowPerfTest) { } Y_UNIT_TEST_LLVM(TestSumDoubleStringKey) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); std::vector<std::pair<std::string, double>> stringI8Samples(I8Samples.size()); std::transform(I8Samples.cbegin(), I8Samples.cend(), stringI8Samples.begin(), [](std::pair<i8, double> src){ return std::make_pair(ToString(src.first), src.second); }); @@ -1338,7 +1297,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineFlowPerfTest) { } Y_UNIT_TEST_LLVM(TestMinMaxSumDoubleStringKey) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); std::vector<std::pair<std::string, double>> stringI8Samples(I8Samples.size()); std::transform(I8Samples.cbegin(), I8Samples.cend(), stringI8Samples.begin(), [](std::pair<i8, double> src){ return std::make_pair(ToString(src.first), src.second); }); @@ -1401,7 +1360,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineFlowPerfTest) { } Y_UNIT_TEST_LLVM(TestMinMaxSumTupleKey) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); std::vector<std::pair<std::pair<ui32, std::string>, double>> pairI8Samples(Ui16Samples.size()); std::transform(Ui16Samples.cbegin(), Ui16Samples.cend(), pairI8Samples.begin(), [](std::pair<ui16, double> src){ return std::make_pair(std::make_pair(ui32(src.first / 10U % 100U), ToString(src.first % 10U)), src.second); }); @@ -1472,7 +1431,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLCombineFlowPerfTest) { const auto border = 9124596000000000ULL; Y_UNIT_TEST_LLVM(TestTpch) { - TSetup_<LLVM> setup; + TSetup<LLVM> setup(GetNodeFactory()); struct TPairHash { size_t operator()(const std::pair<std::string_view, std::string_view>& p) const { return CombineHashes(std::hash<std::string_view>()(p.first), std::hash<std::string_view>()(p.second)); } }; diff --git a/ydb/library/yql/minikql/comp_nodes/ut/mkql_computation_node_ut.h b/ydb/library/yql/minikql/comp_nodes/ut/mkql_computation_node_ut.h index 9b5ebdad7c..7fa1164bbb 100644 --- a/ydb/library/yql/minikql/comp_nodes/ut/mkql_computation_node_ut.h +++ b/ydb/library/yql/minikql/comp_nodes/ut/mkql_computation_node_ut.h @@ -81,7 +81,7 @@ struct TUdfModuleInfo { template<bool UseLLVM> struct TSetup { - TSetup(TComputationNodeFactory nodeFactory = {}, TVector<TUdfModuleInfo>&& modules = {}) + explicit TSetup(TComputationNodeFactory nodeFactory = GetTestFactory(), TVector<TUdfModuleInfo>&& modules = {}) : Alloc(__LOCATION__) , StatsRegistry(CreateDefaultStatsRegistry()) { @@ -104,11 +104,19 @@ struct TSetup { } THolder<IComputationGraph> BuildGraph(TRuntimeNode pgm, const std::vector<TNode*>& entryPoints = std::vector<TNode*>()) { + return BuildGraph(pgm, EGraphPerProcess::Multi, entryPoints); + } + + THolder<IComputationGraph> BuildGraph(TRuntimeNode pgm, EGraphPerProcess graphPerProcess) { + return BuildGraph(pgm, graphPerProcess, {}); + } + + TAutoPtr<IComputationGraph> BuildGraph(TRuntimeNode pgm, EGraphPerProcess graphPerProcess, const std::vector<TNode*>& entryPoints) { Reset(); Explorer.Walk(pgm.GetNode(), *Env); - TComputationPatternOpts opts(Alloc.Ref(), *Env, GetTestFactory(NodeFactory), + TComputationPatternOpts opts(Alloc.Ref(), *Env, NodeFactory, FunctionRegistry.Get(), NUdf::EValidateMode::None, NUdf::EValidatePolicy::Exception, - UseLLVM ? "" : "OFF", EGraphPerProcess::Multi, StatsRegistry.Get(), nullptr, nullptr); + UseLLVM ? "" : "OFF", graphPerProcess, StatsRegistry.Get(), nullptr, nullptr); Pattern = MakeComputationPattern(Explorer, pgm, entryPoints, opts); auto graph = Pattern->Clone(opts.ToComputationOptions(*RandomProvider, *TimeProvider)); Terminator.Reset(new TBindTerminator(graph->GetTerminator())); diff --git a/ydb/library/yql/minikql/comp_nodes/ut/mkql_multihopping_saveload_ut.cpp b/ydb/library/yql/minikql/comp_nodes/ut/mkql_multihopping_saveload_ut.cpp index d7c4e8517b..9100c5d590 100644 --- a/ydb/library/yql/minikql/comp_nodes/ut/mkql_multihopping_saveload_ut.cpp +++ b/ydb/library/yql/minikql/comp_nodes/ut/mkql_multihopping_saveload_ut.cpp @@ -1,4 +1,5 @@ #include "../mkql_multihopping.h" +#include "mkql_computation_node_ut.h" #include <ydb/library/yql/minikql/mkql_node.h> #include <ydb/library/yql/minikql/mkql_node_cast.h> #include <ydb/library/yql/minikql/mkql_program_builder.h> @@ -15,14 +16,6 @@ namespace NKikimr { namespace NMiniKQL { namespace { - TIntrusivePtr<IRandomProvider> CreateRandomProvider() { - return CreateDeterministicRandomProvider(1); - } - - TIntrusivePtr<ITimeProvider> CreateTimeProvider() { - return CreateDeterministicTimeProvider(10000000); - } - TComputationNodeFactory GetAuxCallableFactory(TWatermark& watermark) { return [&watermark](TCallable& callable, const TComputationNodeFactoryContext& ctx) -> IComputationNode* { if (callable.GetType()->GetName() == "OneYieldStream") { @@ -34,42 +27,6 @@ namespace { return GetBuiltinFactory()(callable, ctx); }; } - - struct TSetup { - TSetup(TScopedAlloc& alloc) - : Alloc(alloc) - { - FunctionRegistry = CreateFunctionRegistry(CreateBuiltinRegistry()); - RandomProvider = CreateRandomProvider(); - TimeProvider = CreateTimeProvider(); - - Env.Reset(new TTypeEnvironment(Alloc)); - PgmBuilder.Reset(new TProgramBuilder(*Env, *FunctionRegistry)); - } - - THolder<IComputationGraph> BuildGraph(TRuntimeNode pgm, const std::vector<TNode*>& entryPoints = std::vector<TNode*>()) { - Explorer.Walk(pgm.GetNode(), *Env); - TComputationPatternOpts opts(Alloc.Ref(), *Env, GetAuxCallableFactory(Watermark), - FunctionRegistry.Get(), - NUdf::EValidateMode::None, NUdf::EValidatePolicy::Fail, "OFF", EGraphPerProcess::Multi); - Pattern = MakeComputationPattern(Explorer, pgm, entryPoints, opts); - TComputationOptsFull compOpts = opts.ToComputationOptions(*RandomProvider, *TimeProvider); - return Pattern->Clone(compOpts); - } - - TIntrusivePtr<IFunctionRegistry> FunctionRegistry; - TIntrusivePtr<IRandomProvider> RandomProvider; - TIntrusivePtr<ITimeProvider> TimeProvider; - - TScopedAlloc& Alloc; - THolder<TTypeEnvironment> Env; - THolder<TProgramBuilder> PgmBuilder; - - TExploringNodeVisitor Explorer; - IComputationPattern::TPtr Pattern; - TWatermark Watermark; - }; - struct TStreamWithYield : public NUdf::TBoxedValue { TStreamWithYield(const TUnboxedValueVector& items, ui32 yieldPos, ui32 index) : Items(items) @@ -106,7 +63,7 @@ namespace { } }; - THolder<IComputationGraph> BuildGraph(TSetup& setup, const std::vector<std::tuple<ui32, i64, ui32>> items, + THolder<IComputationGraph> BuildGraph(TSetup<false>& setup, const std::vector<std::tuple<ui32, i64, ui32>> items, ui32 yieldPos, ui32 startIndex, bool dataWatermarks) { TProgramBuilder& pgmBuilder = *setup.PgmBuilder; @@ -204,12 +161,11 @@ Y_UNIT_TEST_SUITE(TMiniKQLMultiHoppingSaveLoadTest) { bool withTraverse, bool dataWatermarks) { - TScopedAlloc alloc(__LOCATION__); - + TWatermark watermark; for (ui32 yieldPos = 0; yieldPos < input.size(); ++yieldPos) { std::vector<std::tuple<ui32, ui32>> result; - TSetup setup1(alloc); + TSetup<false> setup1(GetAuxCallableFactory(watermark)); auto graph1 = BuildGraph(setup1, input, yieldPos, 0, dataWatermarks); auto root1 = graph1->GetValue(); @@ -230,7 +186,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLMultiHoppingSaveLoadTest) { graphState = graph1->SaveGraphState(); } - TSetup setup2(alloc); + TSetup<false> setup2(GetAuxCallableFactory(watermark)); auto graph2 = BuildGraph(setup2, input, -1, yieldPos, dataWatermarks); NUdf::TUnboxedValue root2; if (withTraverse) { diff --git a/ydb/library/yql/parser/pg_wrapper/ut/sort_ut.cpp b/ydb/library/yql/parser/pg_wrapper/ut/sort_ut.cpp index 04f812ef16..497cd04f82 100644 --- a/ydb/library/yql/parser/pg_wrapper/ut/sort_ut.cpp +++ b/ydb/library/yql/parser/pg_wrapper/ut/sort_ut.cpp @@ -28,7 +28,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLPGSortTest) { const std::array<TString, 3U> values = {{"2000-01-01","1979-12-12","2010-12-01"}}; const std::array<TString, 3U> sortedValues = {{"1979-12-12","2000-01-01","2010-12-01"} }; - TSetup<LLVM> setup(GetPgFactory()); + TSetup<LLVM> setup(GetTestFactory(GetPgFactory())); TProgramBuilder& pgmBuilder = *setup.PgmBuilder; auto pgDateType = static_cast<TPgType*>(pgmBuilder.NewPgType(NPg::LookupType("date").TypeId)); |