Search in sources :

Example 1 with TableOperatorWrapperGenerator

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

the class BatchExecMultipleInput method translateToPlanInternal.

@Override
protected Transformation<RowData> translateToPlanInternal(PlannerBase planner, ExecNodeConfig config) {
    final List<Transformation<?>> inputTransforms = new ArrayList<>();
    for (ExecEdge inputEdge : getInputEdges()) {
        inputTransforms.add(inputEdge.translateToPlan(planner));
    }
    final Transformation<?> outputTransform = rootNode.translateToPlan(planner);
    final int[] readOrders = getInputProperties().stream().map(InputProperty::getPriority).mapToInt(i -> i).toArray();
    final TableOperatorWrapperGenerator generator = new TableOperatorWrapperGenerator(inputTransforms, outputTransform, readOrders);
    generator.generate();
    final List<Pair<Transformation<?>, InputSpec>> inputTransformAndInputSpecPairs = generator.getInputTransformAndInputSpecPairs();
    final MultipleInputTransformation<RowData> multipleInputTransform = new MultipleInputTransformation<>(createTransformationName(config), new BatchMultipleInputStreamOperatorFactory(inputTransformAndInputSpecPairs.stream().map(Pair::getValue).collect(Collectors.toList()), generator.getHeadWrappers(), generator.getTailWrapper()), InternalTypeInfo.of(getOutputType()), generator.getParallelism());
    multipleInputTransform.setDescription(createTransformationDescription(config));
    inputTransformAndInputSpecPairs.forEach(input -> multipleInputTransform.addInput(input.getKey()));
    if (generator.getMaxParallelism() > 0) {
        multipleInputTransform.setMaxParallelism(generator.getMaxParallelism());
    }
    // set resources
    multipleInputTransform.setResources(generator.getMinResources(), generator.getPreferredResources());
    final int memoryWeight = generator.getManagedMemoryWeight();
    final long memoryBytes = (long) memoryWeight << 20;
    ExecNodeUtil.setManagedMemoryWeight(multipleInputTransform, memoryBytes);
    // set chaining strategy for source chaining
    multipleInputTransform.setChainingStrategy(ChainingStrategy.HEAD_WITH_SOURCES);
    return multipleInputTransform;
}
Also used : MultipleInputTransformation(org.apache.flink.streaming.api.transformations.MultipleInputTransformation) ExecNodeContext(org.apache.flink.table.planner.plan.nodes.exec.ExecNodeContext) RowData(org.apache.flink.table.data.RowData) PlannerBase(org.apache.flink.table.planner.delegation.PlannerBase) InputProperty(org.apache.flink.table.planner.plan.nodes.exec.InputProperty) SingleTransformationTranslator(org.apache.flink.table.planner.plan.nodes.exec.SingleTransformationTranslator) ExecNodeConfig(org.apache.flink.table.planner.plan.nodes.exec.ExecNodeConfig) InputSpec(org.apache.flink.table.runtime.operators.multipleinput.input.InputSpec) Collectors(java.util.stream.Collectors) ExecNode(org.apache.flink.table.planner.plan.nodes.exec.ExecNode) BatchMultipleInputStreamOperatorFactory(org.apache.flink.table.runtime.operators.multipleinput.BatchMultipleInputStreamOperatorFactory) TableOperatorWrapperGenerator(org.apache.flink.table.runtime.operators.multipleinput.TableOperatorWrapperGenerator) ArrayList(java.util.ArrayList) ExecNodeUtil(org.apache.flink.table.planner.plan.nodes.exec.utils.ExecNodeUtil) List(java.util.List) InternalTypeInfo(org.apache.flink.table.runtime.typeutils.InternalTypeInfo) ChainingStrategy(org.apache.flink.streaming.api.operators.ChainingStrategy) ExecEdge(org.apache.flink.table.planner.plan.nodes.exec.ExecEdge) Pair(org.apache.commons.lang3.tuple.Pair) Preconditions.checkArgument(org.apache.flink.util.Preconditions.checkArgument) ExecNodeBase(org.apache.flink.table.planner.plan.nodes.exec.ExecNodeBase) Transformation(org.apache.flink.api.dag.Transformation) MultipleInputTransformation(org.apache.flink.streaming.api.transformations.MultipleInputTransformation) Transformation(org.apache.flink.api.dag.Transformation) ExecEdge(org.apache.flink.table.planner.plan.nodes.exec.ExecEdge) InputProperty(org.apache.flink.table.planner.plan.nodes.exec.InputProperty) ArrayList(java.util.ArrayList) BatchMultipleInputStreamOperatorFactory(org.apache.flink.table.runtime.operators.multipleinput.BatchMultipleInputStreamOperatorFactory) TableOperatorWrapperGenerator(org.apache.flink.table.runtime.operators.multipleinput.TableOperatorWrapperGenerator) RowData(org.apache.flink.table.data.RowData) MultipleInputTransformation(org.apache.flink.streaming.api.transformations.MultipleInputTransformation) Pair(org.apache.commons.lang3.tuple.Pair)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Pair (org.apache.commons.lang3.tuple.Pair)1 Transformation (org.apache.flink.api.dag.Transformation)1 ChainingStrategy (org.apache.flink.streaming.api.operators.ChainingStrategy)1 MultipleInputTransformation (org.apache.flink.streaming.api.transformations.MultipleInputTransformation)1 RowData (org.apache.flink.table.data.RowData)1 PlannerBase (org.apache.flink.table.planner.delegation.PlannerBase)1 ExecEdge (org.apache.flink.table.planner.plan.nodes.exec.ExecEdge)1 ExecNode (org.apache.flink.table.planner.plan.nodes.exec.ExecNode)1 ExecNodeBase (org.apache.flink.table.planner.plan.nodes.exec.ExecNodeBase)1 ExecNodeConfig (org.apache.flink.table.planner.plan.nodes.exec.ExecNodeConfig)1 ExecNodeContext (org.apache.flink.table.planner.plan.nodes.exec.ExecNodeContext)1 InputProperty (org.apache.flink.table.planner.plan.nodes.exec.InputProperty)1 SingleTransformationTranslator (org.apache.flink.table.planner.plan.nodes.exec.SingleTransformationTranslator)1 ExecNodeUtil (org.apache.flink.table.planner.plan.nodes.exec.utils.ExecNodeUtil)1 BatchMultipleInputStreamOperatorFactory (org.apache.flink.table.runtime.operators.multipleinput.BatchMultipleInputStreamOperatorFactory)1 TableOperatorWrapperGenerator (org.apache.flink.table.runtime.operators.multipleinput.TableOperatorWrapperGenerator)1 InputSpec (org.apache.flink.table.runtime.operators.multipleinput.input.InputSpec)1