use of org.knime.core.node.streamable.StreamableFunction in project knime-core by knime.
the class RowKeyNodeModel2 method createStreamableOperator.
/**
* {@inheritDoc}
*/
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
LOGGER.debug("Entering createStreamableOperator-method of class RowKeyNodeModel");
if (m_replaceKey.getBooleanValue()) {
DataTableSpec outSpec = configure((DataTableSpec) inSpecs[DATA_IN_PORT], true);
return new StreamableOperator() {
@Override
public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
RowInput rowInput = (RowInput) inputs[DATA_IN_PORT];
RowOutput rowOutput = (RowOutput) outputs[DATA_OUT_PORT];
replaceKey(rowInput, rowOutput, outSpec.getNumColumns(), -1, exec);
}
};
} else if (m_appendRowKey.getBooleanValue()) {
LOGGER.debug("The user only wants to append a new column with " + "name " + m_newColumnName);
// the user wants only a column with the given name which
// contains the rowkey as value
final DataTableSpec tableSpec = (DataTableSpec) inSpecs[DATA_IN_PORT];
final String newColumnName = m_newColumnName.getStringValue();
final ColumnRearranger c = RowKeyUtil2.createColumnRearranger(tableSpec, newColumnName, StringCell.TYPE);
return c.createStreamableFunction();
} else {
// the given data
return new StreamableFunction() {
@Override
public DataRow compute(final DataRow input) throws Exception {
return input;
}
};
}
}
use of org.knime.core.node.streamable.StreamableFunction in project knime-core by knime.
the class SVMPredictorNodeModel 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 pmmlModel = (PMMLPortObject) ((PortObjectInput) inputs[0]).getPortObject();
ColumnRearranger colre = createColumnRearranger(pmmlModel, (DataTableSpec) inSpecs[1]);
StreamableFunction func = colre.createStreamableFunction(1, 0);
func.runFinal(inputs, outputs, exec);
}
};
}
use of org.knime.core.node.streamable.StreamableFunction in project knime-core by knime.
the class MLPPredictorNodeModel 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 pmmlPortObject = (PMMLPortObject) ((PortObjectInput) inputs[0]).getPortObject();
ColumnRearranger colre = createColumnRearranger(pmmlPortObject, (DataTableSpec) inSpecs[1]);
StreamableFunction func = colre.createStreamableFunction(1, 0);
func.runFinal(inputs, outputs, exec);
}
};
}
use of org.knime.core.node.streamable.StreamableFunction 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.StreamableFunction in project knime-core by knime.
the class TreeEnsembleClassificationPredictorNodeModel 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 {
TreeEnsembleModelPortObject model = (TreeEnsembleModelPortObject) ((PortObjectInput) inputs[0]).getPortObject();
TreeEnsembleModelPortObjectSpec modelSpec = model.getSpec();
DataTableSpec dataSpec = (DataTableSpec) inSpecs[1];
final TreeEnsemblePredictor pred = new TreeEnsemblePredictor(modelSpec, model, dataSpec, m_configuration);
ColumnRearranger rearranger = pred.getPredictionRearranger();
StreamableFunction func = rearranger.createStreamableFunction(1, 0);
func.runFinal(inputs, outputs, exec);
}
};
}
Aggregations