Class Filter<T>
- java.lang.Object
-
- org.apache.beam.sdk.transforms.PTransform<PCollection<T>,PCollection<T>>
-
- org.apache.beam.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:
java.io.Serializable
,HasDisplayData
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 org.apache.beam.sdk.transforms.PTransform
name, resourceHints
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T,PredicateT extends ProcessFunction<T,java.lang.Boolean>>
Filter<T>by(PredicateT predicate)
Returns aPTransform
that takes an inputPCollection<T>
and returns aPCollection<T>
with elements that satisfy the given predicate.static <T extends java.lang.Comparable<T>>
Filter<T>equal(T value)
Returns aPTransform
that takes an inputPCollection<T>
and returns aPCollection<T>
with elements that equals to a given value.PCollection<T>
expand(PCollection<T> input)
Override this method to specify how thisPTransform
should be expanded on the givenInputT
.static <T extends java.lang.Comparable<T>>
Filter<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 java.lang.Comparable<T>>
Filter<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 java.lang.Comparable<T>>
Filter<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 java.lang.Comparable<T>>
Filter<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.void
populateDisplayData(DisplayData.Builder builder)
Register display data for the given transform or component.-
Methods inherited from class org.apache.beam.sdk.transforms.PTransform
compose, compose, getAdditionalInputs, getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, getResourceHints, setResourceHints, toString, validate, validate
-
-
-
-
Method Detail
-
by
public static <T,PredicateT extends ProcessFunction<T,java.lang.Boolean>> Filter<T> by(PredicateT predicate)
Returns aPTransform
that takes an inputPCollection<T>
and returns aPCollection<T>
with elements that satisfy the given predicate. The predicate must be aProcessFunction<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,java.lang.Boolean>> Filter<T> by(PredicateT predicate)
Binary compatibility adapter forby(ProcessFunction)
.
-
lessThan
public static <T extends java.lang.Comparable<T>> Filter<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)
,equal(T)
andgreaterThan(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 java.lang.Comparable<T>> Filter<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)
,equal(T)
andlessThanEq(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 java.lang.Comparable<T>> Filter<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)
,equal(T)
andgreaterThan(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 java.lang.Comparable<T>> Filter<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)
,equal(T)
andlessThanEq(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 java.lang.Comparable<T>> Filter<T> equal(T value)
Returns aPTransform
that takes an inputPCollection<T>
and returns aPCollection<T>
with elements that equals to a given value. Elements must beComparable
.Example of use:
PCollection<Integer> listOfNumbers = ...; PCollection<Integer> equalNumbers = listOfNumbers.apply(Filter.equal(1000));
See also
greaterThan(T)
,lessThan(T)
,lessThanEq(T)
andgreaterThanEq(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 thisPTransform
should be expanded on the givenInputT
.NOTE: This method should not be called directly. Instead apply the
PTransform
should be applied to theInputT
using theapply
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 classPTransform<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 viaDisplayData.from(HasDisplayData)
. Implementations may callsuper.populateDisplayData(builder)
in order to register display data in the current namespace, but should otherwise usesubcomponent.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 interfaceHasDisplayData
- Overrides:
populateDisplayData
in classPTransform<PCollection<T>,PCollection<T>>
- Parameters:
builder
- The builder to populate with display data.- See Also:
HasDisplayData
-
-