Search in sources :

Example 6 with AffineTransTable

use of org.knime.base.data.normalize.AffineTransTable in project knime-core by knime.

the class NormalizerApplyNodeModel method createStreamableOperator.

/**
 * {@inheritDoc}
 */
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    if (getNrOutPorts() == 2) {
        // by default call the default implementation of this method
        return super.createStreamableOperator(partitionInfo, inSpecs);
    } else {
        return new StreamableOperator() {

            @Override
            public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
                assert outputs.length == 1;
                NormalizerPortObject model = (NormalizerPortObject) ((PortObjectInput) inputs[0]).getPortObject();
                RowInput rowInput = (RowInput) inputs[1];
                AffineTransTable t = new AffineTransTable(rowInput, getAffineTrans(model.getConfiguration()));
                RowOutput rowOutput = (RowOutput) outputs[0];
                RowIterator it = t.iterator();
                while (it.hasNext()) {
                    rowOutput.push(it.next());
                }
                if (t.getErrorMessage() != null) {
                    // TODO collect error message from remote nodes if run distributed
                    setWarningMessage(t.getErrorMessage());
                }
                rowInput.close();
                rowOutput.close();
            }
        };
    }
}
Also used : NormalizerPortObject(org.knime.base.data.normalize.NormalizerPortObject) RowOutput(org.knime.core.node.streamable.RowOutput) ExecutionContext(org.knime.core.node.ExecutionContext) StreamableOperator(org.knime.core.node.streamable.StreamableOperator) RowIterator(org.knime.core.data.RowIterator) AffineTransTable(org.knime.base.data.normalize.AffineTransTable) RowInput(org.knime.core.node.streamable.RowInput)

Aggregations

AffineTransTable (org.knime.base.data.normalize.AffineTransTable)6 BufferedDataTable (org.knime.core.node.BufferedDataTable)5 AffineTransConfiguration (org.knime.base.data.normalize.AffineTransConfiguration)4 IOException (java.io.IOException)3 DataColumnDomainCreator (org.knime.core.data.DataColumnDomainCreator)3 DataColumnSpec (org.knime.core.data.DataColumnSpec)3 DataColumnSpecCreator (org.knime.core.data.DataColumnSpecCreator)3 DataRow (org.knime.core.data.DataRow)3 DataTableSpec (org.knime.core.data.DataTableSpec)3 DoubleCell (org.knime.core.data.def.DoubleCell)3 BufferedDataContainer (org.knime.core.node.BufferedDataContainer)3 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)3 ExecutionContext (org.knime.core.node.ExecutionContext)3 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)3 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)3 Normalizer2 (org.knime.base.data.normalize.Normalizer2)2 NormalizerPortObject (org.knime.base.data.normalize.NormalizerPortObject)2 Normalizer (org.knime.base.data.normalize.Normalizer)1 PMMLNormalizeTranslator (org.knime.base.data.normalize.PMMLNormalizeTranslator)1 RowIterator (org.knime.core.data.RowIterator)1