Search in sources :

Example 1 with PaddingLeftMapFunction

use of org.apache.flink.table.runtime.operators.join.interval.PaddingLeftMapFunction in project flink by apache.

the class StreamExecIntervalJoin method createNegativeWindowSizeJoin.

private Transformation<RowData> createNegativeWindowSizeJoin(JoinSpec joinSpec, Transformation<RowData> leftInputTransform, Transformation<RowData> rightInputTransform, int leftArity, int rightArity, InternalTypeInfo<RowData> returnTypeInfo, ReadableConfig config) {
    // We filter all records instead of adding an empty source to preserve the watermarks.
    FilterAllFlatMapFunction allFilter = new FilterAllFlatMapFunction(returnTypeInfo);
    OuterJoinPaddingUtil paddingUtil = new OuterJoinPaddingUtil(leftArity, rightArity);
    PaddingLeftMapFunction leftPadder = new PaddingLeftMapFunction(paddingUtil, returnTypeInfo);
    PaddingRightMapFunction rightPadder = new PaddingRightMapFunction(paddingUtil, returnTypeInfo);
    int leftParallelism = leftInputTransform.getParallelism();
    int rightParallelism = rightInputTransform.getParallelism();
    OneInputTransformation<RowData, RowData> filterAllLeftStream = new OneInputTransformation<>(leftInputTransform, "FilterLeft", new StreamFlatMap<>(allFilter), returnTypeInfo, leftParallelism);
    filterAllLeftStream.setUid(createTransformationUid(FILTER_LEFT_TRANSFORMATION));
    filterAllLeftStream.setDescription(createFormattedTransformationDescription("filter all left input transformation", config));
    filterAllLeftStream.setName(createFormattedTransformationName(filterAllLeftStream.getDescription(), "FilterLeft", config));
    OneInputTransformation<RowData, RowData> filterAllRightStream = new OneInputTransformation<>(rightInputTransform, "FilterRight", new StreamFlatMap<>(allFilter), returnTypeInfo, rightParallelism);
    filterAllRightStream.setUid(createTransformationUid(FILTER_RIGHT_TRANSFORMATION));
    filterAllRightStream.setDescription(createFormattedTransformationDescription("filter all right input transformation", config));
    filterAllRightStream.setName(createFormattedTransformationName(filterAllRightStream.getDescription(), "FilterRight", config));
    OneInputTransformation<RowData, RowData> padLeftStream = new OneInputTransformation<>(leftInputTransform, "PadLeft", new StreamMap<>(leftPadder), returnTypeInfo, leftParallelism);
    padLeftStream.setUid(createTransformationUid(PAD_LEFT_TRANSFORMATION));
    padLeftStream.setDescription(createFormattedTransformationDescription("pad left input transformation", config));
    padLeftStream.setName(createFormattedTransformationName(padLeftStream.getDescription(), "PadLeft", config));
    OneInputTransformation<RowData, RowData> padRightStream = new OneInputTransformation<>(rightInputTransform, "PadRight", new StreamMap<>(rightPadder), returnTypeInfo, rightParallelism);
    padRightStream.setUid(createTransformationUid(PAD_RIGHT_TRANSFORMATION));
    padRightStream.setDescription(createFormattedTransformationDescription("pad right input transformation", config));
    padRightStream.setName(createFormattedTransformationName(padRightStream.getDescription(), "PadRight", config));
    switch(joinSpec.getJoinType()) {
        case INNER:
            return new UnionTransformation<>(Lists.newArrayList(filterAllLeftStream, filterAllRightStream));
        case LEFT:
            return new UnionTransformation<>(Lists.newArrayList(padLeftStream, filterAllRightStream));
        case RIGHT:
            return new UnionTransformation<>(Lists.newArrayList(filterAllLeftStream, padRightStream));
        case FULL:
            return new UnionTransformation<>(Lists.newArrayList(padLeftStream, padRightStream));
        default:
            throw new TableException("should no reach here");
    }
}
Also used : FilterAllFlatMapFunction(org.apache.flink.table.runtime.operators.join.interval.FilterAllFlatMapFunction) RowData(org.apache.flink.table.data.RowData) TableException(org.apache.flink.table.api.TableException) PaddingLeftMapFunction(org.apache.flink.table.runtime.operators.join.interval.PaddingLeftMapFunction) UnionTransformation(org.apache.flink.streaming.api.transformations.UnionTransformation) PaddingRightMapFunction(org.apache.flink.table.runtime.operators.join.interval.PaddingRightMapFunction) OneInputTransformation(org.apache.flink.streaming.api.transformations.OneInputTransformation) OuterJoinPaddingUtil(org.apache.flink.table.runtime.operators.join.OuterJoinPaddingUtil)

Aggregations

OneInputTransformation (org.apache.flink.streaming.api.transformations.OneInputTransformation)1 UnionTransformation (org.apache.flink.streaming.api.transformations.UnionTransformation)1 TableException (org.apache.flink.table.api.TableException)1 RowData (org.apache.flink.table.data.RowData)1 OuterJoinPaddingUtil (org.apache.flink.table.runtime.operators.join.OuterJoinPaddingUtil)1 FilterAllFlatMapFunction (org.apache.flink.table.runtime.operators.join.interval.FilterAllFlatMapFunction)1 PaddingLeftMapFunction (org.apache.flink.table.runtime.operators.join.interval.PaddingLeftMapFunction)1 PaddingRightMapFunction (org.apache.flink.table.runtime.operators.join.interval.PaddingRightMapFunction)1