Search in sources :

Example 1 with Match

use of org.apache.flink.runtime.operators.testutils.Match in project flink by apache.

the class ReusingSortMergeInnerJoinIteratorITCase method matchValues.

// --------------------------------------------------------------------------------------------
//                                    Utilities
// --------------------------------------------------------------------------------------------
private Map<Integer, Collection<Match>> matchValues(Map<Integer, Collection<String>> leftMap, Map<Integer, Collection<String>> rightMap) {
    Map<Integer, Collection<Match>> map = new HashMap<Integer, Collection<Match>>();
    for (Integer key : leftMap.keySet()) {
        Collection<String> leftValues = leftMap.get(key);
        Collection<String> rightValues = rightMap.get(key);
        if (rightValues == null) {
            continue;
        }
        if (!map.containsKey(key)) {
            map.put(key, new ArrayList<Match>());
        }
        Collection<Match> matchedValues = map.get(key);
        for (String leftValue : leftValues) {
            for (String rightValue : rightValues) {
                matchedValues.add(new Match(leftValue, rightValue));
            }
        }
    }
    return map;
}
Also used : HashMap(java.util.HashMap) Collection(java.util.Collection) Match(org.apache.flink.runtime.operators.testutils.Match)

Example 2 with Match

use of org.apache.flink.runtime.operators.testutils.Match in project flink by apache.

the class NonReusingSortMergeInnerJoinIteratorITCase method matchValues.

// --------------------------------------------------------------------------------------------
//                                    Utilities
// --------------------------------------------------------------------------------------------
private Map<Integer, Collection<Match>> matchValues(Map<Integer, Collection<String>> leftMap, Map<Integer, Collection<String>> rightMap) {
    Map<Integer, Collection<Match>> map = new HashMap<Integer, Collection<Match>>();
    for (Integer key : leftMap.keySet()) {
        Collection<String> leftValues = leftMap.get(key);
        Collection<String> rightValues = rightMap.get(key);
        if (rightValues == null) {
            continue;
        }
        if (!map.containsKey(key)) {
            map.put(key, new ArrayList<Match>());
        }
        Collection<Match> matchedValues = map.get(key);
        for (String leftValue : leftValues) {
            for (String rightValue : rightValues) {
                matchedValues.add(new Match(leftValue, rightValue));
            }
        }
    }
    return map;
}
Also used : HashMap(java.util.HashMap) Collection(java.util.Collection) Match(org.apache.flink.runtime.operators.testutils.Match)

Example 3 with Match

use of org.apache.flink.runtime.operators.testutils.Match in project flink by apache.

the class AbstractSortMergeOuterJoinIteratorITCase method joinValues.

// --------------------------------------------------------------------------------------------
//                                    Utilities
// --------------------------------------------------------------------------------------------
private Map<Integer, Collection<Match>> joinValues(Map<Integer, Collection<String>> leftMap, Map<Integer, Collection<String>> rightMap, OuterJoinType outerJoinType) {
    Map<Integer, Collection<Match>> map = new HashMap<>();
    for (Integer key : leftMap.keySet()) {
        Collection<String> leftValues = leftMap.get(key);
        Collection<String> rightValues = rightMap.get(key);
        if (outerJoinType == OuterJoinType.RIGHT && rightValues == null) {
            continue;
        }
        if (!map.containsKey(key)) {
            map.put(key, new ArrayList<Match>());
        }
        Collection<Match> joinedValues = map.get(key);
        for (String leftValue : leftValues) {
            if (rightValues != null) {
                for (String rightValue : rightValues) {
                    joinedValues.add(new Match(leftValue, rightValue));
                }
            } else {
                joinedValues.add(new Match(leftValue, null));
            }
        }
    }
    if (outerJoinType == OuterJoinType.RIGHT || outerJoinType == OuterJoinType.FULL) {
        for (Integer key : rightMap.keySet()) {
            Collection<String> leftValues = leftMap.get(key);
            Collection<String> rightValues = rightMap.get(key);
            if (leftValues != null) {
                continue;
            }
            if (!map.containsKey(key)) {
                map.put(key, new ArrayList<Match>());
            }
            Collection<Match> joinedValues = map.get(key);
            for (String rightValue : rightValues) {
                joinedValues.add(new Match(null, rightValue));
            }
        }
    }
    return map;
}
Also used : HashMap(java.util.HashMap) Collection(java.util.Collection) Match(org.apache.flink.runtime.operators.testutils.Match)

Aggregations

Collection (java.util.Collection)3 HashMap (java.util.HashMap)3 Match (org.apache.flink.runtime.operators.testutils.Match)3