Search in sources :

Example 11 with StreamableFunction

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

the class CellReplacerNodeModel method createStreamableOperator.

/**
 * {@inheritDoc}
 */
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    return new StreamableOperator() {

        @Override
        public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
            BufferedDataTable dictTable = (BufferedDataTable) ((PortObjectInput) inputs[1]).getPortObject();
            ColumnRearranger rearranger = createColumnRearranger((DataTableSpec) inSpecs[0], dictTable.getDataTableSpec(), dictTable, exec);
            StreamableFunction func = rearranger.createStreamableFunction(0, 0);
            func.runFinal(inputs, outputs, exec);
        }
    };
}
Also used : ExecutionContext(org.knime.core.node.ExecutionContext) ColumnRearranger(org.knime.core.data.container.ColumnRearranger) StreamableOperator(org.knime.core.node.streamable.StreamableOperator) BufferedDataTable(org.knime.core.node.BufferedDataTable) StreamableFunction(org.knime.core.node.streamable.StreamableFunction)

Example 12 with StreamableFunction

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

the class ReferenceColumnResorterNodeModel method createStreamableOperator.

/**
 * {@inheritDoc}
 */
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    return new StreamableOperator() {

        private String[] m_streamableOperatorOrder;

        /**
         * {@inheritDoc}
         */
        @Override
        public void runIntermediate(final PortInput[] inputs, final ExecutionContext exec) throws Exception {
            BufferedDataTable orderTable = (BufferedDataTable) ((PortObjectInput) inputs[1]).getPortObject();
            m_streamableOperatorOrder = readOrderFromTable(orderTable);
        }

        @Override
        public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
            RowInput dataInput = (RowInput) inputs[0];
            DataTableSpec dataInputSpec = dataInput.getDataTableSpec();
            ColumnRearranger rearranger = createColumnRearranger(dataInputSpec, m_streamableOperatorOrder);
            StreamableFunction streamableFunction = rearranger.createStreamableFunction();
            streamableFunction.runFinal(new PortInput[] { dataInput }, outputs, exec);
        }

        /**
         * {@inheritDoc}
         */
        @Override
        public StreamableOperatorInternals saveInternals() {
            return createStreamableOperatorInternalsFromOrder(m_streamableOperatorOrder);
        }

        /**
         * {@inheritDoc}
         */
        @Override
        public void loadInternals(final StreamableOperatorInternals internals) {
            m_streamableOperatorOrder = readOrderFromStreamableOperatorInternals(internals);
        }
    };
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) ExecutionContext(org.knime.core.node.ExecutionContext) ColumnRearranger(org.knime.core.data.container.ColumnRearranger) StreamableOperator(org.knime.core.node.streamable.StreamableOperator) BufferedDataTable(org.knime.core.node.BufferedDataTable) StreamableOperatorInternals(org.knime.core.node.streamable.StreamableOperatorInternals) SimpleStreamableOperatorInternals(org.knime.core.node.streamable.simple.SimpleStreamableOperatorInternals) RowInput(org.knime.core.node.streamable.RowInput) StreamableFunction(org.knime.core.node.streamable.StreamableFunction)

Example 13 with StreamableFunction

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

the class DataColumnSpecFilterPMMLNodeModel method createStreamableOperator.

/**
 * {@inheritDoc}
 */
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    final ColumnRearranger corea = createColumnRearranger((DataTableSpec) inSpecs[0]);
    final StreamableFunction fct = corea.createStreamableFunction();
    return new StreamableOperator() {

        @Override
        public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
            // execute streamable in- and outport (0)
            fct.init(exec);
            fct.runFinal(inputs, outputs, exec);
            fct.finish();
            DataTableSpec outSpec = corea.createSpec();
            // pmml ports
            PMMLPortObject pmmlIn = (PMMLPortObject) ((PortObjectInput) inputs[1]).getPortObject();
            final PMMLPortObject pmmlOut = createPMMLOut(pmmlIn, outSpec, getFilterResult((DataTableSpec) inSpecs[0]));
            ((PortObjectOutput) outputs[1]).setPortObject(pmmlOut);
        }
    };
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) ColumnRearranger(org.knime.core.data.container.ColumnRearranger) ExecutionContext(org.knime.core.node.ExecutionContext) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) StreamableOperator(org.knime.core.node.streamable.StreamableOperator) StreamableFunction(org.knime.core.node.streamable.StreamableFunction) PortObjectOutput(org.knime.core.node.streamable.PortObjectOutput)

Example 14 with StreamableFunction

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

the class AbstractColumnRefNodeModel method createStreamableOperator.

