Search in sources :

Example 56 with StreamableOperator

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

the class NaiveBayesPredictorNodeModel2 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 {
            PMMLPortObject pmmlPortObj = (PMMLPortObject) ((PortObjectInput) inputs[MODEL_IN_PORT]).getPortObject();
            DataTableSpec inSpec = (DataTableSpec) inSpecs[DATA_IN_PORT];
            StreamableFunction fct = createColumnRearranger(pmmlPortObj, inSpec).createStreamableFunction(DATA_IN_PORT, 0);
            fct.runFinal(inputs, outputs, exec);
        }
    };
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) 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)

Example 57 with StreamableOperator

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

the class VirtualSubNodeOutputNodeModel 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 {
            PortObject[] inObjects = new PortObject[getNrInPorts()];
            for (int i = 0; i < inObjects.length; i++) {
                PortType inPortType = getInPortType(i);
                if (BufferedDataTable.TYPE.equals(inPortType)) {
                    BufferedDataContainer container = exec.createDataContainer((DataTableSpec) inSpecs[i]);
                    DataRow r;
                    while ((r = ((RowInput) inputs[i]).poll()) != null) {
                        container.addRowToTable(r);
                    }
                    container.close();
                    inObjects[i] = container.getTable();
                } else {
                    inObjects[i] = ((PortObjectInput) inputs[i]).getPortObject();
                }
            }
            setNewExchange(new VirtualSubNodeExchange(inObjects, getVisibleFlowVariables()));
        }
    };
}
Also used : ExecutionContext(org.knime.core.node.ExecutionContext) BufferedDataContainer(org.knime.core.node.BufferedDataContainer) StreamableOperator(org.knime.core.node.streamable.StreamableOperator) InactiveBranchPortObject(org.knime.core.node.port.inactive.InactiveBranchPortObject) PortObject(org.knime.core.node.port.PortObject) DataRow(org.knime.core.data.DataRow) PortType(org.knime.core.node.port.PortType)

Aggregations

StreamableOperator (org.knime.core.node.streamable.StreamableOperator)57 ExecutionContext (org.knime.core.node.ExecutionContext)56 DataTableSpec (org.knime.core.data.DataTableSpec)32 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)32 RowInput (org.knime.core.node.streamable.RowInput)25 RowOutput (org.knime.core.node.streamable.RowOutput)23 StreamableFunction (org.knime.core.node.streamable.StreamableFunction)23 DataRow (org.knime.core.data.DataRow)13 BufferedDataTable (org.knime.core.node.BufferedDataTable)12 PMMLPortObject (org.knime.core.node.port.pmml.PMMLPortObject)11 DataTableRowInput (org.knime.core.node.streamable.DataTableRowInput)11 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)10 BufferedDataTableRowOutput (org.knime.core.node.streamable.BufferedDataTableRowOutput)10 StreamableOperatorInternals (org.knime.core.node.streamable.StreamableOperatorInternals)10 PortObjectInput (org.knime.core.node.streamable.PortObjectInput)8 SimpleStreamableOperatorInternals (org.knime.core.node.streamable.simple.SimpleStreamableOperatorInternals)8 PortInput (org.knime.core.node.streamable.PortInput)7 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)6 IOException (java.io.IOException)5 DataCell (org.knime.core.data.DataCell)5