@Override public Map<TupleTag<?>, PValue> getAdditionalInputs() { return delegate().getAdditionalInputs(); }
/** * Gets the singleton input of an {@link AppliedPTransform}, ignoring any additional inputs * returned by {@link PTransform#getAdditionalInputs()}. */ public static <T> PCollection<T> getSingletonMainInput( AppliedPTransform<? extends PCollection<? extends T>, ?, ?> application) { return getSingletonMainInput( application.getInputs(), application.getTransform().getAdditionalInputs().keySet()); }
/** * Gets all inputs of the {@link AppliedPTransform} that are not returned by {@link * PTransform#getAdditionalInputs()}. */ public static Collection<PValue> nonAdditionalInputs(AppliedPTransform<?, ?, ?> application) { ImmutableList.Builder<PValue> mainInputs = ImmutableList.builder(); PTransform<?, ?> transform = application.getTransform(); for (Map.Entry<TupleTag<?>, PValue> input : application.getInputs().entrySet()) { if (!transform.getAdditionalInputs().containsKey(input.getKey())) { mainInputs.add(input.getValue()); } } checkArgument( !mainInputs.build().isEmpty() || application.getInputs().isEmpty(), "Expected at least one main input if any inputs exist"); return mainInputs.build(); } }
/** * Creates a new Node with the given parent and transform. * * @param enclosingNode the composite node containing this node * @param transform the PTransform tracked by this node * @param fullName the fully qualified name of the transform * @param input the unexpanded input to the transform */ private Node(Node enclosingNode, PTransform<?, ?> transform, String fullName, PInput input) { this.enclosingNode = enclosingNode; this.transform = transform; this.fullName = fullName; ImmutableMap.Builder<TupleTag<?>, PValue> inputs = ImmutableMap.builder(); inputs.putAll(input.expand()); inputs.putAll(transform.getAdditionalInputs()); this.inputs = inputs.build(); }
@Test public void getAdditionalInputsDelegates() { Map<TupleTag<?>, PValue> additionalInputs = ImmutableMap.of(new TupleTag<>("test_tag"), Pipeline.create().apply(Create.of("1"))); when(delegate.getAdditionalInputs()).thenReturn(additionalInputs); assertThat(forwarding.getAdditionalInputs(), equalTo(additionalInputs)); }