use of org.apache.flink.table.api.TableConfig in project flink by apache.
the class PlannerMocks method create.
public static PlannerMocks create(Configuration configuration) {
TableConfig tableConfig = new TableConfig();
tableConfig.addConfiguration(configuration);
return new PlannerMocks(tableConfig);
}
use of org.apache.flink.table.api.TableConfig in project flink by apache.
the class PushProjectIntoTableSourceScanRule method getProjections.
private List<RexNode> getProjections(LogicalProject project, LogicalTableScan scan) {
final TableSourceTable source = scan.getTable().unwrap(TableSourceTable.class);
final TableConfig tableConfig = unwrapContext(scan).getTableConfig();
final List<RexNode> projections = new ArrayList<>(project.getProjects());
if (supportsProjectionPushDown(source.tableSource()) && requiresPrimaryKey(source, tableConfig)) {
projections.addAll(getPrimaryKeyProjections(scan));
}
return projections;
}
use of org.apache.flink.table.api.TableConfig in project flink by apache.
the class CodeSplitTest method testRecordComparator.
@Test
public void testRecordComparator() {
int numFields = 600;
RowType rowType = getIntRowType(numFields);
SortSpec.SortSpecBuilder builder = SortSpec.builder();
for (int i = 0; i < numFields; i++) {
builder.addField(i, true, true);
}
SortSpec sortSpec = builder.build();
GenericRowData rowData1 = new GenericRowData(numFields);
GenericRowData rowData2 = new GenericRowData(numFields);
Random random = new Random();
for (int i = 0; i < numFields; i++) {
int x = random.nextInt(100);
rowData1.setField(i, x);
rowData2.setField(i, x);
}
int result = random.nextInt(3) - 1;
if (result == -1) {
rowData1.setField(random.nextInt(numFields), -1);
} else if (result == 1) {
rowData1.setField(random.nextInt(numFields), 100);
}
Consumer<TableConfig> consumer = tableConfig -> {
RecordComparator instance = ComparatorCodeGenerator.gen(tableConfig, "", rowType, sortSpec).newInstance(classLoader);
for (int i = 0; i < 100; i++) {
Assert.assertEquals(result, instance.compare(rowData1, rowData2));
}
};
runTest(consumer);
}
use of org.apache.flink.table.api.TableConfig 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);
}
use of org.apache.flink.table.api.TableConfig in project flink by apache.
the class LongHashJoinGeneratorTest method newOperator.
@Override
public Object newOperator(long memorySize, HashJoinType type, boolean reverseJoinFunction) {
RowType keyType = RowType.of(new IntType());
Assert.assertTrue(LongHashJoinGenerator.support(type, keyType, new boolean[] { true }));
return LongHashJoinGenerator.gen(new TableConfig(), type, keyType, RowType.of(new IntType(), new IntType()), RowType.of(new IntType(), new IntType()), new int[] { 0 }, new int[] { 0 }, 20, 10000, reverseJoinFunction, new GeneratedJoinCondition(MyJoinCondition.class.getCanonicalName(), "", new Object[0]));
}
Aggregations