Search in sources :

Example 11 with SideInput

use of org.apache.beam.model.pipeline.v1.RunnerApi.SideInput in project beam by apache.

the class StreamingSideInputHandlerFactory method forStage.

/**
 * Creates a new state handler for the given stage. Note that this requires a traversal of the
 * stage itself, so this should only be called once per stage rather than once per bundle.
 */
public static StreamingSideInputHandlerFactory forStage(ExecutableStage stage, Map<SideInputId, PCollectionView<?>> viewMapping, org.apache.beam.runners.core.SideInputHandler runnerHandler) {
    ImmutableMap.Builder<SideInputId, PCollectionView<?>> sideInputBuilder = ImmutableMap.builder();
    for (SideInputReference sideInput : stage.getSideInputs()) {
        SideInputId sideInputId = SideInputId.newBuilder().setTransformId(sideInput.transform().getId()).setLocalName(sideInput.localName()).build();
        sideInputBuilder.put(sideInputId, checkNotNull(viewMapping.get(sideInputId), "No side input for %s/%s", sideInputId.getTransformId(), sideInputId.getLocalName()));
    }
    StreamingSideInputHandlerFactory factory = new StreamingSideInputHandlerFactory(sideInputBuilder.build(), runnerHandler);
    return factory;
}
Also used : PCollectionView(org.apache.beam.sdk.values.PCollectionView) SideInputReference(org.apache.beam.runners.core.construction.graph.SideInputReference) SideInputId(org.apache.beam.model.pipeline.v1.RunnerApi.ExecutableStagePayload.SideInputId) ImmutableMap(org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableMap)

Aggregations

RunnerApi (org.apache.beam.model.pipeline.v1.RunnerApi)7 PCollectionView (org.apache.beam.sdk.values.PCollectionView)7 Map (java.util.Map)5 HashMap (java.util.HashMap)4 PTransform (org.apache.beam.model.pipeline.v1.RunnerApi.PTransform)4 PTransformNode (org.apache.beam.runners.core.construction.graph.PipelineNode.PTransformNode)4 ByteString (org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.ByteString)4 ImmutableMap (org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableMap)4 IOException (java.io.IOException)3 Components (org.apache.beam.model.pipeline.v1.RunnerApi.Components)3 ExecutableStagePayload (org.apache.beam.model.pipeline.v1.RunnerApi.ExecutableStagePayload)3 SideInput (org.apache.beam.model.pipeline.v1.RunnerApi.SideInput)3 Structs.getString (org.apache.beam.runners.dataflow.util.Structs.getString)3 Test (org.junit.Test)3 ParDoInstruction (com.google.api.services.dataflow.model.ParDoInstruction)2 ArrayList (java.util.ArrayList)2 Environment (org.apache.beam.model.pipeline.v1.RunnerApi.Environment)2 PCollection (org.apache.beam.model.pipeline.v1.RunnerApi.PCollection)2 ParDoPayload (org.apache.beam.model.pipeline.v1.RunnerApi.ParDoPayload)2 PCollectionNode (org.apache.beam.runners.core.construction.graph.PipelineNode.PCollectionNode)2