Class Filter<T>

Type Parameters:
T - the type of the values in the input PCollection, and the type of the elements in the output PCollection
All Implemented Interfaces:
Serializable, HasDisplayData

public class Filter<T> extends PTransform<PCollection<T>,PCollection<T>>
PTransforms for filtering from a PCollection the elements satisfying a predicate, or satisfying an inequality with a given value based on the elements' natural ordering.
See Also:
  • Method Details

    • by

      public static <T, PredicateT extends ProcessFunction<T, Boolean>> Filter<T> by(PredicateT predicate)
      Returns a PTransform that takes an input PCollection<T> and returns a PCollection<T> with elements that satisfy the given predicate. The predicate must be a ProcessFunction<T, Boolean>.

      Example of use:

      
       PCollection<String> wordList = ...;
       PCollection<String> longWords =
           wordList.apply(Filter.by(new MatchIfWordLengthGT(6)));
       

      See also lessThan(T), lessThanEq(T), greaterThan(T), greaterThanEq(T), which return elements satisfying various inequalities with the specified value based on the elements' natural ordering.

    • by

      public static <T, PredicateT extends SerializableFunction<T, Boolean>> Filter<T> by(PredicateT predicate)
      Binary compatibility adapter for by(ProcessFunction).
    • lessThan

      public static <T extends Comparable<T>> Filter<T> lessThan(T value)
      Returns a PTransform that takes an input PCollection and returns a PCollection with elements that are less than a given value, based on the elements' natural ordering. Elements must be Comparable.

      Example of use:

      
       PCollection<Integer> listOfNumbers = ...;
       PCollection<Integer> smallNumbers =
           listOfNumbers.apply(Filter.lessThan(10));
       

      See also lessThanEq(T), greaterThanEq(T), equal(T) and greaterThan(T), which return elements satisfying various inequalities with the specified value based on the elements' natural ordering.

      See also by(PredicateT), which returns elements that satisfy the given predicate.

    • greaterThan

      public static <T extends Comparable<T>> Filter<T> greaterThan(T value)
      Returns a PTransform that takes an input PCollection<T> and returns a PCollection<T> with elements that are greater than a given value, based on the elements' natural ordering. Elements must be Comparable.

      Example of use:

      
       PCollection<Integer> listOfNumbers = ...;
       PCollection<Integer> largeNumbers =
           listOfNumbers.apply(Filter.greaterThan(1000));
       

      See also greaterThanEq(T), lessThan(T), equal(T) and lessThanEq(T), which return elements satisfying various inequalities with the specified value based on the elements' natural ordering.

      See also by(PredicateT), which returns elements that satisfy the given predicate.

    • lessThanEq

      public static <T extends Comparable<T>> Filter<T> lessThanEq(T value)
      Returns a PTransform that takes an input PCollection<T> and returns a PCollection<T> with elements that are less than or equal to a given value, based on the elements' natural ordering. Elements must be Comparable.

      Example of use:

      
       PCollection<Integer> listOfNumbers = ...;
       PCollection<Integer> smallOrEqualNumbers =
           listOfNumbers.apply(Filter.lessThanEq(10));
       

      See also lessThan(T), greaterThanEq(T), equal(T) and greaterThan(T), which return elements satisfying various inequalities with the specified value based on the elements' natural ordering.

      See also by(PredicateT), which returns elements that satisfy the given predicate.

    • greaterThanEq

      public static <T extends Comparable<T>> Filter<T> greaterThanEq(T value)
      Returns a PTransform that takes an input PCollection<T> and returns a PCollection<T> with elements that are greater than or equal to a given value, based on the elements' natural ordering. Elements must be Comparable.

      Example of use:

      
       PCollection<Integer> listOfNumbers = ...;
       PCollection<Integer> largeOrEqualNumbers =
           listOfNumbers.apply(Filter.greaterThanEq(1000));
       

      See also greaterThan(T), lessThan(T), equal(T) and lessThanEq(T), which return elements satisfying various inequalities with the specified value based on the elements' natural ordering.

      See also by(PredicateT), which returns elements that satisfy the given predicate.

    • equal

      public static <T extends Comparable<T>> Filter<T> equal(T value)
      Returns a PTransform that takes an input PCollection<T> and returns a PCollection<T> with elements that equals to a given value. Elements must be Comparable.

      Example of use:

      
       PCollection<Integer> listOfNumbers = ...;
       PCollection<Integer> equalNumbers = listOfNumbers.apply(Filter.equal(1000));
       

      See also greaterThan(T), lessThan(T), lessThanEq(T) and greaterThanEq(T), which return elements satisfying various inequalities with the specified value based on the elements' natural ordering.

      See also by(PredicateT), which returns elements that satisfy the given predicate.

    • 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>>
    • populateDisplayData

      public void populateDisplayData(DisplayData.Builder builder)
      Description copied from class: PTransform
      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
      Overrides:
      populateDisplayData in class PTransform<PCollection<T>,PCollection<T>>
      Parameters:
      builder - The builder to populate with display data.
      See Also: