Search in sources :

Example 1 with BroadcastingOutput

use of org.apache.flink.table.runtime.operators.multipleinput.output.BroadcastingOutput in project flink by apache.

the class MultipleInputStreamOperatorBase method createAllOperators.

/**
 * Create all sub-operators by corresponding operator factory in a multiple input operator from
 * <b>tail to head</b>.
 */
@SuppressWarnings("unchecked")
private void createAllOperators(StreamOperatorParameters<RowData> parameters) {
    final boolean isObjectReuseEnabled = parameters.getContainingTask().getExecutionConfig().isObjectReuseEnabled();
    final ExecutionConfig executionConfig = parameters.getContainingTask().getExecutionConfig();
    final Iterator<TableOperatorWrapper<?>> it = topologicalOrderingOperators.descendingIterator();
    while (it.hasNext()) {
        final TableOperatorWrapper<?> wrapper = it.next();
        final Output<StreamRecord<RowData>> output;
        if (wrapper == this.tailWrapper) {
            output = this.output;
        } else {
            final int numberOfOutputs = wrapper.getOutputEdges().size();
            final Output<StreamRecord<RowData>>[] outputs = new Output[numberOfOutputs];
            for (int i = 0; i < numberOfOutputs; ++i) {
                TableOperatorWrapper.Edge edge = wrapper.getOutputEdges().get(i);
                int inputId = edge.getInputId();
                StreamOperator<RowData> outputOperator = edge.getTarget().getStreamOperator();
                if (isObjectReuseEnabled) {
                    outputs[i] = createOutput(outputOperator, inputId);
                } else {
                    // the source's output type info is equal to the target's type info for the
                    // corresponding index
                    TypeSerializer<RowData> serializer = (TypeSerializer<RowData>) edge.getSource().getOutputType().createSerializer(executionConfig);
                    outputs[i] = createCopyingOutput(serializer, outputOperator, inputId);
                }
            }
            if (outputs.length == 1) {
                output = outputs[0];
            } else {
                // Because user's operator may change the record passed to it.
                if (isObjectReuseEnabled) {
                    output = new CopyingBroadcastingOutput(outputs);
                } else {
                    output = new BroadcastingOutput(outputs);
                }
            }
        }
        final StreamOperatorParameters<RowData> newParameters = createSubOperatorParameters(parameters, output, wrapper);
        wrapper.createOperator(newParameters);
    }
}
Also used : StreamRecord(org.apache.flink.streaming.runtime.streamrecord.StreamRecord) ExecutionConfig(org.apache.flink.api.common.ExecutionConfig) BroadcastingOutput(org.apache.flink.table.runtime.operators.multipleinput.output.BroadcastingOutput) CopyingBroadcastingOutput(org.apache.flink.table.runtime.operators.multipleinput.output.CopyingBroadcastingOutput) RowData(org.apache.flink.table.data.RowData) CopyingBroadcastingOutput(org.apache.flink.table.runtime.operators.multipleinput.output.CopyingBroadcastingOutput) OneInputStreamOperatorOutput(org.apache.flink.table.runtime.operators.multipleinput.output.OneInputStreamOperatorOutput) BroadcastingOutput(org.apache.flink.table.runtime.operators.multipleinput.output.BroadcastingOutput) Output(org.apache.flink.streaming.api.operators.Output) CopyingSecondInputOfTwoInputStreamOperatorOutput(org.apache.flink.table.runtime.operators.multipleinput.output.CopyingSecondInputOfTwoInputStreamOperatorOutput) CopyingOneInputStreamOperatorOutput(org.apache.flink.table.runtime.operators.multipleinput.output.CopyingOneInputStreamOperatorOutput) FirstInputOfTwoInputStreamOperatorOutput(org.apache.flink.table.runtime.operators.multipleinput.output.FirstInputOfTwoInputStreamOperatorOutput) CopyingFirstInputOfTwoInputStreamOperatorOutput(org.apache.flink.table.runtime.operators.multipleinput.output.CopyingFirstInputOfTwoInputStreamOperatorOutput) CopyingBroadcastingOutput(org.apache.flink.table.runtime.operators.multipleinput.output.CopyingBroadcastingOutput) SecondInputOfTwoInputStreamOperatorOutput(org.apache.flink.table.runtime.operators.multipleinput.output.SecondInputOfTwoInputStreamOperatorOutput) TypeSerializer(org.apache.flink.api.common.typeutils.TypeSerializer)

Aggregations

ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)1 TypeSerializer (org.apache.flink.api.common.typeutils.TypeSerializer)1 Output (org.apache.flink.streaming.api.operators.Output)1 StreamRecord (org.apache.flink.streaming.runtime.streamrecord.StreamRecord)1 RowData (org.apache.flink.table.data.RowData)1 BroadcastingOutput (org.apache.flink.table.runtime.operators.multipleinput.output.BroadcastingOutput)1 CopyingBroadcastingOutput (org.apache.flink.table.runtime.operators.multipleinput.output.CopyingBroadcastingOutput)1 CopyingFirstInputOfTwoInputStreamOperatorOutput (org.apache.flink.table.runtime.operators.multipleinput.output.CopyingFirstInputOfTwoInputStreamOperatorOutput)1 CopyingOneInputStreamOperatorOutput (org.apache.flink.table.runtime.operators.multipleinput.output.CopyingOneInputStreamOperatorOutput)1 CopyingSecondInputOfTwoInputStreamOperatorOutput (org.apache.flink.table.runtime.operators.multipleinput.output.CopyingSecondInputOfTwoInputStreamOperatorOutput)1 FirstInputOfTwoInputStreamOperatorOutput (org.apache.flink.table.runtime.operators.multipleinput.output.FirstInputOfTwoInputStreamOperatorOutput)1 OneInputStreamOperatorOutput (org.apache.flink.table.runtime.operators.multipleinput.output.OneInputStreamOperatorOutput)1 SecondInputOfTwoInputStreamOperatorOutput (org.apache.flink.table.runtime.operators.multipleinput.output.SecondInputOfTwoInputStreamOperatorOutput)1