use of org.knime.core.node.streamable.StreamableOperator in project knime-core by knime.
the class NormalizerApplyNodeModel method createStreamableOperator.
/**
* {@inheritDoc}
*/
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
if (getNrOutPorts() == 2) {
// by default call the default implementation of this method
return super.createStreamableOperator(partitionInfo, inSpecs);
} else {
return new StreamableOperator() {
@Override
public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
assert outputs.length == 1;
NormalizerPortObject model = (NormalizerPortObject) ((PortObjectInput) inputs[0]).getPortObject();
RowInput rowInput = (RowInput) inputs[1];
AffineTransTable t = new AffineTransTable(rowInput, getAffineTrans(model.getConfiguration()));
RowOutput rowOutput = (RowOutput) outputs[0];
RowIterator it = t.iterator();
while (it.hasNext()) {
rowOutput.push(it.next());
}
if (t.getErrorMessage() != null) {
// TODO collect error message from remote nodes if run distributed
setWarningMessage(t.getErrorMessage());
}
rowInput.close();
rowOutput.close();
}
};
}
}
use of org.knime.core.node.streamable.StreamableOperator in project knime-core by knime.
the class BinnerNodeModel 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 colre = createColumnRearranger((DataTableSpec) inSpecs[0]);
colre.createStreamableFunction(0, 0).runFinal(inputs, outputs, exec);
if (m_pmmlOutEnabled) {
// handle the optional PMML in port (can be null)
PMMLPortObject inPMMLPort = m_pmmlInEnabled ? (PMMLPortObject) ((PortObjectInput) inputs[1]).getPortObject() : null;
PMMLPortObject outPMMLPort = createPMMLModel(inPMMLPort, (DataTableSpec) inSpecs[0], colre.createSpec());
((PortObjectOutput) outputs[1]).setPortObject(outPMMLPort);
}
}
};
}
use of org.knime.core.node.streamable.StreamableOperator in project knime-core by knime.
the class FilterApplyRowSplitterNodeModel 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 {
final DataTableRowInput in = (DataTableRowInput) inputs[0];
final RowOutput out1 = (RowOutput) outputs[0];
final RowOutput out2 = (RowOutput) outputs[1];
PortObjectInput portObjectInput = (PortObjectInput) inputs[1];
DataTableSpec filterSpec = portObjectInput == null ? in.getDataTableSpec() : ((FilterDefinitionHandlerPortObject) portObjectInput.getPortObject()).getSpec();
FilterApplyRowSplitterNodeModel.this.execute(in, out1, out2, filterSpec, exec, -1);
}
};
}
use of org.knime.core.node.streamable.StreamableOperator in project knime-core by knime.
the class NominalValueRowFilterNodeModel method createStreamableOperator.
/**
* {@inheritDoc}
*/
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
return new StreamableOperator() {
@SuppressWarnings("null")
@Override
public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
RowInput in = (RowInput) inputs[0];
RowOutput match = (RowOutput) outputs[0];
RowOutput miss = m_splitter ? (RowOutput) outputs[1] : null;
try {
long rowIdx = -1;
DataRow row;
while ((row = in.poll()) != null) {
rowIdx++;
exec.setProgress("Adding row " + rowIdx + ".");
exec.checkCanceled();
if (matches(row)) {
match.push(row);
} else if (m_splitter) {
miss.push(row);
}
}
} finally {
match.close();
if (m_splitter) {
miss.close();
}
}
}
};
}
use of org.knime.core.node.streamable.StreamableOperator in project knime-core by knime.
the class ColumnRenameRegexNodeModel 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 {
// just pass through since only the column names have been changed
RowInput rowInput = (RowInput) inputs[0];
RowOutput rowOutput = (RowOutput) outputs[0];
DataRow row;
while ((row = rowInput.poll()) != null) {
rowOutput.push(row);
}
rowInput.close();
rowOutput.close();
}
};
}
Aggregations