/**
 * {@inheritDoc}
 */
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    return new StreamableOperator() {

        @Override
        public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
            ColumnRearranger[] cr = createRearranger((DataTableSpec) inSpecs[0], (DataTableSpec) inSpecs[1]);
            StreamableFunction func1 = cr[0].createStreamableFunction(0, 0);
            if (m_isSplitter) {
                StreamableFunction func2 = cr[1].createStreamableFunction(0, 1);
                RowInput rowInput = ((RowInput) inputs[0]);
                RowOutput rowOutput1 = ((RowOutput) outputs[0]);
                RowOutput rowOutput2 = ((RowOutput) outputs[1]);
                StreamableFunction.runFinalInterwoven(rowInput, func1, rowOutput1, func2, rowOutput2, exec);
            } else {
                func1.runFinal(inputs, outputs, exec);
            }
        }
    };
}
Also used : RowOutput(org.knime.core.node.streamable.RowOutput) ExecutionContext(org.knime.core.node.ExecutionContext) ColumnRearranger(org.knime.core.data.container.ColumnRearranger) StreamableOperator(org.knime.core.node.streamable.StreamableOperator) StreamableFunction(org.knime.core.node.streamable.StreamableFunction) RowInput(org.knime.core.node.streamable.RowInput)

Example 15 with StreamableFunction

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

the class SplitNodeModel2 method createStreamableOperator.

/**
 * {@inheritDoc}
 */
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    if (m_conf == null) {
        m_conf = createColFilterConf();
    }
    final DataTableSpec inSpec = (DataTableSpec) inSpecs[0];
    return new StreamableOperator() {

        @Override
        public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
            ColumnRearranger[] a = createColumnRearrangers(inSpec);
            StreamableFunction func1 = a[0].createStreamableFunction(0, 0);
            StreamableFunction func2 = a[1].createStreamableFunction(0, 1);
            // use both functions to actually do it
            RowInput rowInput = ((RowInput) inputs[0]);
            RowOutput rowOutput1 = ((RowOutput) outputs[0]);
            RowOutput rowOutput2 = ((RowOutput) outputs[1]);
            StreamableFunction.runFinalInterwoven(rowInput, func1, rowOutput1, func2, rowOutput2, exec);
        }
    };
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) RowOutput(org.knime.core.node.streamable.RowOutput) ExecutionContext(org.knime.core.node.ExecutionContext) ColumnRearranger(org.knime.core.data.container.ColumnRearranger) StreamableOperator(org.knime.core.node.streamable.StreamableOperator) StreamableFunction(org.knime.core.node.streamable.StreamableFunction) RowInput(org.knime.core.node.streamable.RowInput)

Aggregations

ExecutionContext (org.knime.core.node.ExecutionContext)23 StreamableFunction (org.knime.core.node.streamable.StreamableFunction)23 StreamableOperator (org.knime.core.node.streamable.StreamableOperator)23 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)21 DataTableSpec (org.knime.core.data.DataTableSpec)16 PMMLPortObject (org.knime.core.node.port.pmml.PMMLPortObject)7 RowInput (org.knime.core.node.streamable.RowInput)5 TreeEnsembleModelPortObjectSpec (org.knime.base.node.mine.treeensemble2.model.TreeEnsembleModelPortObjectSpec)4 GradientBoostingModelPortObject (org.knime.base.node.mine.treeensemble2.model.GradientBoostingModelPortObject)3 GradientBoostingPredictor (org.knime.base.node.mine.treeensemble2.node.gradientboosting.predictor.GradientBoostingPredictor)3 BufferedDataTable (org.knime.core.node.BufferedDataTable)3 RowOutput (org.knime.core.node.streamable.RowOutput)3 TreeEnsembleModelPortObject (org.knime.base.node.mine.treeensemble.model.TreeEnsembleModelPortObject)2 TreeEnsembleModelPortObjectSpec (org.knime.base.node.mine.treeensemble.model.TreeEnsembleModelPortObjectSpec)2 TreeEnsemblePredictor (org.knime.base.node.mine.treeensemble.node.predictor.TreeEnsemblePredictor)2 TreeEnsembleModelPortObject (org.knime.base.node.mine.treeensemble2.model.TreeEnsembleModelPortObject)2 TreeEnsemblePredictor (org.knime.base.node.mine.treeensemble2.node.predictor.TreeEnsemblePredictor)2 StreamableOperatorInternals (org.knime.core.node.streamable.StreamableOperatorInternals)2 SimpleStreamableOperatorInternals (org.knime.core.node.streamable.simple.SimpleStreamableOperatorInternals)2 IOException (java.io.IOException)1