Interface FilterFunction<T>

  • Type Parameters:
    T - The type of the filtered elements.
    All Superinterfaces:
    org.apache.flink.api.common.functions.Function, Serializable
    All Known Implementing Classes:
    RichFilterFunction
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @Public
    @FunctionalInterface
    public interface FilterFunction<T>
    extends org.apache.flink.api.common.functions.Function, Serializable
    A filter function is a predicate applied individually to each record. The predicate decides whether to keep the element, or to discard it.

    The basic syntax for using a FilterFunction is as follows:

    
     DataSet<X> input = ...;
    
     DataSet<X> result = input.filter(new MyFilterFunction());
     

    IMPORTANT: The system assumes that the function does not modify the elements on which the predicate is applied. Violating this assumption can lead to incorrect results.

    • Method Detail

      • filter

        boolean filter​(T value)
                throws Exception
        The filter function that evaluates the predicate.

        IMPORTANT: The system assumes that the function does not modify the elements on which the predicate is applied. Violating this assumption can lead to incorrect results.

        Parameters:
        value - The value to be filtered.
        Returns:
        True for values that should be retained, false for values to be filtered out.
        Throws:
        Exception - This method may throw exceptions. Throwing an exception will cause the operation to fail and may trigger recovery.