com.google.cloud.dataflow.sdk.transforms

## Class Filter<T>

- java.lang.Object
- - com.google.cloud.dataflow.sdk.transforms.PTransform<PCollection<T>,PCollection<T>>
  - - com.google.cloud.dataflow.sdk.transforms.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>>

`PTransform`s 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

### Field Summary

### Fields inherited from class com.google.cloud.dataflow.sdk.transforms.PTransform

`name`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
`PCollection<T>` `apply(PCollection<T> input)` Applies this `PTransform` on the given `InputT`, and returns its `Output`.
`static <T,PredicateT extends SerializableFunction<T,Boolean>> ParDo.Bound<T,T>` `by(PredicateT filterPred)` Deprecated. use `byPredicate(PredicateT)`, which returns a `Filter` transform instead of a `ParDo.Bound`.
`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.
`protected Coder<T>` `getDefaultOutputCoder(PCollection<T> input)` Returns the default `Coder` to use for the output of this single-output `PTransform` when applied to the given input.
`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.
`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.
`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.
`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.
`Filter<T>` `named(String name)`

### Methods inherited from class com.google.cloud.dataflow.sdk.transforms.PTransform

`getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, populateDisplayData, toString, validate`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### 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.

#### by

    @Deprecated
    public static <T,PredicateT extends SerializableFunction<T,Boolean>> ParDo.Bound<T,T> by(PredicateT filterPred)

Deprecated. use `byPredicate(PredicateT)`, which returns a `Filter` transform instead of a `ParDo.Bound`.

#### 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.

#### named

    public Filter<T> named(String name)

#### apply

    public PCollection<T> apply(PCollection<T> input)

Description copied from class: `PTransform`
Applies this `PTransform` on the given `InputT`, and returns its `Output`.

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).

The default implementation throws an exception. A derived class must either implement apply, or else each runner must supply a custom implementation via `PipelineRunner.apply(com.google.cloud.dataflow.sdk.transforms.PTransform<InputT, OutputT>, InputT)`.

Overrides:
  `apply` in class `PTransform<PCollection<T>,PCollection<T>>`

#### getDefaultOutputCoder

    protected Coder<T> getDefaultOutputCoder(PCollection<T> input)

Description copied from class: `PTransform`
Returns the default `Coder` to use for the output of this single-output `PTransform` when applied to the given input.

Overrides:
  `getDefaultOutputCoder` in class `PTransform<PCollection<T>,PCollection<T>>`