Skip to content

Commit f18e7fd

Browse files
committed
just better
1 parent c7396a0 commit f18e7fd

File tree

1 file changed

+12
-26
lines changed

1 file changed

+12
-26
lines changed

ydb/library/yql/minikql/comp_nodes/ut/mkql_wide_combine_ut.cpp

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ TRuntimeNode Combine(TProgramBuilder& pb, TRuntimeNode stream, std::function<TRu
119119
pb.CombineCore(stream, keyExtractor, init, update, finishLambda, 64ul << 20);
120120
}
121121

122+
template<bool SPILLING>
123+
TRuntimeNode WideLastCombiner(TProgramBuilder& pb, TRuntimeNode flow, const TProgramBuilder::TWideLambda& extractor, const TProgramBuilder::TBinaryWideLambda& init, const TProgramBuilder::TTernaryWideLambda& update, const TProgramBuilder::TBinaryWideLambda& finish) {
124+
return SPILLING ?
125+
pb.WideLastCombinerWithSpilling(flow, extractor, init, update, finish):
126+
pb.WideLastCombiner(flow, extractor, init, update, finish);
127+
}
128+
122129
} // unnamed
123130

124131
#if !defined(MKQL_RUNTIME_VERSION) || MKQL_RUNTIME_VERSION >= 18u
@@ -1042,12 +1049,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLWideLastCombinerTest) {
10421049

10431050
const auto list = pb.NewList(tupleType, {data1, data2, data3, data4, data5, data6, data7, data8, data9});
10441051

1045-
auto wideLastCombinerCollable = &TProgramBuilder::WideLastCombiner;
1046-
if (SPILLING) {
1047-
wideLastCombinerCollable = &TProgramBuilder::WideLastCombinerWithSpilling;
1048-
}
1049-
1050-
const auto pgmReturn = pb.Collect(pb.NarrowMap((pb.*wideLastCombinerCollable)(pb.ExpandMap(pb.ToFlow(list),
1052+
const auto pgmReturn = pb.Collect(pb.NarrowMap(WideLastCombiner<SPILLING>(pb, pb.ExpandMap(pb.ToFlow(list),
10511053
[&](TRuntimeNode item) -> TRuntimeNode::TList { return {pb.Nth(item, 0U), pb.Nth(item, 1U)}; }),
10521054
[&](TRuntimeNode::TList items) -> TRuntimeNode::TList { return {items.front()}; },
10531055
[&](TRuntimeNode::TList keys, TRuntimeNode::TList items) -> TRuntimeNode::TList {
@@ -1138,11 +1140,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLWideLastCombinerTest) {
11381140

11391141
const auto list = pb.NewList(tupleType, {data1, data2, data3, data4, data5, data6, data7, data8, data9});
11401142

1141-
auto wideLastCombinerCollable = &TProgramBuilder::WideLastCombiner;
1142-
if (SPILLING) {
1143-
wideLastCombinerCollable = &TProgramBuilder::WideLastCombinerWithSpilling;
1144-
}
1145-
const auto pgmReturn = pb.Collect(pb.NarrowMap((pb.*wideLastCombinerCollable)(pb.ExpandMap(pb.ToFlow(list),
1143+
const auto pgmReturn = pb.Collect(pb.NarrowMap(WideLastCombiner<SPILLING>(pb, pb.ExpandMap(pb.ToFlow(list),
11461144
[&](TRuntimeNode item) -> TRuntimeNode::TList { return {pb.Nth(item, 0U), pb.Nth(item, 1U)}; }),
11471145
[&](TRuntimeNode::TList items) -> TRuntimeNode::TList { return {items.front()}; },
11481146
[&](TRuntimeNode::TList keys, TRuntimeNode::TList items) -> TRuntimeNode::TList {
@@ -1232,11 +1230,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLWideLastCombinerTest) {
12321230

12331231
const auto landmine = pb.NewDataLiteral<NUdf::EDataSlot::String>("ACHTUNG MINEN!");
12341232

1235-
auto wideLastCombinerCollable = &TProgramBuilder::WideLastCombiner;
1236-
if (SPILLING) {
1237-
wideLastCombinerCollable = &TProgramBuilder::WideLastCombinerWithSpilling;
1238-
}
1239-
const auto pgmReturn = pb.Collect(pb.NarrowMap((pb.*wideLastCombinerCollable)(pb.ExpandMap(pb.ToFlow(list),
1233+
const auto pgmReturn = pb.Collect(pb.NarrowMap(WideLastCombiner<SPILLING>(pb, pb.ExpandMap(pb.ToFlow(list),
12401234
[&](TRuntimeNode item) -> TRuntimeNode::TList { return {pb.Nth(item, 0U), pb.Unwrap(pb.Nth(item, 1U), landmine, __FILE__, __LINE__, 0), pb.Nth(item, 2U)}; }),
12411235
[&](TRuntimeNode::TList items) -> TRuntimeNode::TList { return {items.front()}; },
12421236
[&](TRuntimeNode::TList keys, TRuntimeNode::TList items) -> TRuntimeNode::TList {
@@ -1321,11 +1315,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLWideLastCombinerTest) {
13211315

13221316
const auto landmine = pb.NewDataLiteral<NUdf::EDataSlot::String>("ACHTUNG MINEN!");
13231317

1324-
auto wideLastCombinerCollable = &TProgramBuilder::WideLastCombiner;
1325-
if (SPILLING) {
1326-
wideLastCombinerCollable = &TProgramBuilder::WideLastCombinerWithSpilling;
1327-
}
1328-
const auto pgmReturn = pb.Collect(pb.NarrowMap((pb.*wideLastCombinerCollable)(pb.ExpandMap(pb.ToFlow(list),
1318+
const auto pgmReturn = pb.Collect(pb.NarrowMap(WideLastCombiner<SPILLING>(pb, pb.ExpandMap(pb.ToFlow(list),
13291319
[&](TRuntimeNode item) -> TRuntimeNode::TList { return {pb.Nth(item, 0U), pb.Nth(item, 1U), pb.Nth(item, 2U)}; }),
13301320
[&](TRuntimeNode::TList items) -> TRuntimeNode::TList { return {items.front()}; },
13311321
[&](TRuntimeNode::TList, TRuntimeNode::TList items) -> TRuntimeNode::TList {
@@ -1376,11 +1366,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLWideLastCombinerTest) {
13761366

13771367
const auto list = pb.NewList(tupleType, {data, data, data, data});
13781368

1379-
auto wideLastCombinerCollable = &TProgramBuilder::WideLastCombiner;
1380-
if (SPILLING) {
1381-
wideLastCombinerCollable = &TProgramBuilder::WideLastCombinerWithSpilling;
1382-
}
1383-
const auto pgmReturn = pb.Collect(pb.NarrowMap((pb.*wideLastCombinerCollable)(pb.ExpandMap(pb.ToFlow(list),
1369+
const auto pgmReturn = pb.Collect(pb.NarrowMap(WideLastCombiner<SPILLING>(pb, pb.ExpandMap(pb.ToFlow(list),
13841370
[](TRuntimeNode) -> TRuntimeNode::TList { return {}; }),
13851371
[](TRuntimeNode::TList items) { return items; },
13861372
[](TRuntimeNode::TList, TRuntimeNode::TList items) { return items; },

0 commit comments

Comments
 (0)