Class Tee<T>

Type Parameters:
T - the element type of the input PCollection
All Implemented Interfaces:
Serializable, HasDisplayData

public class Tee<T> extends PTransform<PCollection<T>,PCollection<T>>
A PTransform that returns its input, but also applies its input to an auxiliary PTransform, akin to the shell tee command, which is named after the T-splitter used in plumbing.

This can be useful to write out or otherwise process an intermediate transform without breaking the linear flow of a chain of transforms, e.g.


 PCollection<T> input = ... ;
 PCollection<T> result =
     input.apply(...)
     ...
     input.apply(Tee.of(someSideTransform)
     ...
     input.apply(...);
 
See Also:
  • Method Details

    • of

      public static <T> Tee<T> of(PTransform<PCollection<T>,?> consumer)
      Returns a new Tee PTransform that will apply an auxilary transform to the input as well as pass it on.
      Type Parameters:
      T - the type of the elements in the input PCollection.
      Parameters:
      consumer - An additional PTransform that should process the input PCollection. Its output will be ignored.
    • of

      public static <T> Tee<T> of(Consumer<PCollection<T>> consumer)
      Returns a new Tee PTransform that will apply an auxilary transform to the input as well as pass it on.
      Type Parameters:
      T - the type of the elements in the input PCollection.
      Parameters:
      consumer - An arbitrary Consumer that will be wrapped in a PTransform and applied to the input. Its output will be ignored.
    • expand

      public PCollection<T> expand(PCollection<T> input)
      Description copied from class: PTransform
      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).

      Specified by:
      expand in class PTransform<PCollection<T>,PCollection<T>>
    • getKindString

      protected String getKindString()
      Description copied from class: PTransform
      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.

      Overrides:
      getKindString in class PTransform<PCollection<T>,PCollection<T>>