use of org.apache.flink.table.runtime.generated.Projection in project flink by apache.
the class CodeSplitTest method testProjection.
@SuppressWarnings("unchecked")
@Test
public void testProjection() {
int numFields = 1000;
RowType rowType = getIntRowType(numFields);
List<Integer> order = new ArrayList<>();
for (int i = 0; i < numFields; i++) {
order.add(i);
}
Collections.shuffle(order);
GenericRowData input = new GenericRowData(numFields);
for (int i = 0; i < numFields; i++) {
input.setField(i, i);
}
BinaryRowData output = new BinaryRowData(numFields);
BinaryRowWriter outputWriter = new BinaryRowWriter(output);
for (int i = 0; i < numFields; i++) {
outputWriter.writeInt(i, order.get(i));
}
outputWriter.complete();
Consumer<TableConfig> consumer = tableConfig -> {
Projection instance = ProjectionCodeGenerator.generateProjection(new CodeGeneratorContext(tableConfig), "", rowType, rowType, order.stream().mapToInt(i -> i).toArray()).newInstance(classLoader);
for (int i = 0; i < 100; i++) {
Assert.assertEquals(output, instance.apply(input));
}
};
runTest(consumer);
}
Aggregations