Search in sources :

Example 6 with MultipleKey

use of org.talend.utils.collections.MultipleKey in project tdq-studio-se by Talend.

the class DatasetUtils method fillDataset.

/**
 * Method "fillDataset" fills in the data sets.
 *
 * @param nominalColumns the nominal columns
 * @param listRows the rows (=result set)
 * @param firstNumericColumnIdx the index of the first numeric column
 * @return a map [key -> aggregated values] where identifies a level of aggregation
 */
private static Map<String, ValueAggregator> fillDataset(final List<ModelElement> nominalColumns, final List<Object[]> listRows, final int firstNumericColumnIdx) {
    Map<String, ValueAggregator> valueAggregators = new HashMap<String, ValueAggregator>();
    int xPos = firstNumericColumnIdx;
    int yPos = firstNumericColumnIdx + 1;
    int zPos = firstNumericColumnIdx + 2;
    for (int i = nominalColumns.size(); i > 0; i--) {
        String key = createKey(nominalColumns, i);
        // ADD msjian 2011-5-30 17479: Excel Odbc connection can not run well on the correlation analysis
        if (null != listRows) {
            for (Object[] row : listRows) {
                final Object xobj = row[xPos];
                final Double xValue = xobj != null ? Double.valueOf(String.valueOf(xobj)) : null;
                final Object yobj = row[yPos];
                final Double yValue = yobj != null ? Double.valueOf(String.valueOf(yobj)) : null;
                final Object zobj = row[zPos];
                final Double zValue = zobj != null ? Double.valueOf(String.valueOf(zobj)) : null;
                ValueAggregator valueAggregator = valueAggregators.get(key);
                if (valueAggregator == null) {
                    valueAggregator = new ValueAggregator();
                    valueAggregators.put(key, valueAggregator);
                }
                MultipleKey multipleKey = new MultipleKey(row, i);
                valueAggregator.addValue(multipleKey, new Double[] { xValue, yValue, zValue });
            }
        }
    }
    return valueAggregators;
}
Also used : MultipleKey(org.talend.utils.collections.MultipleKey) HashMap(java.util.HashMap) ValueAggregator(org.talend.dataprofiler.service.utils.ValueAggregator)

Aggregations

MultipleKey (org.talend.utils.collections.MultipleKey)6 HashMap (java.util.HashMap)3 ValueAggregator (org.talend.dataprofiler.service.utils.ValueAggregator)2 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)2 Edge (edu.uci.ics.jung.graph.Edge)1 Vertex (edu.uci.ics.jung.graph.Vertex)1 UndirectedSparseEdge (edu.uci.ics.jung.graph.impl.UndirectedSparseEdge)1 UndirectedSparseVertex (edu.uci.ics.jung.graph.impl.UndirectedSparseVertex)1 Date (java.util.Date)1 Entry (java.util.Map.Entry)1 TreeMap (java.util.TreeMap)1