Class FunctionalUtils


  • public class FunctionalUtils
    extends Object
    • Constructor Detail

      • FunctionalUtils

        public FunctionalUtils()
    • Method Detail

      • cogroup

        public static <K,​V> Map<K,​Pair<List<V>,​List<V>>> cogroup​(List<Pair<K,​V>> left,
                                                                                   List<Pair<K,​V>> right)
        For each key in left and right, cogroup returns the list of values as a pair for each value present in left as well as right.
        Type Parameters:
        K - the key type
        V - the value type
        Parameters:
        left - the left list of pairs to join
        right - the right list of pairs to join
        Returns:
        a map of the list of values by key for each value in the left as well as the right with each element in the pair representing the values in left and right respectively.
      • groupByKey

        public static <K,​V> Map<K,​List<V>> groupByKey​(List<Pair<K,​V>> listInput)
        Group the input pairs by the key of each pair.
        Type Parameters:
        K - the key type
        V - the value type
        Parameters:
        listInput - the list of pairs to group
        Returns:
        a map representing a grouping of the keys by the given input key type and list of values in the grouping.
      • mapToPair

        public static <K,​V> List<Pair<K,​V>> mapToPair​(Map<K,​V> map)
        Convert a map with a set of entries of type K for key and V for value in to a list of Pair
        Type Parameters:
        K - the key type
        V - the value type
        Parameters:
        map - the map to collapse
        Returns:
        the collapsed map as a List