Search in sources :

Example 1 with Statistic

use of org.knime.base.data.statistics.Statistic in project knime-core by knime.

the class MissingCellReplacingDataTable method init.

/**
 * Initializes the statistics for the handlers. Only has to be called if actual replacement should take place.
 * @param inTable the actual DataTable which this table wraps.
 * @param exec the execution context for the iteration which calculates statistics
 * @throws InvalidSettingsException if the statistics from the
 *                                  missing cell handlers are conflicting with the table specs
 * @throws CanceledExecutionException when the user cancels the execution
 */
public void init(final BufferedDataTable inTable, final ExecutionContext exec) throws InvalidSettingsException, CanceledExecutionException {
    m_table = inTable;
    // Calculate necessary statistics
    ArrayList<Statistic> statistics = new ArrayList<Statistic>();
    for (int i = 0; i < m_table.getDataTableSpec().getNumColumns(); i++) {
        Statistic s = m_handlers[i].getStatistic();
        if (s != null) {
            statistics.add(s);
        }
    }
    // Fill the statistics retrieved from the handlers
    if (statistics.size() > 0) {
        StatisticCalculator calc = new StatisticCalculator(m_table.getDataTableSpec(), statistics.toArray(new Statistic[0]));
        String res = calc.evaluate(m_table, exec);
        if (res != null) {
            addWarningMessage(res);
        }
    }
}
Also used : StatisticCalculator(org.knime.base.data.statistics.StatisticCalculator) Statistic(org.knime.base.data.statistics.Statistic) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)1 Statistic (org.knime.base.data.statistics.Statistic)1 StatisticCalculator (org.knime.base.data.statistics.StatisticCalculator)1