|
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)); |
@@ -534,7 +535,7 @@ public void testGroupByWithMultiFunction() throws Exception { |
534 | 535 | initAlignedSeriesAggregationScanOperator(aggregators, null, true, groupByTimeParameter); |
535 | 536 | int count = 0; |
536 | 537 | while (seriesAggregationScanOperator.hasNext()) { |
537 | | - TsBlock resultTsBlock = seriesAggregationScanOperator.next(); |
| 538 | + TsBlock resultTsBlock = nextNonNullOrEmpty(seriesAggregationScanOperator); |
538 | 539 | int positionCount = resultTsBlock.getPositionCount(); |
539 | 540 | for (int pos = 0; pos < positionCount; pos++) { |
540 | 541 | assertEquals(100 * count, resultTsBlock.getTimeColumn().getLong(pos)); |
@@ -580,7 +581,7 @@ public void testGroupByWithMultiFunctionOrderByTimeDesc() throws Exception { |
580 | 581 | initAlignedSeriesAggregationScanOperator(aggregators, null, false, groupByTimeParameter); |
581 | 582 | int count = 0; |
582 | 583 | while (seriesAggregationScanOperator.hasNext()) { |
583 | | - TsBlock resultTsBlock = seriesAggregationScanOperator.next(); |
| 584 | + TsBlock resultTsBlock = nextNonNullOrEmpty(seriesAggregationScanOperator); |
584 | 585 | int positionCount = resultTsBlock.getPositionCount(); |
585 | 586 | for (int pos = 0; pos < positionCount; pos++) { |
586 | 587 | assertEquals(100 * (3 - count), resultTsBlock.getTimeColumn().getLong(pos)); |
@@ -616,7 +617,7 @@ public void testGroupBySlidingTimeWindow() throws Exception { |
616 | 617 | initAlignedSeriesAggregationScanOperator(aggregators, null, true, groupByTimeParameter); |
617 | 618 | int count = 0; |
618 | 619 | while (seriesAggregationScanOperator.hasNext()) { |
619 | | - TsBlock resultTsBlock = seriesAggregationScanOperator.next(); |
| 620 | + TsBlock resultTsBlock = nextNonNullOrEmpty(seriesAggregationScanOperator); |
620 | 621 | int positionCount = resultTsBlock.getPositionCount(); |
621 | 622 | for (int pos = 0; pos < positionCount; pos++) { |
622 | 623 | assertEquals(50 * count, resultTsBlock.getTimeColumn().getLong(pos)); |
@@ -649,7 +650,7 @@ public void testGroupBySlidingTimeWindow2() throws Exception { |
649 | 650 | initAlignedSeriesAggregationScanOperator(aggregators, null, true, groupByTimeParameter); |
650 | 651 | int count = 0; |
651 | 652 | while (seriesAggregationScanOperator.hasNext()) { |
652 | | - TsBlock resultTsBlock = seriesAggregationScanOperator.next(); |
| 653 | + TsBlock resultTsBlock = nextNonNullOrEmpty(seriesAggregationScanOperator); |
653 | 654 | int positionCount = resultTsBlock.getPositionCount(); |
654 | 655 | for (int pos = 0; pos < positionCount; pos++) { |
655 | 656 | assertEquals(timeColumn[count], resultTsBlock.getTimeColumn().getLong(pos)); |
@@ -693,7 +694,7 @@ public void testGroupBySlidingWindowWithMultiFunction() throws Exception { |
693 | 694 | initAlignedSeriesAggregationScanOperator(aggregators, null, true, groupByTimeParameter); |
694 | 695 | int count = 0; |
695 | 696 | while (seriesAggregationScanOperator.hasNext()) { |
696 | | - TsBlock resultTsBlock = seriesAggregationScanOperator.next(); |
| 697 | + TsBlock resultTsBlock = nextNonNullOrEmpty(seriesAggregationScanOperator); |
697 | 698 | int positionCount = resultTsBlock.getPositionCount(); |
698 | 699 | for (int pos = 0; pos < positionCount; pos++) { |
699 | 700 | assertEquals(timeColumn[count], resultTsBlock.getTimeColumn().getLong(pos)); |
|
0 commit comments