use of org.knime.core.node.streamable.StreamableOperator 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.StreamableOperator 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.StreamableOperator in project knime-core by knime.
the class AppendedRowsNodeModel 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 {
List<RowInput> noNullList = new ArrayList<RowInput>();
for (PortInput p : inputs) {
if (p != null) {
noNullList.add((RowInput) p);
}
}
RowInput[] rowInputs = noNullList.toArray(new RowInput[noNullList.size()]);
run(rowInputs, (RowOutput) outputs[0], exec, -1);
}
};
}
use of org.knime.core.node.streamable.StreamableOperator 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.StreamableOperator in project knime-core by knime.
the class ReadTableNodeModel 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 {
exec.setMessage("Extract temporary table");
ContainerTable table = extractTable(exec.createSubExecutionContext(0.4));
exec.setMessage("Streaming Output");
RowOutput output = (RowOutput) outputs[0];
execute(table, output, exec.createSubExecutionContext(0.6));
}
};
}
Aggregations