Google Cloud Dataflow SDK for Java, version 1.9.1
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 inputPCollection
, and the type of the elements in the outputPCollection
- All Implemented Interfaces:
- HasDisplayData, Serializable
public class Filter<T> extends PTransform<PCollection<T>,PCollection<T>>
PTransform
s for filtering from aPCollection
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 Modifier and Type Method and Description PCollection<T>
apply(PCollection<T> input)
Applies thisPTransform
on the givenInputT
, and returns itsOutput
.static <T,PredicateT extends SerializableFunction<T,Boolean>>
ParDo.Bound<T,T>by(PredicateT filterPred)
Deprecated.usebyPredicate(PredicateT)
, which returns aFilter
transform instead of aParDo.Bound
.static <T,PredicateT extends SerializableFunction<T,Boolean>>
Filter<T>byPredicate(PredicateT predicate)
Returns aPTransform
that takes an inputPCollection<T>
and returns aPCollection<T>
with elements that satisfy the given predicate.protected Coder<T>
getDefaultOutputCoder(PCollection<T> input)
Returns the defaultCoder
to use for the output of this single-outputPTransform
when applied to the given input.static <T extends Comparable<T>>
ParDo.Bound<T,T>greaterThan(T value)
Returns aPTransform
that takes an inputPCollection<T>
and returns aPCollection<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 aPTransform
that takes an inputPCollection<T>
and returns aPCollection<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 aPTransform
that takes an inputPCollection
and returns aPCollection
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 aPTransform
that takes an inputPCollection<T>
and returns aPCollection<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
-
-
-
-
Method Detail
-
byPredicate
public static <T,PredicateT extends SerializableFunction<T,Boolean>> Filter<T> byPredicate(PredicateT predicate)
Returns aPTransform
that takes an inputPCollection<T>
and returns aPCollection<T>
with elements that satisfy the given predicate. The predicate must be aSerializableFunction<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. usebyPredicate(PredicateT)
, which returns aFilter
transform instead of aParDo.Bound
.
-
lessThan
public static <T extends Comparable<T>> ParDo.Bound<T,T> lessThan(T value)
Returns aPTransform
that takes an inputPCollection
and returns aPCollection
with elements that are less than a given value, based on the elements' natural ordering. Elements must beComparable
.Example of use:
PCollection<Integer> listOfNumbers = ...; PCollection<Integer> smallNumbers = listOfNumbers.apply(Filter.lessThan(10));
See also
lessThanEq(T)
,greaterThanEq(T)
, andgreaterThan(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 aPTransform
that takes an inputPCollection<T>
and returns aPCollection<T>
with elements that are greater than a given value, based on the elements' natural ordering. Elements must beComparable
.Example of use:
PCollection<Integer> listOfNumbers = ...; PCollection<Integer> largeNumbers = listOfNumbers.apply(Filter.greaterThan(1000));
See also
greaterThanEq(T)
,lessThan(T)
, andlessThanEq(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 aPTransform
that takes an inputPCollection<T>
and returns aPCollection<T>
with elements that are less than or equal to a given value, based on the elements' natural ordering. Elements must beComparable
.Example of use:
PCollection<Integer> listOfNumbers = ...; PCollection<Integer> smallOrEqualNumbers = listOfNumbers.apply(Filter.lessThanEq(10));
See also
lessThan(T)
,greaterThanEq(T)
, andgreaterThan(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 aPTransform
that takes an inputPCollection<T>
and returns aPCollection<T>
with elements that are greater than or equal to a given value, based on the elements' natural ordering. Elements must beComparable
.Example of use:
PCollection<Integer> listOfNumbers = ...; PCollection<Integer> largeOrEqualNumbers = listOfNumbers.apply(Filter.greaterThanEq(1000));
See also
greaterThan(T)
,lessThan(T)
, andlessThanEq(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.
-
apply
public PCollection<T> apply(PCollection<T> input)
Description copied from class:PTransform
Applies thisPTransform
on the givenInputT
, and returns itsOutput
.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 classPTransform<PCollection<T>,PCollection<T>>
-
getDefaultOutputCoder
protected Coder<T> getDefaultOutputCoder(PCollection<T> input)
Description copied from class:PTransform
Returns the defaultCoder
to use for the output of this single-outputPTransform
when applied to the given input.By default, always throws.
- Overrides:
getDefaultOutputCoder
in classPTransform<PCollection<T>,PCollection<T>>
-
-