Class PTransform<InputT extends PInput,​OutputT extends POutput>

    • Field Detail

      • name

        protected final transient @Nullable java.lang.String name
        The base name of this PTransform, e.g., from defaults, or null if not yet assigned.
      • resourceHints

        protected transient @NonNull ResourceHints resourceHints
    • Constructor Detail

      • PTransform

        protected PTransform()
      • PTransform

        protected PTransform​(@Nullable java.lang.String name)
    • Method Detail

      • expand

        public abstract OutputT expand​(InputT input)
        Override this method to specify how this PTransform should be expanded on the given InputT.

        NOTE: This method should not be called directly. Instead apply the PTransform should be applied to the InputT using the apply method.

        Composite transforms, which are defined in terms of other transforms, should return the output of one of the composed transforms. Non-composite transforms, which do not apply any transforms internally, should return a new unbound output and register evaluators (via backend-specific registration methods).

      • validate

        public void validate​(@Nullable PipelineOptions options)
        Called before running the Pipeline to verify this transform is fully and correctly specified.

        By default, does nothing.

      • getName

        public java.lang.String getName()
        Returns the transform name.

        This name is provided by the transform creator and is not required to be unique.

      • setResourceHints

        public PTransform<InputT,​OutputT> setResourceHints​(@NonNull ResourceHints resourceHints)
        Sets resource hints for the transform.
        Parameters:
        resourceHints - a ResourceHints instance.
        Returns:
        a reference to the same transfrom instance.

        For example:

        
         Pipeline p = ...
         ...
         p.apply(new SomeTransform().setResourceHints(ResourceHints.create().withMinRam("6 GiB")))
         ...
        
         
      • getResourceHints

        public ResourceHints getResourceHints()
        Returns resource hints set on the transform.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getKindString

        protected java.lang.String getKindString()
        Returns the name to use by default for this PTransform (not including the names of any enclosing PTransforms).

        By default, returns the base name of this PTransform's class.

        The caller is responsible for ensuring that names of applied PTransforms are unique, e.g., by adding a uniquifying suffix when needed.

      • populateDisplayData

        public void populateDisplayData​(DisplayData.Builder builder)
        Register display data for the given transform or component.

        populateDisplayData(DisplayData.Builder) is invoked by Pipeline runners to collect display data via DisplayData.from(HasDisplayData). Implementations may call super.populateDisplayData(builder) in order to register display data in the current namespace, but should otherwise use subcomponent.populateDisplayData(builder) to use the namespace of the subcomponent.

        By default, does not register any display data. Implementors may override this method to provide their own display data.

        Specified by:
        populateDisplayData in interface HasDisplayData
        Parameters:
        builder - The builder to populate with display data.
        See Also:
        HasDisplayData
      • compose

        @Experimental
        public static <InputT extends PInput,​OutputT extends POutputPTransform<InputT,​OutputT> compose​(SerializableFunction<InputT,​OutputT> fn)
        For a SerializableFunction<InputT, OutputT> fn, returns a PTransform given by applying fn.apply(v) to the input PCollection<InputT>.

        Allows users to define a concise composite transform using a Java 8 lambda expression. For example:

        
         PCollection<String> words = wordsAndErrors.apply(
           (PCollectionTuple input) -> {
             input.get(errorsTag).apply(new WriteErrorOutput());
             return input.get(wordsTag);
           });