Search in sources :

Example 1 with CompareCol

use of org.talend.spark.utils.CompareCol in project tdi-studio-se by Talend.

the class KeyByCompareColFunction method call.

public Tuple2<List<Object>, List<Object>> call(List<Object> d) {
    List<Object> key = new ArrayList<Object>(compCols.size());
    for (int i = 0; i < compCols.size(); i++) {
        key.add(i, d.get(compCols.get(i).getColId()));
    }
    List<Object> values = new ArrayList<Object>(d.size());
    int valId = 0;
    for (Integer i = 0; i < d.size(); i++) {
        boolean contain = false;
        for (CompareCol compCol : compCols) {
            if (compCol.getColId().equals(i)) {
                contain = true;
                break;
            }
        }
        if (!contain) {
            values.add(valId, d.get(i));
            valId++;
        }
    }
    return new Tuple2<List<Object>, List<Object>>(key, values);
}
Also used : CompareCol(org.talend.spark.utils.CompareCol) Tuple2(scala.Tuple2) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)1 CompareCol (org.talend.spark.utils.CompareCol)1 Tuple2 (scala.Tuple2)1