Filter (Google Cloud Dataflow SDK 1.9.1 API)

Google Cloud Dataflow SDK for Java, version 1.9.1

com.google.cloud.dataflow.sdk.transforms

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:
    HasDisplayData, Serializable


    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:
    Serialized Form
    • Method Detail

      • byPredicate

        public static <T,PredicateT extends SerializableFunction<T,Boolean>> Filter<T> byPredicate(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 SerializableFunction<T, Boolean>.

        Example of use:

         
         PCollection<String> wordList = ...;
         PCollection<String> longWords =
             wordList.apply(Filter.byPredicate(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.

      • lessThan

        public static <T extends Comparable<T>> ParDo.Bound<T,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), and greaterThan(T), which return elements satisfying various inequalities with the specified value based on the elements' natural ordering.

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

      • greaterThan

        public static <T extends Comparable<T>> ParDo.Bound<T,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), and lessThanEq(T), which return elements satisfying various inequalities with the specified value based on the elements' natural ordering.

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

      • lessThanEq

        public static <T extends Comparable<T>> ParDo.Bound<T,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), and greaterThan(T), which return elements satisfying various inequalities with the specified value based on the elements' natural ordering.

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

      • greaterThanEq

        public static <T extends Comparable<T>> ParDo.Bound<T,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), and lessThanEq(T), which return elements satisfying various inequalities with the specified value based on the elements' natural ordering.

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


Was this page helpful? Let us know how we did:

Send feedback about...

Cloud Dataflow