use of org.apache.flink.table.runtime.operators.join.lookup.LookupJoinRunner in project flink by apache.
the class LookupJoinHarnessTest method createHarness.
// ---------------------------------------------------------------------------------
@SuppressWarnings("unchecked")
private OneInputStreamOperatorTestHarness<RowData, RowData> createHarness(JoinType joinType, FilterOnTable filterOnTable) throws Exception {
boolean isLeftJoin = joinType == JoinType.LEFT_JOIN;
ProcessFunction<RowData, RowData> joinRunner;
if (filterOnTable == FilterOnTable.WITHOUT_FILTER) {
joinRunner = new LookupJoinRunner(new GeneratedFunctionWrapper<>(new TestingFetcherFunction()), new GeneratedCollectorWrapper<>(new TestingFetcherCollector()), isLeftJoin, 2);
} else {
joinRunner = new LookupJoinWithCalcRunner(new GeneratedFunctionWrapper<>(new TestingFetcherFunction()), new GeneratedFunctionWrapper<>(new CalculateOnTemporalTable()), new GeneratedCollectorWrapper<>(new TestingFetcherCollector()), isLeftJoin, 2);
}
ProcessOperator<RowData, RowData> operator = new ProcessOperator<>(joinRunner);
return new OneInputStreamOperatorTestHarness<>(operator, inSerializer);
}
use of org.apache.flink.table.runtime.operators.join.lookup.LookupJoinRunner in project flink by apache.
the class CommonExecLookupJoin method createSyncLookupJoin.
private StreamOperatorFactory<RowData> createSyncLookupJoin(RelOptTable temporalTable, ExecNodeConfig config, Map<Integer, LookupJoinUtil.LookupKey> allLookupKeys, TableFunction<?> syncLookupFunction, RelBuilder relBuilder, RowType inputRowType, RowType tableSourceRowType, RowType resultRowType, boolean isLeftOuterJoin, boolean isObjectReuseEnabled) {
DataTypeFactory dataTypeFactory = ShortcutUtils.unwrapContext(relBuilder).getCatalogManager().getDataTypeFactory();
int[] orderedLookupKeys = LookupJoinUtil.getOrderedLookupKeys(allLookupKeys.keySet());
GeneratedFunction<FlatMapFunction<RowData, RowData>> generatedFetcher = LookupJoinCodeGenerator.generateSyncLookupFunction(config.getTableConfig(), dataTypeFactory, inputRowType, tableSourceRowType, resultRowType, allLookupKeys, orderedLookupKeys, syncLookupFunction, StringUtils.join(temporalTable.getQualifiedName(), "."), isObjectReuseEnabled);
RowType rightRowType = Optional.ofNullable(temporalTableOutputType).map(FlinkTypeFactory::toLogicalRowType).orElse(tableSourceRowType);
CodeGeneratorContext ctx = new CodeGeneratorContext(config.getTableConfig());
GeneratedCollector<TableFunctionCollector<RowData>> generatedCollector = LookupJoinCodeGenerator.generateCollector(ctx, inputRowType, rightRowType, resultRowType, JavaScalaConversionUtil.toScala(Optional.ofNullable(joinCondition)), JavaScalaConversionUtil.toScala(Optional.empty()), true);
ProcessFunction<RowData, RowData> processFunc;
if (existCalcOnTemporalTable) {
// a projection or filter after table source scan
GeneratedFunction<FlatMapFunction<RowData, RowData>> generatedCalc = LookupJoinCodeGenerator.generateCalcMapFunction(config.getTableConfig(), JavaScalaConversionUtil.toScala(projectionOnTemporalTable), filterOnTemporalTable, temporalTableOutputType, tableSourceRowType);
processFunc = new LookupJoinWithCalcRunner(generatedFetcher, generatedCalc, generatedCollector, isLeftOuterJoin, rightRowType.getFieldCount());
} else {
// right type is the same as table source row type, because no calc after temporal table
processFunc = new LookupJoinRunner(generatedFetcher, generatedCollector, isLeftOuterJoin, rightRowType.getFieldCount());
}
return SimpleOperatorFactory.of(new ProcessOperator<>(processFunc));
}
Aggregations