use of org.apache.flink.table.runtime.util.GenericRowRecordSortComparator in project flink by apache.
the class WindowOperatorTest method testProcessingTimeSessionWindows.
@Test
public void testProcessingTimeSessionWindows() throws Throwable {
closeCalled.set(0);
WindowOperator operator = WindowOperatorBuilder.builder().withInputFields(inputFieldTypes).withShiftTimezone(shiftTimeZone).session(Duration.ofSeconds(3)).withProcessingTime().aggregateAndBuild(getTimeWindowAggFunction(), equaliser, accTypes, aggResultTypes, windowTypes);
OneInputStreamOperatorTestHarness<RowData, RowData> testHarness = createTestHarness(operator);
RowDataHarnessAssertor assertor = new RowDataHarnessAssertor(outputType.toRowFieldTypes(), new GenericRowRecordSortComparator(0, VarCharType.STRING_TYPE));
ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<>();
testHarness.open();
// timestamp is ignored in processing time
testHarness.setProcessingTime(3);
testHarness.processElement(insertRecord("key2", 1, 1L));
testHarness.setProcessingTime(1000);
testHarness.processElement(insertRecord("key2", 1, 1002L));
testHarness.setProcessingTime(5000);
expectedOutput.addAll(doubleRecord(isTableAggregate, insertRecord("key2", 2L, 2L, localMills(3L), localMills(4000L), localMills(3999L))));
assertor.assertOutputEqualsSorted("Output was not correct.", expectedOutput, testHarness.getOutput());
testHarness.processElement(insertRecord("key2", 1, 5000L));
testHarness.processElement(insertRecord("key2", 1, 5000L));
testHarness.processElement(insertRecord("key1", 1, 5000L));
testHarness.processElement(insertRecord("key1", 1, 5000L));
testHarness.processElement(insertRecord("key1", 1, 5000L));
testHarness.setProcessingTime(10000);
expectedOutput.addAll(doubleRecord(isTableAggregate, insertRecord("key2", 2L, 2L, localMills(5000L), localMills(8000L), localMills(7999L))));
expectedOutput.addAll(doubleRecord(isTableAggregate, insertRecord("key1", 3L, 3L, localMills(5000L), localMills(8000L), localMills(7999L))));
assertor.assertOutputEqualsSorted("Output was not correct.", expectedOutput, testHarness.getOutput());
testHarness.close();
}
Aggregations