@@ -126,6 +126,24 @@ TRuntimeNode WideLastCombiner(TProgramBuilder& pb, TRuntimeNode flow, const TPro
126
126
pb.WideLastCombiner (flow, extractor, init, update, finish);
127
127
}
128
128
129
+ void CheckIfStreamHasExpectedStringValues (const NUdf::TUnboxedValue& streamValue, std::unordered_set<TString>& expected) {
130
+ NUdf::TUnboxedValue item;
131
+ NUdf::EFetchStatus fetchStatus;
132
+ while (!expected.empty ()) {
133
+ fetchStatus = streamValue.Fetch (item);
134
+ UNIT_ASSERT_UNEQUAL (fetchStatus, NUdf::EFetchStatus::Finish);
135
+ if (fetchStatus == NYql::NUdf::EFetchStatus::Yield) continue ;
136
+
137
+ const auto actual = TString (item.AsStringRef ());
138
+
139
+ auto it = expected.find (actual);
140
+ UNIT_ASSERT (it != expected.end ());
141
+ expected.erase (it);
142
+ }
143
+ fetchStatus = streamValue.Fetch (item);
144
+ UNIT_ASSERT_EQUAL (fetchStatus, NUdf::EFetchStatus::Finish);
145
+ }
146
+
129
147
} // unnamed
130
148
131
149
#if !defined(MKQL_RUNTIME_VERSION) || MKQL_RUNTIME_VERSION >= 18u
@@ -1049,7 +1067,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLWideLastCombinerTest) {
1049
1067
1050
1068
const auto list = pb.NewList (tupleType, {data1, data2, data3, data4, data5, data6, data7, data8, data9});
1051
1069
1052
- const auto pgmReturn = pb.Collect (pb.NarrowMap (WideLastCombiner<SPILLING>(pb, pb.ExpandMap (pb.ToFlow (list),
1070
+ const auto pgmReturn = pb.FromFlow (pb.NarrowMap (WideLastCombiner<SPILLING>(pb, pb.ExpandMap (pb.ToFlow (list),
1053
1071
[&](TRuntimeNode item) -> TRuntimeNode::TList { return {pb.Nth (item, 0U ), pb.Nth (item, 1U )}; }),
1054
1072
[&](TRuntimeNode::TList items) -> TRuntimeNode::TList { return {items.front ()}; },
1055
1073
[&](TRuntimeNode::TList keys, TRuntimeNode::TList items) -> TRuntimeNode::TList {
@@ -1076,26 +1094,16 @@ Y_UNIT_TEST_SUITE(TMiniKQLWideLastCombinerTest) {
1076
1094
if (SPILLING) {
1077
1095
graph->GetContext ().SpillerFactory = std::make_shared<TMockSpillerFactory>();
1078
1096
}
1079
- const auto iterator = graph->GetValue ().GetListIterator ();
1080
1097
1098
+ const auto streamVal = graph->GetValue ();
1081
1099
std::unordered_set<TString> expected {
1082
1100
" key one" ,
1083
1101
" very long value 2 / key two" ,
1084
1102
" very long key one" ,
1085
1103
" very long value 8 / very long value 7 / very long value 6"
1086
1104
};
1087
1105
1088
- NUdf::TUnboxedValue item;
1089
- while (!expected.empty ()) {
1090
- UNIT_ASSERT (iterator.Next (item));
1091
- const auto actual = TString (item.AsStringRef ());
1092
-
1093
- auto it = expected.find (actual);
1094
- UNIT_ASSERT (it != expected.end ());
1095
- expected.erase (it);
1096
- }
1097
- UNIT_ASSERT (!iterator.Next (item));
1098
- UNIT_ASSERT (!iterator.Next (item));
1106
+ CheckIfStreamHasExpectedStringValues (streamVal, expected);
1099
1107
}
1100
1108
1101
1109
Y_UNIT_TEST_LLVM_SPILLING (TestLongStringsPasstroughtRefCounting) {
@@ -1140,7 +1148,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLWideLastCombinerTest) {
1140
1148
1141
1149
const auto list = pb.NewList (tupleType, {data1, data2, data3, data4, data5, data6, data7, data8, data9});
1142
1150
1143
- const auto pgmReturn = pb.Collect (pb.NarrowMap (WideLastCombiner<SPILLING>(pb, pb.ExpandMap (pb.ToFlow (list),
1151
+ const auto pgmReturn = pb.FromFlow (pb.NarrowMap (WideLastCombiner<SPILLING>(pb, pb.ExpandMap (pb.ToFlow (list),
1144
1152
[&](TRuntimeNode item) -> TRuntimeNode::TList { return {pb.Nth (item, 0U ), pb.Nth (item, 1U )}; }),
1145
1153
[&](TRuntimeNode::TList items) -> TRuntimeNode::TList { return {items.front ()}; },
1146
1154
[&](TRuntimeNode::TList keys, TRuntimeNode::TList items) -> TRuntimeNode::TList {
@@ -1166,26 +1174,16 @@ Y_UNIT_TEST_SUITE(TMiniKQLWideLastCombinerTest) {
1166
1174
if (SPILLING) {
1167
1175
graph->GetContext ().SpillerFactory = std::make_shared<TMockSpillerFactory>();
1168
1176
}
1169
- const auto iterator = graph->GetValue ().GetListIterator ();
1170
1177
1178
+ const auto streamVal = graph->GetValue ();
1171
1179
std::unordered_set<TString> expected {
1172
1180
" very long value 1 / key one / very long value 1 / key one" ,
1173
1181
" very long value 3 / key two / very long value 2 / key two" ,
1174
1182
" very long value 4 / very long key one / very long value 4 / very long key one" ,
1175
1183
" very long value 9 / very long key two / very long value 5 / very long key two"
1176
1184
};
1177
1185
1178
- NUdf::TUnboxedValue item;
1179
- while (!expected.empty ()) {
1180
- UNIT_ASSERT (iterator.Next (item));
1181
- const auto actual = TString (item.AsStringRef ());
1182
-
1183
- auto it = expected.find (actual);
1184
- UNIT_ASSERT (it != expected.end ());
1185
- expected.erase (it);
1186
- }
1187
- UNIT_ASSERT (!iterator.Next (item));
1188
- UNIT_ASSERT (!iterator.Next (item));
1186
+ CheckIfStreamHasExpectedStringValues (streamVal, expected);
1189
1187
}
1190
1188
1191
1189
Y_UNIT_TEST_LLVM_SPILLING (TestDoNotCalculateUnusedInput) {
@@ -1230,7 +1228,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLWideLastCombinerTest) {
1230
1228
1231
1229
const auto landmine = pb.NewDataLiteral <NUdf::EDataSlot::String>(" ACHTUNG MINEN!" );
1232
1230
1233
- const auto pgmReturn = pb.Collect (pb.NarrowMap (WideLastCombiner<SPILLING>(pb, pb.ExpandMap (pb.ToFlow (list),
1231
+ const auto pgmReturn = pb.FromFlow (pb.NarrowMap (WideLastCombiner<SPILLING>(pb, pb.ExpandMap (pb.ToFlow (list),
1234
1232
[&](TRuntimeNode item) -> TRuntimeNode::TList { return {pb.Nth (item, 0U ), pb.Unwrap (pb.Nth (item, 1U ), landmine, __FILE__, __LINE__, 0 ), pb.Nth (item, 2U )}; }),
1235
1233
[&](TRuntimeNode::TList items) -> TRuntimeNode::TList { return {items.front ()}; },
1236
1234
[&](TRuntimeNode::TList keys, TRuntimeNode::TList items) -> TRuntimeNode::TList {
@@ -1257,23 +1255,14 @@ Y_UNIT_TEST_SUITE(TMiniKQLWideLastCombinerTest) {
1257
1255
if (SPILLING) {
1258
1256
graph->GetContext ().SpillerFactory = std::make_shared<TMockSpillerFactory>();
1259
1257
}
1258
+
1259
+ const auto streamVal = graph->GetValue ();
1260
1260
std::unordered_set<TString> expected {
1261
1261
" key one / value 2 / value 1 / value 5 / value 4" ,
1262
1262
" key two / value 4 / value 3 / value 3 / value 2"
1263
1263
};
1264
1264
1265
- const auto iterator = graph->GetValue ().GetListIterator ();
1266
- NUdf::TUnboxedValue item;
1267
- while (!expected.empty ()) {
1268
- UNIT_ASSERT (iterator.Next (item));
1269
- const auto actual = TString (item.AsStringRef ());
1270
-
1271
- auto it = expected.find (actual);
1272
- UNIT_ASSERT (it != expected.end ());
1273
- expected.erase (it);
1274
- }
1275
- UNIT_ASSERT (!iterator.Next (item));
1276
- UNIT_ASSERT (!iterator.Next (item));
1265
+ CheckIfStreamHasExpectedStringValues (streamVal, expected);
1277
1266
}
1278
1267
1279
1268
Y_UNIT_TEST_LLVM_SPILLING (TestDoNotCalculateUnusedOutput) {
@@ -1315,7 +1304,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLWideLastCombinerTest) {
1315
1304
1316
1305
const auto landmine = pb.NewDataLiteral <NUdf::EDataSlot::String>(" ACHTUNG MINEN!" );
1317
1306
1318
- const auto pgmReturn = pb.Collect (pb.NarrowMap (WideLastCombiner<SPILLING>(pb, pb.ExpandMap (pb.ToFlow (list),
1307
+ const auto pgmReturn = pb.FromFlow (pb.NarrowMap (WideLastCombiner<SPILLING>(pb, pb.ExpandMap (pb.ToFlow (list),
1319
1308
[&](TRuntimeNode item) -> TRuntimeNode::TList { return {pb.Nth (item, 0U ), pb.Nth (item, 1U ), pb.Nth (item, 2U )}; }),
1320
1309
[&](TRuntimeNode::TList items) -> TRuntimeNode::TList { return {items.front ()}; },
1321
1310
[&](TRuntimeNode::TList, TRuntimeNode::TList items) -> TRuntimeNode::TList {
@@ -1334,23 +1323,14 @@ Y_UNIT_TEST_SUITE(TMiniKQLWideLastCombinerTest) {
1334
1323
if (SPILLING) {
1335
1324
graph->GetContext ().SpillerFactory = std::make_shared<TMockSpillerFactory>();
1336
1325
}
1326
+
1327
+ const auto streamVal = graph->GetValue ();
1337
1328
std::unordered_set<TString> expected {
1338
1329
" key one: value 1, value 4, value 5, value 1, value 2" ,
1339
1330
" key two: value 2, value 3, value 3, value 4"
1340
1331
};
1341
1332
1342
- const auto iterator = graph->GetValue ().GetListIterator ();
1343
- NUdf::TUnboxedValue item;
1344
- while (!expected.empty ()) {
1345
- UNIT_ASSERT (iterator.Next (item));
1346
- const auto actual = TString (item.AsStringRef ());
1347
-
1348
- auto it = expected.find (actual);
1349
- UNIT_ASSERT (it != expected.end ());
1350
- expected.erase (it);
1351
- }
1352
- UNIT_ASSERT (!iterator.Next (item));
1353
- UNIT_ASSERT (!iterator.Next (item));
1333
+ CheckIfStreamHasExpectedStringValues (streamVal, expected);
1354
1334
}
1355
1335
1356
1336
Y_UNIT_TEST_LLVM_SPILLING (TestThinAllLambdas) {
@@ -1366,7 +1346,7 @@ Y_UNIT_TEST_SUITE(TMiniKQLWideLastCombinerTest) {
1366
1346
1367
1347
const auto list = pb.NewList (tupleType, {data, data, data, data});
1368
1348
1369
- const auto pgmReturn = pb.Collect (pb.NarrowMap (WideLastCombiner<SPILLING>(pb, pb.ExpandMap (pb.ToFlow (list),
1349
+ const auto pgmReturn = pb.FromFlow (pb.NarrowMap (WideLastCombiner<SPILLING>(pb, pb.ExpandMap (pb.ToFlow (list),
1370
1350
[](TRuntimeNode) -> TRuntimeNode::TList { return {}; }),
1371
1351
[](TRuntimeNode::TList items) { return items; },
1372
1352
[](TRuntimeNode::TList, TRuntimeNode::TList items) { return items; },
@@ -1376,10 +1356,10 @@ Y_UNIT_TEST_SUITE(TMiniKQLWideLastCombinerTest) {
1376
1356
));
1377
1357
1378
1358
const auto graph = setup.BuildGraph (pgmReturn);
1379
- const auto iterator = graph->GetValue (). GetListIterator ();
1359
+ const auto streamVal = graph->GetValue ();
1380
1360
NUdf::TUnboxedValue item;
1381
- UNIT_ASSERT (!iterator. Next (item) );
1382
- UNIT_ASSERT (!iterator. Next (item) );
1361
+ const auto fetchStatus = streamVal. Fetch (item);
1362
+ UNIT_ASSERT_EQUAL (fetchStatus, NUdf::EFetchStatus::Finish );
1383
1363
}
1384
1364
}
1385
1365
0 commit comments