Java Code Examples for org.apache.beam.sdk.values.TupleTagList#getAll()
The following examples show how to use
org.apache.beam.sdk.values.TupleTagList#getAll() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Partition.java From beam with Apache License 2.0 | 6 votes |
@Override public PCollectionList<T> expand(PCollection<T> in) { final TupleTagList outputTags = partitionDoFn.getOutputTags(); PCollectionTuple outputs = in.apply( ParDo.of(partitionDoFn) .withOutputTags(new TupleTag<Void>() {}, outputTags) .withSideInputs(partitionDoFn.getSideInputs())); PCollectionList<T> pcs = PCollectionList.empty(in.getPipeline()); Coder<T> coder = in.getCoder(); for (TupleTag<?> outputTag : outputTags.getAll()) { // All the tuple tags are actually TupleTag<T> // And all the collections are actually PCollection<T> @SuppressWarnings("unchecked") TupleTag<T> typedOutputTag = (TupleTag<T>) outputTag; pcs = pcs.and(outputs.get(typedOutputTag).setCoder(coder)); } return pcs; }
Example 2
Source File: CoGbkResultSchema.java From beam with Apache License 2.0 | 5 votes |
/** Builds a schema from a tuple of {@code TupleTag<?>}s. */ public CoGbkResultSchema(TupleTagList tupleTagList) { this.tupleTagList = tupleTagList; int index = -1; for (TupleTag<?> tag : tupleTagList.getAll()) { index++; tagMap.put(tag, index); } }
Example 3
Source File: PipelineTranslator.java From incubator-nemo with Apache License 2.0 | 4 votes |
/** * @param ctx provides translation context. * @param beamNode the beam node to be translated. * @param sideInputMap side inputs. * @return the created DoFnTransform. */ private static AbstractDoFnTransform createDoFnTransform(final PipelineTranslationContext ctx, final TransformHierarchy.Node beamNode, final Map<Integer, PCollectionView<?>> sideInputMap) { try { final AppliedPTransform pTransform = beamNode.toAppliedPTransform(ctx.getPipeline()); final DoFn doFn = ParDoTranslation.getDoFn(pTransform); final TupleTag mainOutputTag = ParDoTranslation.getMainOutputTag(pTransform); final TupleTagList additionalOutputTags = ParDoTranslation.getAdditionalOutputTags(pTransform); final PCollection<?> mainInput = (PCollection<?>) Iterables.getOnlyElement(TransformInputs.nonAdditionalInputs(pTransform)); final HasDisplayData displayData = (builder) -> builder.add(DisplayData.item("name", beamNode.getFullName())); final DoFnSchemaInformation doFnSchemaInformation = ParDoTranslation.getSchemaInformation(beamNode.toAppliedPTransform(ctx.getPipeline())); if (sideInputMap.isEmpty()) { return new DoFnTransform( doFn, mainInput.getCoder(), getOutputCoders(pTransform), mainOutputTag, additionalOutputTags.getAll(), mainInput.getWindowingStrategy(), ctx.getPipelineOptions(), DisplayData.from(displayData), doFnSchemaInformation, Collections.emptyMap()); } else { return new PushBackDoFnTransform( doFn, mainInput.getCoder(), getOutputCoders(pTransform), mainOutputTag, additionalOutputTags.getAll(), mainInput.getWindowingStrategy(), sideInputMap, ctx.getPipelineOptions(), DisplayData.from(displayData), doFnSchemaInformation, Collections.emptyMap()); } } catch (final IOException e) { throw new RuntimeException(e); } }