Search in sources :

Example 6 with DataTableSpecCreator

use of org.knime.core.data.DataTableSpecCreator in project knime-core by knime.

the class TimerinfoNodeModel method createSpec.

private DataTableSpec createSpec() {
    DataTableSpecCreator dtsc = new DataTableSpecCreator();
    DataColumnSpec[] colSpecs = new DataColumnSpec[] { new DataColumnSpecCreator("Name", StringCell.TYPE).createSpec(), new DataColumnSpecCreator("Execution Time", LongCell.TYPE).createSpec(), new DataColumnSpecCreator("Execution Time since last Reset", LongCell.TYPE).createSpec(), new DataColumnSpecCreator("Execution Time since Start", LongCell.TYPE).createSpec(), new DataColumnSpecCreator("Nr of Executions since last Reset", IntCell.TYPE).createSpec(), new DataColumnSpecCreator("Nr of Executions since Start", IntCell.TYPE).createSpec(), new DataColumnSpecCreator("NodeID", StringCell.TYPE).createSpec(), new DataColumnSpecCreator("Classname", StringCell.TYPE).createSpec() };
    dtsc.addColumns(colSpecs);
    return dtsc.createSpec();
}
Also used : DataColumnSpec(org.knime.core.data.DataColumnSpec) DataColumnSpecCreator(org.knime.core.data.DataColumnSpecCreator) DataTableSpecCreator(org.knime.core.data.DataTableSpecCreator)

Example 7 with DataTableSpecCreator

use of org.knime.core.data.DataTableSpecCreator in project knime-core by knime.

the class ClusterNodeModel method createClusterCentersSpec.

private DataTableSpec createClusterCentersSpec(final DataTableSpec spec) {
    // Create spec for cluster center table
    DataTableSpecCreator clusterCenterSpecCreator = new DataTableSpecCreator();
    for (int i = 0; i < m_dimension; i++) {
        if (!m_ignoreColumn[i]) {
            clusterCenterSpecCreator.addColumns(new DataColumnSpecCreator(spec.getColumnSpec(i).getName(), DoubleCell.TYPE).createSpec());
        }
    }
    clusterCenterSpecCreator.dropAllDomains();
    return clusterCenterSpecCreator.createSpec();
}
Also used : DataColumnSpecCreator(org.knime.core.data.DataColumnSpecCreator) DataTableSpecCreator(org.knime.core.data.DataTableSpecCreator)

Example 8 with DataTableSpecCreator

use of org.knime.core.data.DataTableSpecCreator in project knime-core by knime.

the class EditNominalDomainNodeModel method sortPossibleValues.

private DataTableSpec sortPossibleValues(final DataTableSpec orgSpec) throws InvalidSettingsException {
    if (m_configuration == null) {
        throw new InvalidSettingsException("Missing Configuration.");
    }
    Set<String> configuredColumns = new HashSet<String>(m_configuration.getConfiguredColumns());
    String[] columnNames = orgSpec.getColumnNames();
    DataTableSpecCreator creator = new DataTableSpecCreator(orgSpec).dropAllColumns();
    for (int i = 0; i < orgSpec.getNumColumns(); i++) {
        String name = columnNames[i];
        if (configuredColumns.remove(name)) {
            DataColumnSpec orgDataSpec = orgSpec.getColumnSpec(i);
            if (!StringCell.TYPE.equals(orgDataSpec.getType())) {
                CheckUtils.checkSetting(m_configuration.isIgnoreWrongTypes(), "Column '%s' must be of type '%s' \nbut was of type: '%s'", name, StringCell.TYPE, orgDataSpec.getType());
                creator.addColumns(orgDataSpec);
            } else {
                DataColumnDomain domain = orgDataSpec.getDomain();
                DataColumnSpecCreator dataColumnSpecCreator = new DataColumnSpecCreator(orgDataSpec);
                DataColumnDomainCreator yetAnotherCreator = new DataColumnDomainCreator(domain.getLowerBound(), domain.getUpperBound());
                List<DataCell> sorting = new ArrayList<DataCell>(m_configuration.getSorting(name));
                Set<DataCell> difference = diff(domain.getValues(), sorting);
                yetAnotherCreator.setValues(resolveNewValues(sorting, difference));
                dataColumnSpecCreator.setDomain(yetAnotherCreator.createDomain());
                creator.addColumns(dataColumnSpecCreator.createSpec());
            }
        } else {
            creator.addColumns(orgSpec.getColumnSpec(i));
        }
    }
    if (!configuredColumns.isEmpty()) {
        String missingColumnsString = "Following columns are configured but no longer exist: \n" + ConvenienceMethods.getShortStringFrom(configuredColumns, 5);
        CheckUtils.checkSetting(m_configuration.isIgnoreNotExistingColumns(), missingColumnsString);
        setWarningMessage(missingColumnsString);
    }
    return creator.createSpec();
}
Also used : DataColumnSpecCreator(org.knime.core.data.DataColumnSpecCreator) DataTableSpecCreator(org.knime.core.data.DataTableSpecCreator) ArrayList(java.util.ArrayList) DataColumnDomainCreator(org.knime.core.data.DataColumnDomainCreator) DataColumnSpec(org.knime.core.data.DataColumnSpec) DataColumnDomain(org.knime.core.data.DataColumnDomain) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) DataCell(org.knime.core.data.DataCell) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 9 with DataTableSpecCreator

