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;
}
Aggregations