use of org.apache.flink.table.data.RowData in project flink by apache.
the class PythonStreamGroupTableAggregateOperatorTest method testFlushDataOnClose.
@Test
public void testFlushDataOnClose() throws Exception {
OneInputStreamOperatorTestHarness<RowData, RowData> testHarness = getTestHarness(new Configuration());
long initialTime = 0L;
ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<>();
testHarness.open();
testHarness.processElement(new StreamRecord<>(newRow(true, "c1", 0L), initialTime + 1));
testHarness.processElement(new StreamRecord<>(newRow(false, "c2", 1L), initialTime + 2));
testHarness.close();
expectedOutput.add(new StreamRecord<>(newRow(true, "c1", 0L)));
expectedOutput.add(new StreamRecord<>(newRow(true, "c1", 0L)));
expectedOutput.add(new StreamRecord<>(newRow(false, "c2", 1L)));
expectedOutput.add(new StreamRecord<>(newRow(false, "c2", 1L)));
assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput());
}
use of org.apache.flink.table.data.RowData in project flink by apache.
the class PythonStreamGroupTableAggregateOperatorTest method testFinishBundleTriggeredByTime.
@Test
public void testFinishBundleTriggeredByTime() throws Exception {
Configuration conf = new Configuration();
conf.setInteger(PythonOptions.MAX_BUNDLE_SIZE, 10);
conf.setLong(PythonOptions.MAX_BUNDLE_TIME_MILLS, 1000L);
OneInputStreamOperatorTestHarness<RowData, RowData> testHarness = getTestHarness(conf);
long initialTime = 0L;
ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<>();
testHarness.open();
testHarness.processElement(new StreamRecord<>(newRow(true, "c1", 0L), initialTime + 1));
testHarness.processElement(new StreamRecord<>(newRow(true, "c2", 1L), initialTime + 2));
testHarness.processElement(new StreamRecord<>(newRow(true, "c3", 2L), initialTime + 3));
assertOutputEquals("FinishBundle should not be triggered.", expectedOutput, testHarness.getOutput());
testHarness.setProcessingTime(1000L);
expectedOutput.add(new StreamRecord<>(newRow(true, "c1", 0L)));
expectedOutput.add(new StreamRecord<>(newRow(true, "c1", 0L)));
expectedOutput.add(new StreamRecord<>(newRow(true, "c2", 1L)));
expectedOutput.add(new StreamRecord<>(newRow(true, "c2", 1L)));
expectedOutput.add(new StreamRecord<>(newRow(true, "c3", 2L)));
expectedOutput.add(new StreamRecord<>(newRow(true, "c3", 2L)));
assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput());
testHarness.close();
}
use of org.apache.flink.table.data.RowData in project flink by apache.
the class PythonStreamGroupTableAggregateOperatorTest method testFinishBundleTriggeredByCount.
@Test
public void testFinishBundleTriggeredByCount() throws Exception {
Configuration conf = new Configuration();
conf.setInteger(PythonOptions.MAX_BUNDLE_SIZE, 3);
OneInputStreamOperatorTestHarness<RowData, RowData> testHarness = getTestHarness(conf);
long initialTime = 0L;
ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<>();
testHarness.open();
testHarness.processElement(new StreamRecord<>(newRow(true, "c1", 0L), initialTime + 1));
testHarness.processElement(new StreamRecord<>(newRow(true, "c2", 1L), initialTime + 2));
assertOutputEquals("FinishBundle should not be triggered.", expectedOutput, testHarness.getOutput());
testHarness.processElement(new StreamRecord<>(newRow(true, "c3", 2L), initialTime + 2));
expectedOutput.add(new StreamRecord<>(newRow(true, "c1", 0L)));
expectedOutput.add(new StreamRecord<>(newRow(true, "c1", 0L)));
expectedOutput.add(new StreamRecord<>(newRow(true, "c2", 1L)));
expectedOutput.add(new StreamRecord<>(newRow(true, "c2", 1L)));
expectedOutput.add(new StreamRecord<>(newRow(true, "c3", 2L)));
expectedOutput.add(new StreamRecord<>(newRow(true, "c3", 2L)));
assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput());
testHarness.close();
}
use of org.apache.flink.table.data.RowData in project flink by apache.
the class ArrowPythonAggregateFunctionOperatorTestBase method newBinaryRow.
protected RowData newBinaryRow(boolean accumulateMsg, Object... fields) {
if (accumulateMsg) {
return binaryrow(fields);
} else {
RowData row = binaryrow(fields);
row.setRowKind(RowKind.DELETE);
return row;
}
}
use of org.apache.flink.table.data.RowData in project flink by apache.
the class BatchArrowPythonGroupAggregateFunctionOperatorTest method testFinishBundleTriggeredByTime.
@Test
public void testFinishBundleTriggeredByTime() throws Exception {
Configuration conf = new Configuration();
conf.setInteger(PythonOptions.MAX_BUNDLE_SIZE, 10);
conf.setLong(PythonOptions.MAX_BUNDLE_TIME_MILLS, 1000L);
OneInputStreamOperatorTestHarness<RowData, RowData> testHarness = getTestHarness(conf);
long initialTime = 0L;
ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<>();
testHarness.open();
testHarness.processElement(new StreamRecord<>(newRow(true, "c1", "c2", 0L), initialTime + 1));
testHarness.processElement(new StreamRecord<>(newRow(true, "c1", "c2", 1L), initialTime + 2));
testHarness.processElement(new StreamRecord<>(newRow(true, "c2", "c6", 2L), initialTime + 2));
assertOutputEquals("FinishBundle should not be triggered.", expectedOutput, testHarness.getOutput());
testHarness.setProcessingTime(1000L);
expectedOutput.add(new StreamRecord<>(newRow(true, "c1", 0L)));
assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput());
testHarness.close();
expectedOutput.add(new StreamRecord<>(newRow(true, "c2", 2L)));
assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput());
}
Aggregations