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);
}
};
}
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()));
}
};
}
Aggregations