use of org.knime.core.data.DataTableSpecCreator in project knime-core by knime.

the class GlobalTimerinfoNodeModel method createSpecOut1.

private DataTableSpec createSpecOut1() {
    DataTableSpecCreator dtsc = new DataTableSpecCreator();
    DataColumnSpec[] colSpecs = new DataColumnSpec[] { new DataColumnSpecCreator("Feature Name", StringCell.TYPE).createSpec(), new DataColumnSpecCreator("Version", StringCell.TYPE).createSpec() };
    dtsc.addColumns(colSpecs);
    return dtsc.createSpec();
}
Also used : DataColumnSpec(org.knime.core.data.DataColumnSpec) DataColumnSpecCreator(org.knime.core.data.DataColumnSpecCreator) DataTableSpecCreator(org.knime.core.data.DataTableSpecCreator)

Example 10 with DataTableSpecCreator

use of org.knime.core.data.DataTableSpecCreator in project knime-core by knime.

the class EditNominalDomainDicNodeModel method mergeTableSpecs.

/**
 * @param orgSpec
 * @param orgIndexToNewDomainValuesMap
 * @return
 */
private static DataTableSpecCreator mergeTableSpecs(final DataTableSpec orgSpec, final Map<Integer, Set<DataCell>> orgIndexToNewDomainValuesMap) {
    DataTableSpecCreator newSpecCreator = new DataTableSpecCreator(orgSpec).dropAllColumns();
    for (int i = 0; i < orgSpec.getNumColumns(); i++) {
        if (orgIndexToNewDomainValuesMap.containsKey(i)) {
            DataColumnSpec orgDataSpec = orgSpec.getColumnSpec(i);
            DataColumnSpecCreator dataColumnSpecCreator = new DataColumnSpecCreator(orgDataSpec);
            DataColumnDomainCreator yetAnotherCreator = new DataColumnDomainCreator(orgDataSpec.getDomain());
            yetAnotherCreator.setValues(orgIndexToNewDomainValuesMap.get(i));
            dataColumnSpecCreator.setDomain(yetAnotherCreator.createDomain());
            newSpecCreator.addColumns(dataColumnSpecCreator.createSpec());
        } else {
            newSpecCreator.addColumns(orgSpec.getColumnSpec(i));
        }
    }
    return newSpecCreator;
}
Also used : DataColumnSpec(org.knime.core.data.DataColumnSpec) DataColumnSpecCreator(org.knime.core.data.DataColumnSpecCreator) DataTableSpecCreator(org.knime.core.data.DataTableSpecCreator) DataColumnDomainCreator(org.knime.core.data.DataColumnDomainCreator)

Aggregations

DataTableSpecCreator (org.knime.core.data.DataTableSpecCreator)20 DataColumnSpecCreator (org.knime.core.data.DataColumnSpecCreator)12 DataColumnSpec (org.knime.core.data.DataColumnSpec)11 DataTableSpec (org.knime.core.data.DataTableSpec)6 DataCell (org.knime.core.data.DataCell)4 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)4 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)4 ArrayList (java.util.ArrayList)3 DataColumnDomainCreator (org.knime.core.data.DataColumnDomainCreator)3 HashSet (java.util.HashSet)2 Random (java.util.Random)2 DefaultRow (org.knime.core.data.def.DefaultRow)2 DoubleCell (org.knime.core.data.def.DoubleCell)2 BufferedDataContainer (org.knime.core.node.BufferedDataContainer)2 BufferedDataTable (org.knime.core.node.BufferedDataTable)2 FilterResult (org.knime.core.node.util.filter.NameFilterConfiguration.FilterResult)2 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 HistogramColumn (org.knime.base.data.statistics.HistogramColumn)1 BooleanValue (org.knime.core.data.BooleanValue)1