use of org.apache.flink.table.data.RowData in project flink by apache.
the class StreamArrowPythonProcTimeBoundedRangeOperatorTest method testOverWindowAggregateFunction.
@Test
public void testOverWindowAggregateFunction() throws Exception {
OneInputStreamOperatorTestHarness<RowData, RowData> testHarness = getTestHarness(new Configuration());
ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<>();
testHarness.open();
testHarness.setProcessingTime(100);
testHarness.processElement(new StreamRecord<>(newBinaryRow(true, "c1", "c2", 0L)));
testHarness.setProcessingTime(150);
testHarness.processElement(new StreamRecord<>(newBinaryRow(true, "c1", "c4", 1L)));
testHarness.setProcessingTime(200);
testHarness.processElement(new StreamRecord<>(newBinaryRow(true, "c1", "c6", 2L)));
testHarness.setProcessingTime(300);
testHarness.processElement(new StreamRecord<>(newBinaryRow(true, "c2", "c8", 3L)));
testHarness.setProcessingTime(600);
testHarness.close();
expectedOutput.add(new StreamRecord<>(newRow(true, "c1", "c2", 0L, 0L)));
expectedOutput.add(new StreamRecord<>(newRow(true, "c1", "c4", 1L, 0L)));
expectedOutput.add(new StreamRecord<>(newRow(true, "c1", "c6", 2L, 1L)));
expectedOutput.add(new StreamRecord<>(newRow(true, "c2", "c8", 3L, 3L)));
assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput());
}
use of org.apache.flink.table.data.RowData in project flink by apache.
the class StreamArrowPythonRowTimeBoundedRangeOperatorTest method testStateCleanup.
@Test
public void testStateCleanup() throws Exception {
Configuration conf = new Configuration();
OneInputStreamOperatorTestHarness<RowData, RowData> testHarness = getTestHarness(conf);
AbstractStreamOperator<RowData> operator = testHarness.getOperator();
testHarness.open();
AbstractKeyedStateBackend stateBackend = (AbstractKeyedStateBackend) operator.getKeyedStateBackend();
assertEquals("Initial state is not empty", 0, stateBackend.numKeyValueStateEntries());
testHarness.processElement(new StreamRecord<>(newBinaryRow(true, "c1", "c2", 0L, 100L)));
testHarness.processElement(new StreamRecord<>(newBinaryRow(true, "c1", "c4", 1L, 100L)));
testHarness.processElement(new StreamRecord<>(newBinaryRow(true, "c1", "c6", 2L, 500L)));
testHarness.processWatermark(new Watermark(1000L));
// at this moment we expect the function to have some records in state
testHarness.processWatermark(new Watermark(4000L));
// at this moment the function should have cleaned up states
assertEquals("State has not been cleaned up", 0, stateBackend.numKeyValueStateEntries());
testHarness.close();
}
use of org.apache.flink.table.data.RowData in project flink by apache.
the class BatchArrowPythonOverWindowAggregateFunctionOperatorTest method testOverWindowAggregateFunction.
@Test
public void testOverWindowAggregateFunction() throws Exception {
OneInputStreamOperatorTestHarness<RowData, RowData> testHarness = getTestHarness(new Configuration());
long initialTime = 0L;
ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<>();
testHarness.open();
testHarness.processElement(new StreamRecord<>(newBinaryRow(true, "c1", "c2", 0L, 0L), initialTime + 1));
testHarness.processElement(new StreamRecord<>(newBinaryRow(true, "c1", "c4", 1L, 0L), initialTime + 2));
testHarness.processElement(new StreamRecord<>(newBinaryRow(true, "c1", "c6", 2L, 10L), initialTime + 3));
testHarness.processElement(new StreamRecord<>(newBinaryRow(true, "c2", "c8", 3L, 0L), initialTime + 3));
testHarness.close();
expectedOutput.add(new StreamRecord<>(newRow(true, "c1", "c2", 0L, 0L, 0L)));
expectedOutput.add(new StreamRecord<>(newRow(true, "c1", "c4", 1L, 0L, 0L)));
expectedOutput.add(new StreamRecord<>(newRow(true, "c1", "c6", 2L, 10L, 2L)));
expectedOutput.add(new StreamRecord<>(newRow(true, "c2", "c8", 3L, 0L, 3L)));
assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput());
}
use of org.apache.flink.table.data.RowData in project flink by apache.
the class StreamArrowPythonGroupWindowAggregateFunctionOperatorTest method testGroupWindowAggregateFunction.
@Test
public void testGroupWindowAggregateFunction() throws Exception {
OneInputStreamOperatorTestHarness<RowData, RowData> testHarness = getTestHarness(new Configuration());
long initialTime = 0L;
ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<>();
testHarness.open();
testHarness.processElement(new StreamRecord<>(newBinaryRow(true, "c1", "c2", 0L, 0L), initialTime + 1));
testHarness.processElement(new StreamRecord<>(newBinaryRow(true, "c1", "c4", 1L, 6000L), initialTime + 2));
testHarness.processElement(new StreamRecord<>(newBinaryRow(true, "c1", "c6", 2L, 10000L), initialTime + 3));
testHarness.processElement(new StreamRecord<>(newBinaryRow(true, "c2", "c8", 3L, 0L), initialTime + 4));
testHarness.processElement(new StreamRecord<>(newBinaryRow(true, "c3", "c8", 3L, 0L), initialTime + 5));
testHarness.processElement(new StreamRecord<>(newBinaryRow(false, "c3", "c8", 3L, 0L), initialTime + 6));
testHarness.processWatermark(Long.MAX_VALUE);
testHarness.close();
expectedOutput.add(new Watermark(Long.MAX_VALUE));
expectedOutput.add(new StreamRecord<>(newRow(true, "c1", 0L, TimestampData.fromEpochMillis(-5000L), TimestampData.fromEpochMillis(5000L))));
expectedOutput.add(new StreamRecord<>(newRow(true, "c2", 3L, TimestampData.fromEpochMillis(-5000L), TimestampData.fromEpochMillis(5000L))));
expectedOutput.add(new StreamRecord<>(newRow(true, "c1", 0L, TimestampData.fromEpochMillis(0L), TimestampData.fromEpochMillis(10000L))));
expectedOutput.add(new StreamRecord<>(newRow(true, "c2", 3L, TimestampData.fromEpochMillis(0L), TimestampData.fromEpochMillis(10000L))));
expectedOutput.add(new StreamRecord<>(newRow(true, "c1", 1L, TimestampData.fromEpochMillis(5000L), TimestampData.fromEpochMillis(15000L))));
expectedOutput.add(new StreamRecord<>(newRow(true, "c1", 2L, TimestampData.fromEpochMillis(10000L), TimestampData.fromEpochMillis(20000L))));
assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput());
}
use of org.apache.flink.table.data.RowData in project flink by apache.
the class StreamArrowPythonGroupWindowAggregateFunctionOperatorTest method testFinishBundleTriggeredByCount.
@Test
public void testFinishBundleTriggeredByCount() throws Exception {
Configuration conf = new Configuration();
conf.setInteger(PythonOptions.MAX_BUNDLE_SIZE, 4);
OneInputStreamOperatorTestHarness<RowData, RowData> testHarness = getTestHarness(conf);
long initialTime = 0L;
ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<>();
testHarness.open();
testHarness.processElement(new StreamRecord<>(newBinaryRow(true, "c1", "c2", 0L, 0L), initialTime + 1));
testHarness.processElement(new StreamRecord<>(newBinaryRow(true, "c1", "c4", 1L, 6000L), initialTime + 2));
testHarness.processElement(new StreamRecord<>(newBinaryRow(true, "c1", "c6", 2L, 10000L), initialTime + 3));
testHarness.processElement(new StreamRecord<>(newBinaryRow(true, "c2", "c8", 3L, 0L), initialTime + 4));
testHarness.processWatermark(new Watermark(10000L));
expectedOutput.add(new StreamRecord<>(newRow(true, "c1", 0L, TimestampData.fromEpochMillis(-5000L), TimestampData.fromEpochMillis(5000L))));
expectedOutput.add(new StreamRecord<>(newRow(true, "c2", 3L, TimestampData.fromEpochMillis(-5000L), TimestampData.fromEpochMillis(5000L))));
expectedOutput.add(new StreamRecord<>(newRow(true, "c2", 3L, TimestampData.fromEpochMillis(0L), TimestampData.fromEpochMillis(10000L))));
expectedOutput.add(new StreamRecord<>(newRow(true, "c1", 0L, TimestampData.fromEpochMillis(0L), TimestampData.fromEpochMillis(10000L))));
expectedOutput.add(new Watermark(10000L));
assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput());
testHarness.processWatermark(20000L);
testHarness.close();
expectedOutput.add(new Watermark(20000L));
expectedOutput.add(new StreamRecord<>(newRow(true, "c1", 1L, TimestampData.fromEpochMillis(5000L), TimestampData.fromEpochMillis(15000L))));
expectedOutput.add(new StreamRecord<>(newRow(true, "c1", 2L, TimestampData.fromEpochMillis(10000L), TimestampData.fromEpochMillis(20000L))));
assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput());
}
Aggregations