Class SelectByMaxFunction<T extends org.apache.flink.api.java.tuple.Tuple>

  • Type Parameters:
    T -
    All Implemented Interfaces:
    Serializable, org.apache.flink.api.common.functions.Function, org.apache.flink.api.common.functions.ReduceFunction<T>

    @Internal
    public class SelectByMaxFunction<T extends org.apache.flink.api.java.tuple.Tuple>
    extends Object
    implements org.apache.flink.api.common.functions.ReduceFunction<T>
    Function that enables selection by maximal value of a field.
    See Also:
    Serialized Form
    • Constructor Detail

      • SelectByMaxFunction

        public SelectByMaxFunction​(org.apache.flink.api.java.typeutils.TupleTypeInfo<T> type,
                                   int... fields)
        Constructor which is overwriting the default constructor.
        Parameters:
        type - Types of tuple whether to check if given fields are key types.
        fields - Array of integers which are used as key for comparison. The order of indexes is regarded in the reduce function. First index has highest priority and last index has least priority.
    • Method Detail

      • reduce

        public T reduce​(T value1,
                        T value2)
                 throws Exception
        Reduce implementation, returns bigger tuple or value1 if both tuples are equal. Comparison highly depends on the order and amount of fields chosen as indices. All given fields (at construction time) are checked in the same order as defined (at construction time). If both tuples are equal in one index, the next index is compared. Or if no next index is available value1 is returned. The tuple which has a bigger value at one index will be returned.
        Specified by:
        reduce in interface org.apache.flink.api.common.functions.ReduceFunction<T extends org.apache.flink.api.java.tuple.Tuple>
        Throws:
        Exception