Search in sources :

Example 6 with SimpleStreamableOperatorInternals

use of org.knime.core.node.streamable.simple.SimpleStreamableOperatorInternals in project knime-core by knime.

the class OldToNewTimeNodeModel method createInitialStreamableOperatorInternals.

@Override
public StreamableOperatorInternals createInitialStreamableOperatorInternals() {
    SimpleStreamableOperatorInternals simpleStreamableOperatorInternals = new SimpleStreamableOperatorInternals();
    simpleStreamableOperatorInternals.getConfig().addBoolean("hasIterated", true);
    simpleStreamableOperatorInternals.getConfig().addInt("sizeRow", 0);
    return simpleStreamableOperatorInternals;
}
Also used : SimpleStreamableOperatorInternals(org.knime.core.node.streamable.simple.SimpleStreamableOperatorInternals)

Example 7 with SimpleStreamableOperatorInternals

use of org.knime.core.node.streamable.simple.SimpleStreamableOperatorInternals in project knime-core by knime.

the class OldToNewTimeNodeModel method computeFinalOutputSpecs.

@Override
public PortObjectSpec[] computeFinalOutputSpecs(final StreamableOperatorInternals internals, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    if (m_autoType.getBooleanValue()) {
        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] });
    }
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) SimpleStreamableOperatorInternals(org.knime.core.node.streamable.simple.SimpleStreamableOperatorInternals) DataColumnSpec(org.knime.core.data.DataColumnSpec) DataColumnSpecCreator(org.knime.core.data.DataColumnSpecCreator) Config(org.knime.core.node.config.Config)

Example 8 with SimpleStreamableOperatorInternals

use of org.knime.core.node.streamable.simple.SimpleStreamableOperatorInternals in project knime-core by knime.

the class StringToNumberNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected BufferedDataTable[] execute(final BufferedDataTable[] inData, final ExecutionContext exec) throws Exception {
    DataTableSpec inspec = inData[0].getDataTableSpec();
    List<String> inclcols = m_inclCols.getIncludeList();
    if (inclcols.size() == 0) {
        // nothing to convert, let's return the input table.
        setWarningMessage("No columns selected," + " returning input DataTable.");
        return new BufferedDataTable[] { inData[0] };
    }
    SimpleStreamableOperatorInternals internals = createStreamingOperatorInternals();
    ColumnRearranger colre = createColumnRearranger(inspec, internals);
    BufferedDataTable resultTable = exec.createColumnRearrangeTable(inData[0], colre, exec);
    warningMessage(internals);
    return new BufferedDataTable[] { resultTable };
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) SimpleStreamableOperatorInternals(org.knime.core.node.streamable.simple.SimpleStreamableOperatorInternals) ColumnRearranger(org.knime.core.data.container.ColumnRearranger) BufferedDataTable(org.knime.core.node.BufferedDataTable) SettingsModelFilterString(org.knime.core.node.defaultnodesettings.SettingsModelFilterString)

Example 9 with SimpleStreamableOperatorInternals

use of org.knime.core.node.streamable.simple.SimpleStreamableOperatorInternals in project knime-core by knime.

the class ReferenceColumnResorterNodeModel method createStreamableOperatorInternalsFromOrder.

private SimpleStreamableOperatorInternals createStreamableOperatorInternalsFromOrder(final String[] order) {
    SimpleStreamableOperatorInternals i = new SimpleStreamableOperatorInternals();
    i.getConfig().addStringArray("order", order);
    return i;
}
Also used : SimpleStreamableOperatorInternals(org.knime.core.node.streamable.simple.SimpleStreamableOperatorInternals)

Example 10 with SimpleStreamableOperatorInternals

use of org.knime.core.node.streamable.simple.SimpleStreamableOperatorInternals in project knime-core by knime.

the class DoubleToIntNodeModel method mergeStreamingOperatorInternals.

/**
 * {@inheritDoc}
 *
 * @since 3.1
 */
@Override
protected SimpleStreamableOperatorInternals mergeStreamingOperatorInternals(final SimpleStreamableOperatorInternals[] operatorInternals) {
    // merge warning messages from potentially different partitions -> essentially concatenate the messages
    StringBuilder sb = new StringBuilder();
    for (SimpleStreamableOperatorInternals oi : operatorInternals) {
        WarningMessage wm = (WarningMessage) oi;
        if (wm.get() != null) {
            sb.append(wm.get());
            sb.append("\n");
        }
    }
    WarningMessage res = new WarningMessage();
    res.set(sb.toString());
    return res;
}
Also used : SimpleStreamableOperatorInternals(org.knime.core.node.streamable.simple.SimpleStreamableOperatorInternals)

Aggregations

SimpleStreamableOperatorInternals (org.knime.core.node.streamable.simple.SimpleStreamableOperatorInternals)24 DataTableSpec (org.knime.core.data.DataTableSpec)9 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)9 BufferedDataTable (org.knime.core.node.BufferedDataTable)7 StreamableOperator (org.knime.core.node.streamable.StreamableOperator)7 StreamableOperatorInternals (org.knime.core.node.streamable.StreamableOperatorInternals)7 ExecutionContext (org.knime.core.node.ExecutionContext)6 RowInput (org.knime.core.node.streamable.RowInput)6 Config (org.knime.core.node.config.Config)5 MergeOperator (org.knime.core.node.streamable.MergeOperator)5 DataColumnSpec (org.knime.core.data.DataColumnSpec)4 DataColumnSpecCreator (org.knime.core.data.DataColumnSpecCreator)4 DataRow (org.knime.core.data.DataRow)4 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)4 DataTableRowInput (org.knime.core.node.streamable.DataTableRowInput)4 PortInput (org.knime.core.node.streamable.PortInput)4 RowOutput (org.knime.core.node.streamable.RowOutput)4 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)3 PartitionInfo (org.knime.core.node.streamable.PartitionInfo)3 PortOutput (org.knime.core.node.streamable.PortOutput)3