Search in sources :

Example 16 with ConfigRO

use of org.knime.core.node.config.ConfigRO in project knime-core by knime.

the class HistogramColumn method loadHistogramsPrivate.

private static Map<Integer, HistogramNumericModel> loadHistogramsPrivate(final File histogramsGz, final Map<Integer, Map<Integer, Set<RowKey>>> numericKeys, final BinNumberSelectionStrategy strategy, final double[] means) throws IOException, InvalidSettingsException {
    final FileInputStream is = new FileInputStream(histogramsGz);
    final GZIPInputStream inData = new GZIPInputStream(is);
    final ConfigRO config = NodeSettings.loadFromXML(inData);
    Map<Integer, HistogramNumericModel> histograms = new HashMap<Integer, HistogramNumericModel>();
    // .getConfig(HISTOGRAMS);
    ConfigRO hs = config;
    int[] numColumnIndices = config.getIntArray(NUMERIC_COLUMNS);
    for (int colIdx : numColumnIndices) {
        Config h = hs.getConfig(HISTOGRAM + colIdx);
        double min = h.getDouble(MIN), max = h.getDouble(MAX), width = h.getDouble(WIDTH);
        int maxCount = h.getInt(MAX_COUNT);
        int rowCount = h.getInt(ROW_COUNT);
        String colName = h.getString(COL_NAME);
        double[] binMins = h.getDoubleArray(BIN_MINS), binMaxes = h.getDoubleArray(BIN_MAXES);
        int[] binCounts = h.getIntArray(BIN_COUNTS);
        double mean = means[colIdx];
        HistogramNumericModel histogramData = new HistogramNumericModel(min, max, binMins.length, colIdx, colName, min, max, mean);
        for (int i = binMins.length; i-- > 0; ) {
            histogramData.getBins().set(i, histogramData.new NumericBin(binMins[i], binMaxes[i]));
            histogramData.getBins().get(i).setCount(binCounts[i]);
        }
        histogramData.setMaxCount(maxCount);
        histogramData.setRowCount(rowCount);
        assert Math.abs(histogramData.m_width - width) < 1e-9 : "histogram data width: " + histogramData.m_width + " width: " + width;
        histograms.put(colIdx, histogramData);
        numericKeys.put(colIdx, new HashMap<Integer, Set<RowKey>>());
    }
    return histograms;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Config(org.knime.core.node.config.Config) FileInputStream(java.io.FileInputStream) GZIPInputStream(java.util.zip.GZIPInputStream) ConfigRO(org.knime.core.node.config.ConfigRO)

Aggregations

ConfigRO (org.knime.core.node.config.ConfigRO)16 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)8 FileInputStream (java.io.FileInputStream)7 Config (org.knime.core.node.config.Config)7 GZIPInputStream (java.util.zip.GZIPInputStream)6 File (java.io.File)5 LinkedHashMap (java.util.LinkedHashMap)5 Color (java.awt.Color)4 HashMap (java.util.HashMap)4 DataCell (org.knime.core.data.DataCell)4 ArrayList (java.util.ArrayList)3 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 Set (java.util.Set)2 DefaultDataArray (org.knime.base.node.util.DefaultDataArray)2 ContainerTable (org.knime.core.data.container.ContainerTable)2 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)2 PortType (org.knime.core.node.port.PortType)2 Point (java.awt.Point)1 HashSet (java.util.HashSet)1