|
69 | 69 | import static org.apache.iotdb.db.queryengine.execution.fragment.FragmentInstanceContext.createFragmentInstanceContext; |
70 | 70 | import static org.apache.iotdb.db.queryengine.execution.operator.AggregationOperatorTest.TEST_TIME_SLICE; |
71 | 71 | import static org.apache.iotdb.db.queryengine.execution.operator.AggregationUtil.initTimeRangeIterator; |
| 72 | +import static org.apache.iotdb.db.queryengine.execution.operator.OperatorTestUtils.nextNonNullOrEmpty; |
72 | 73 | import static org.junit.Assert.assertEquals; |
73 | 74 | import static org.junit.Assert.assertTrue; |
74 | 75 |
|
@@ -122,7 +123,7 @@ public void testAggregationWithoutTimeFilter() throws Exception { |
122 | 123 | initAlignedSeriesAggregationScanOperator(aggregators, null, true, null); |
123 | 124 | int count = 0; |
124 | 125 | while (seriesAggregationScanOperator.hasNext()) { |
125 | | - TsBlock resultTsBlock = seriesAggregationScanOperator.next(); |
| 126 | + TsBlock resultTsBlock = nextNonNullOrEmpty(seriesAggregationScanOperator); |
126 | 127 | for (int i = 0; i < measurementSchemas.size(); i++) { |
127 | 128 | assertEquals(500, resultTsBlock.getColumn(i).getLong(0)); |
128 | 129 | } |
@@ -153,7 +154,7 @@ public void testAggregationWithoutTimeFilterOrderByTimeDesc() throws Exception { |
153 | 154 | initAlignedSeriesAggregationScanOperator(aggregators, null, false, null); |
154 | 155 | int count = 0; |
155 | 156 | while (seriesAggregationScanOperator.hasNext()) { |
156 | | - TsBlock resultTsBlock = seriesAggregationScanOperator.next(); |
| 157 | + TsBlock resultTsBlock = nextNonNullOrEmpty(seriesAggregationScanOperator); |
157 | 158 | for (int i = 0; i < measurementSchemas.size(); i++) { |
158 | 159 | assertEquals(500, resultTsBlock.getColumn(i).getLong(0)); |
159 | 160 | } |
@@ -189,7 +190,7 @@ public void testMultiAggregationFuncWithoutTimeFilter1() throws Exception { |
189 | 190 | initAlignedSeriesAggregationScanOperator(aggregators, null, true, null); |
190 | 191 | int count = 0; |
191 | 192 | while (seriesAggregationScanOperator.hasNext()) { |
192 | | - TsBlock resultTsBlock = seriesAggregationScanOperator.next(); |
| 193 | + TsBlock resultTsBlock = nextNonNullOrEmpty(seriesAggregationScanOperator); |
193 | 194 | assertEquals(500, resultTsBlock.getColumn(0).getLong(0)); |
194 | 195 | assertEquals(6524750.0, resultTsBlock.getColumn(1).getDouble(0), 0.0001); |
195 | 196 | count++; |
@@ -227,7 +228,7 @@ public void testMultiAggregationFuncWithoutTimeFilter2() throws Exception { |
227 | 228 | initAlignedSeriesAggregationScanOperator(aggregators, null, true, null); |
228 | 229 | int count = 0; |
229 | 230 | while (seriesAggregationScanOperator.hasNext()) { |
230 | | - TsBlock resultTsBlock = seriesAggregationScanOperator.next(); |
| 231 | + TsBlock resultTsBlock = nextNonNullOrEmpty(seriesAggregationScanOperator); |
231 | 232 | assertTrue(resultTsBlock.getColumn(0).getBoolean(0)); |
232 | 233 | assertEquals(10499, resultTsBlock.getColumn(1).getInt(0)); |
233 | 234 | assertEquals(20199, resultTsBlock.getColumn(2).getLong(0)); |
@@ -269,7 +270,7 @@ public void testMultiAggregationFuncWithoutTimeFilterOrderByTimeDesc() throws Ex |
269 | 270 | initAlignedSeriesAggregationScanOperator(aggregators, null, false, null); |
270 | 271 | int count = 0; |
271 | 272 | while (seriesAggregationScanOperator.hasNext()) { |
272 | | - TsBlock resultTsBlock = seriesAggregationScanOperator.next(); |
| 273 | + TsBlock resultTsBlock = nextNonNullOrEmpty(seriesAggregationScanOperator); |
273 | 274 | assertTrue(resultTsBlock.getColumn(0).getBoolean(0)); |
274 | 275 | assertEquals(10499, resultTsBlock.getColumn(1).getInt(0)); |
275 | 276 | assertEquals(20199, resultTsBlock.getColumn(2).getLong(0)); |
@@ -304,7 +305,7 @@ public void testAggregationWithTimeFilter1() throws Exception { |
304 | 305 | initAlignedSeriesAggregationScanOperator(aggregators, timeFilter, true, null); |
305 | 306 | int count = 0; |
306 | 307 | while (seriesAggregationScanOperator.hasNext()) { |
307 | | - TsBlock resultTsBlock = seriesAggregationScanOperator.next(); |
| 308 | + TsBlock resultTsBlock = nextNonNullOrEmpty(seriesAggregationScanOperator); |
308 | 309 | for (int i = 0; i < measurementSchemas.size(); i++) { |
309 | 310 | assertEquals(resultTsBlock.getColumn(i).getLong(0), 380); |
310 | 311 | } |
@@ -337,7 +338,7 @@ public void testAggregationWithTimeFilter2() throws Exception { |
337 | 338 | initAlignedSeriesAggregationScanOperator(aggregators, timeFilter, true, null); |
338 | 339 | int count = 0; |
339 | 340 | while (seriesAggregationScanOperator.hasNext()) { |
340 | | - TsBlock resultTsBlock = seriesAggregationScanOperator.next(); |
| 341 | + TsBlock resultTsBlock = nextNonNullOrEmpty(seriesAggregationScanOperator); |
341 | 342 | for (int i = 0; i < measurementSchemas.size(); i++) { |
342 | 343 | assertEquals(resultTsBlock.getColumn(i).getLong(0), 380); |
343 | 344 | } |
@@ -370,7 +371,7 @@ public void testAggregationWithTimeFilter3() throws Exception { |
370 | 371 | initAlignedSeriesAggregationScanOperator(aggregators, timeFilter, true, null); |
371 | 372 | int count = 0; |
372 | 373 | while (seriesAggregationScanOperator.hasNext()) { |
373 | | - TsBlock resultTsBlock = seriesAggregationScanOperator.next(); |
| 374 | + TsBlock resultTsBlock = nextNonNullOrEmpty(seriesAggregationScanOperator); |
374 | 375 | for (int i = 0; i < measurementSchemas.size(); i++) { |
375 | 376 | assertEquals(resultTsBlock.getColumn(i).getLong(0), 300); |
376 | 377 | } |
@@ -410,7 +411,7 @@ public void testMultiAggregationWithTimeFilter() throws Exception { |
410 | 411 | initAlignedSeriesAggregationScanOperator(aggregators, timeFilter, true, null); |
411 | 412 | int count = 0; |
412 | 413 | while (seriesAggregationScanOperator.hasNext()) { |
413 | | - TsBlock resultTsBlock = seriesAggregationScanOperator.next(); |
| 414 | + TsBlock resultTsBlock = nextNonNullOrEmpty(seriesAggregationScanOperator); |
414 | 415 | assertTrue(resultTsBlock.getColumn(0).getBoolean(0)); |
415 | 416 | assertEquals(399, resultTsBlock.getColumn(1).getInt(0)); |
416 | 417 | assertEquals(20199, resultTsBlock.getColumn(2).getLong(0)); |
@@ -448,7 +449,7 @@ public void testGroupByWithoutGlobalTimeFilter() throws Exception { |
448 | 449 | initAlignedSeriesAggregationScanOperator(aggregators, null, true, groupByTimeParameter); |
449 | 450 | int count = 0; |
450 | 451 | while (seriesAggregationScanOperator.hasNext()) { |
451 | | - TsBlock resultTsBlock = seriesAggregationScanOperator.next(); |
| 452 | + TsBlock resultTsBlock = nextNonNullOrEmpty(seriesAggregationScanOperator); |
452 | 453 | int positionCount = resultTsBlock.getPositionCount(); |
453 | 454 | for (int pos = 0; pos < positionCount; pos++) { |
454 | 455 | assertEquals(100 * count, resultTsBlock.getTimeColumn().getLong(pos)); |
@@ -489,7 +490,7 @@ public void testGroupByWithGlobalTimeFilter() throws Exception { |
489 | 490 | aggregators, timeFilter, true, groupByTimeParameter); |
490 | 491 | int count = 0; |
491 | 492 | while (seriesAggregationScanOperator.hasNext()) { |
492 | | - TsBlock resultTsBlock = seriesAggregationScanOperator.next(); |
| 493 | + TsBlock resultTsBlock = nextNonNullOrEmpty(seriesAggregationScanOperator); |
493 | 494 | int positionCount = resultTsBlock.getPositionCount(); |
494 | 495 | for (int pos = 0; pos < positionCount; pos++) { |
495 | 496 | assertEquals(100 * count, resultTsBlock.getTimeColumn().getLong(pos)); |
@@ -533,7 +534,7 @@ public void testGroupByWithMultiFunction() throws Exception { |
533 | 534 | initAlignedSeriesAggregationScanOperator(aggregators, null, true, groupByTimeParameter); |
534 | 535 | int count = 0; |
535 | 536 | while (seriesAggregationScanOperator.hasNext()) { |
536 | | - TsBlock resultTsBlock = seriesAggregationScanOperator.next(); |
| 537 | + TsBlock resultTsBlock = nextNonNullOrEmpty(seriesAggregationScanOperator); |
537 | 538 | int positionCount = resultTsBlock.getPositionCount(); |
538 | 539 | for (int pos = 0; pos < positionCount; pos++) { |
539 | 540 | assertEquals(100 * count, resultTsBlock.getTimeColumn().getLong(pos)); |
@@ -578,7 +579,7 @@ public void testGroupByWithMultiFunctionOrderByTimeDesc() throws Exception { |
578 | 579 | initAlignedSeriesAggregationScanOperator(aggregators, null, false, groupByTimeParameter); |
579 | 580 | int count = 0; |
580 | 581 | while (seriesAggregationScanOperator.hasNext()) { |
581 | | - TsBlock resultTsBlock = seriesAggregationScanOperator.next(); |
| 582 | + TsBlock resultTsBlock = nextNonNullOrEmpty(seriesAggregationScanOperator); |
582 | 583 | int positionCount = resultTsBlock.getPositionCount(); |
583 | 584 | for (int pos = 0; pos < positionCount; pos++) { |
584 | 585 | assertEquals(100 * (3 - count), resultTsBlock.getTimeColumn().getLong(pos)); |
@@ -613,7 +614,7 @@ public void testGroupBySlidingTimeWindow() throws Exception { |
613 | 614 | initAlignedSeriesAggregationScanOperator(aggregators, null, true, groupByTimeParameter); |
614 | 615 | int count = 0; |
615 | 616 | while (seriesAggregationScanOperator.hasNext()) { |
616 | | - TsBlock resultTsBlock = seriesAggregationScanOperator.next(); |
| 617 | + TsBlock resultTsBlock = nextNonNullOrEmpty(seriesAggregationScanOperator); |
617 | 618 | int positionCount = resultTsBlock.getPositionCount(); |
618 | 619 | for (int pos = 0; pos < positionCount; pos++) { |
619 | 620 | assertEquals(50 * count, resultTsBlock.getTimeColumn().getLong(pos)); |
@@ -645,7 +646,7 @@ public void testGroupBySlidingTimeWindow2() throws Exception { |
645 | 646 | initAlignedSeriesAggregationScanOperator(aggregators, null, true, groupByTimeParameter); |
646 | 647 | int count = 0; |
647 | 648 | while (seriesAggregationScanOperator.hasNext()) { |
648 | | - TsBlock resultTsBlock = seriesAggregationScanOperator.next(); |
| 649 | + TsBlock resultTsBlock = nextNonNullOrEmpty(seriesAggregationScanOperator); |
649 | 650 | int positionCount = resultTsBlock.getPositionCount(); |
650 | 651 | for (int pos = 0; pos < positionCount; pos++) { |
651 | 652 | assertEquals(timeColumn[count], resultTsBlock.getTimeColumn().getLong(pos)); |
@@ -688,7 +689,7 @@ public void testGroupBySlidingWindowWithMultiFunction() throws Exception { |
688 | 689 | initAlignedSeriesAggregationScanOperator(aggregators, null, true, groupByTimeParameter); |
689 | 690 | int count = 0; |
690 | 691 | while (seriesAggregationScanOperator.hasNext()) { |
691 | | - TsBlock resultTsBlock = seriesAggregationScanOperator.next(); |
| 692 | + TsBlock resultTsBlock = nextNonNullOrEmpty(seriesAggregationScanOperator); |
692 | 693 | int positionCount = resultTsBlock.getPositionCount(); |
693 | 694 | for (int pos = 0; pos < positionCount; pos++) { |
694 | 695 | assertEquals(timeColumn[count], resultTsBlock.getTimeColumn().getLong(pos)); |
|
0 commit comments