use of org.apache.flink.table.data.conversion.DataStructureConverter in project flink by apache.
the class MaterializedCollectStreamResultTest method testLimitedSnapshot.
@Test
public void testLimitedSnapshot() throws Exception {
final ResolvedSchema schema = ResolvedSchema.physical(new String[] { "f0", "f1" }, new DataType[] { DataTypes.STRING(), DataTypes.INT() });
@SuppressWarnings({ "unchecked", "rawtypes" }) final DataStructureConverter<RowData, Row> rowConverter = (DataStructureConverter) DataStructureConverters.getConverter(schema.toPhysicalRowDataType());
// with 3 rows overcommitment
try (TestMaterializedCollectStreamResult result = new TestMaterializedCollectStreamResult(new TestTableResult(ResultKind.SUCCESS_WITH_CONTENT, schema), 2, 3, createInternalBinaryRowDataConverter(schema.toPhysicalRowDataType()))) {
result.isRetrieving = true;
result.processRecord(Row.ofKind(RowKind.INSERT, "D", 1));
result.processRecord(Row.ofKind(RowKind.INSERT, "A", 1));
result.processRecord(Row.ofKind(RowKind.INSERT, "B", 1));
result.processRecord(Row.ofKind(RowKind.INSERT, "A", 1));
assertRowEquals(Arrays.asList(null, null, Row.ofKind(RowKind.INSERT, "B", 1), // two over-committed rows
Row.ofKind(RowKind.INSERT, "A", 1)), result.getMaterializedTable(), rowConverter);
assertEquals(TypedResult.payload(2), result.snapshot(1));
assertRowEquals(Collections.singletonList(Row.ofKind(RowKind.INSERT, "B", 1)), result.retrievePage(1), rowConverter);
assertRowEquals(Collections.singletonList(Row.ofKind(RowKind.INSERT, "A", 1)), result.retrievePage(2), rowConverter);
result.processRecord(Row.ofKind(RowKind.INSERT, "C", 1));
assertRowEquals(Arrays.asList(Row.ofKind(RowKind.INSERT, "A", 1), // limit clean up has taken place
Row.ofKind(RowKind.INSERT, "C", 1)), result.getMaterializedTable(), rowConverter);
result.processRecord(Row.ofKind(RowKind.DELETE, "A", 1));
assertRowEquals(Collections.singletonList(// regular clean up has taken place
Row.ofKind(RowKind.INSERT, "C", 1)), result.getMaterializedTable(), rowConverter);
}
}
Aggregations