use of org.knime.core.data.DataTableSpec in project knime-core by knime.
the class TwoSampleTTestStatistics method getGroupTable.
/**
* Get descriptive statistics.
* @param exec the execution context
* @return the descriptive statistics for each group
*/
public BufferedDataTable getGroupTable(final ExecutionContext exec) {
DataTableSpec outSpec = getGroupStatisticsSpec();
BufferedDataContainer cont = exec.createDataContainer(outSpec);
int r = 0;
for (List<DataCell> cells : getGroupStatisticsCells()) {
cont.addRowToTable(new DefaultRow(RowKey.createRowKey(r), cells));
r++;
}
cont.close();
BufferedDataTable outTable = cont.getTable();
return outTable;
}
use of org.knime.core.data.DataTableSpec in project knime-core by knime.
the class StringToDateTimeNodeModel method createColumnRearranger.
/**
* {@inheritDoc}
*/
@Override
protected ColumnRearranger createColumnRearranger(final DataTableSpec inSpec) {
final ColumnRearranger rearranger = new ColumnRearranger(inSpec);
final String[] includeList = m_colSelect.applyTo(inSpec).getIncludes();
final int[] includeIndeces = Arrays.stream(m_colSelect.applyTo(inSpec).getIncludes()).mapToInt(s -> inSpec.findColumnIndex(s)).toArray();
int i = 0;
for (String includedCol : includeList) {
if (m_isReplaceOrAppend.getStringValue().equals(OPTION_REPLACE)) {
final DataColumnSpecCreator dataColumnSpecCreator = new DataColumnSpecCreator(includedCol, DateTimeType.valueOf(m_selectedType).getDataType());
final StringToTimeCellFactory cellFac = new StringToTimeCellFactory(dataColumnSpecCreator.createSpec(), includeIndeces[i++]);
rearranger.replace(cellFac, includedCol);
} else {
final DataColumnSpec dataColSpec = new UniqueNameGenerator(inSpec).newColumn(includedCol + m_suffix.getStringValue(), DateTimeType.valueOf(m_selectedType).getDataType());
final StringToTimeCellFactory cellFac = new StringToTimeCellFactory(dataColSpec, includeIndeces[i++]);
rearranger.append(cellFac);
}
}
return rearranger;
}
use of org.knime.core.data.DataTableSpec in project knime-core by knime.
the class StringToDurationPeriodNodeModel method computeFinalOutputSpecs.
@Override
public PortObjectSpec[] computeFinalOutputSpecs(final StreamableOperatorInternals internals, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
if (m_type.getStringValue().equals(OutputType.Automatic.name())) {
final SimpleStreamableOperatorInternals simpleInternals = (SimpleStreamableOperatorInternals) internals;
final Config config = simpleInternals.getConfig();
final DataColumnSpec[] colSpecs = new DataColumnSpec[config.getInt("sizeRow")];
for (int i = 0; i < colSpecs.length; i++) {
final DataColumnSpecCreator dataColumnSpecCreator = new DataColumnSpecCreator(config.getString("colname" + i), config.getDataType("type" + i));
colSpecs[i] = dataColumnSpecCreator.createSpec();
}
return new DataTableSpec[] { new DataTableSpec(colSpecs) };
} else {
return configure(new DataTableSpec[] { (DataTableSpec) inSpecs[0] });
}
}
use of org.knime.core.data.DataTableSpec in project knime-core by knime.
the class StringToDurationPeriodNodeModel method createColumnRearranger.
private ColumnRearranger createColumnRearranger(final DataTableSpec spec) throws InvalidSettingsException {
final ColumnRearranger rearranger = new ColumnRearranger(spec);
final String[] includeList = m_colSelect.applyTo(spec).getIncludes();
final int[] includeIndices = Arrays.stream(m_colSelect.applyTo(spec).getIncludes()).mapToInt(s -> spec.findColumnIndex(s)).toArray();
int i = 0;
for (final String includedCol : includeList) {
if (m_isReplaceOrAppend.getStringValue().equals(OPTION_REPLACE)) {
final DataColumnSpecCreator dataColumnSpecCreator = new DataColumnSpecCreator(includedCol, m_detectedTypes[i]);
final StringToDurationPeriodCellFactory cellFac = new StringToDurationPeriodCellFactory(dataColumnSpecCreator.createSpec(), includeIndices[i++]);
rearranger.replace(cellFac, includedCol);
} else {
final DataColumnSpec dataColSpec = new UniqueNameGenerator(spec).newColumn(includedCol + m_suffix.getStringValue(), m_detectedTypes[i]);
final StringToDurationPeriodCellFactory cellFac = new StringToDurationPeriodCellFactory(dataColSpec, includeIndices[i++]);
rearranger.append(cellFac);
}
}
return rearranger;
}
use of org.knime.core.data.DataTableSpec in project knime-core by knime.
the class ExtendedStatisticsNodeModel method configure.
/**
* {@inheritDoc}
*/
@SuppressWarnings({ "unchecked", "deprecation" })
@Override
protected DataTableSpec[] configure(final DataTableSpec[] inSpecs) throws InvalidSettingsException {
final DataTableSpec inputSpec = inSpecs[0];
if (!m_hasSettings) {
m_nominalFilter.loadDefaults(inputSpec, new DataTypeColumnFilter(NominalValue.class, StringValue.class, IntValue.class, LongValue.class, BooleanValue.class), true);
}
List<String> nominalValues = Arrays.asList(m_nominalFilter.applyTo(inputSpec).getIncludes());
DataTableSpec nominalSpec = Statistics3Table.createOutSpecNominal(inputSpec, nominalValues);
nominalSpec = renamedOccurrencesSpec(nominalSpec);
DataTableSpec[] ret = new DataTableSpec[3];
DataTableSpecCreator specCreator = new DataTableSpecCreator(Statistics3Table.getStatisticsSpecification());
final HistogramColumn hc = createHistogramColumn();
final DataColumnSpec histogramColumnSpec = hc.createHistogramColumnSpec();
specCreator.addColumns(histogramColumnSpec);
ret[0] = specCreator.createSpec();
ret[1] = hc.createNominalHistogramTableSpec();
ret[2] = nominalSpec;
return ret;
}
Aggregations