@Override public void leaveCompositeTransform(Node node) { if (node.isRootNode()) { for (AppliedPTransform<?, ?, ?> pipelineRoot : children.get(node)) { rootIds.add(components.getExistingPTransformId(pipelineRoot)); } } else { // TODO: Include DisplayData in the proto children.put(node.getEnclosingNode(), node.toAppliedPTransform(pipeline)); try { components.registerPTransform( node.toAppliedPTransform(pipeline), children.get(node)); } catch (IOException e) { throw new RuntimeException(e); } } }
transformBuilder.addSubtransforms(components.getExistingPTransformId(subtransform));
@Test public void registerTransformNoChildren() throws IOException { Create.Values<Integer> create = Create.of(1, 2, 3); PCollection<Integer> pt = pipeline.apply(create); String userName = "my_transform/my_nesting"; AppliedPTransform<?, ?, ?> transform = AppliedPTransform.of(userName, pipeline.begin().expand(), pt.expand(), create, pipeline); String componentName = components.registerPTransform(transform, Collections.emptyList()); assertThat(componentName, equalTo(userName)); assertThat(components.getExistingPTransformId(transform), equalTo(componentName)); }
private RunnerApi.PTransform convert(ToAndFromProtoSpec spec, SdkComponents components) throws IOException { List<AppliedPTransform<?, ?, ?>> childTransforms = new ArrayList<>(); for (ToAndFromProtoSpec child : spec.getChildren()) { childTransforms.add(child.getTransform()); System.out.println("Converting child " + child); convert(child, components); // Sanity call components.getExistingPTransformId(child.getTransform()); } RunnerApi.PTransform convert = PTransformTranslation.toProto(spec.getTransform(), childTransforms, components); // Make sure the converted transform is registered. Convert it independently, but if this is a // child spec, the child must be in the components. components.registerPTransform(spec.getTransform(), childTransforms); return convert; }
@Test public void registerTransformEmptyFullName() throws IOException { Create.Values<Integer> create = Create.of(1, 2, 3); PCollection<Integer> pt = pipeline.apply(create); AppliedPTransform<?, ?, ?> transform = AppliedPTransform.of("", pipeline.begin().expand(), pt.expand(), create, pipeline); thrown.expect(IllegalArgumentException.class); thrown.expectMessage(transform.toString()); components.getExistingPTransformId(transform); }