use of org.knime.core.node.streamable.StreamableOperator in project knime-core by knime.
the class CellReplacerNodeModel 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 {
BufferedDataTable dictTable = (BufferedDataTable) ((PortObjectInput) inputs[1]).getPortObject();
ColumnRearranger rearranger = createColumnRearranger((DataTableSpec) inSpecs[0], dictTable.getDataTableSpec(), dictTable, exec);
StreamableFunction func = rearranger.createStreamableFunction(0, 0);
func.runFinal(inputs, outputs, exec);
}
};
}
use of org.knime.core.node.streamable.StreamableOperator in project knime-core by knime.
the class CategoryToNumberNodeModel 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 cr = createRearranger((DataTableSpec) inSpecs[0]);
cr.createStreamableFunction(0, 0).runFinal(inputs, outputs, exec);
// the optional PMML in port (can be null)
PMMLPortObject inPMMLPort = null;
if (m_pmmlInEnabled && inputs[1] != null) {
inPMMLPort = (PMMLPortObject) ((PortObjectInput) inputs[1]).getPortObject();
}
PMMLPortObjectSpecCreator creator = new PMMLPortObjectSpecCreator(inPMMLPort, cr.createSpec());
PMMLPortObject outPMMLPort = new PMMLPortObject(creator.createSpec(), inPMMLPort);
for (CategoryToNumberCellFactory factory : m_factories) {
PMMLMapValuesTranslator trans = new PMMLMapValuesTranslator(factory.getConfig(), new DerivedFieldMapper(inPMMLPort));
outPMMLPort.addGlobalTransformations(trans.exportToTransDict());
}
PortObjectOutput portObjectOutput = (PortObjectOutput) outputs[1];
portObjectOutput.setPortObject(outPMMLPort);
}
};
}
use of org.knime.core.node.streamable.StreamableOperator in project knime-core by knime.
the class ColumnAppenderNodeModel method createStreamableOperator.
// ////////////// STREAMING FUNCTIONS ////////////////
/**
* {@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 {
RowInput in1 = (RowInput) inputs[0];
RowInput in2 = (RowInput) inputs[1];
RowOutput out = (RowOutput) outputs[0];
CustomRowIterator tableIt1 = new CustomRowIteratorImpl2(in1);
CustomRowIterator tableIt2 = new CustomRowIteratorImpl2(in2);
compute(tableIt1, tableIt2, in1.getDataTableSpec().getNumColumns() + in2.getDataTableSpec().getNumColumns(), row -> {
out.push(row);
}, exec, -1, -1);
// poll all the remaining rows if there are any but don't do anything with them
while (tableIt1.hasNext()) {
tableIt1.next();
}
while (tableIt2.hasNext()) {
tableIt2.next();
}
in1.close();
in2.close();
out.close();
}
};
}
use of org.knime.core.node.streamable.StreamableOperator in project knime-core by knime.
the class RowFilterNodeModel method createStreamableOperator.
/**
* {@inheritDoc}
*/
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
return new StreamableOperator() {
@Override
public StreamableOperatorInternals saveInternals() {
return null;
}
@Override
public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext ctx) throws Exception {
RowInput in = (RowInput) inputs[0];
RowOutput out = (RowOutput) outputs[0];
RowFilterNodeModel.this.execute(in, out, ctx);
}
};
}
use of org.knime.core.node.streamable.StreamableOperator in project knime-core by knime.
the class ReferenceColumnResorterNodeModel method createStreamableOperator.
/**
* {@inheritDoc}
*/
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
return new StreamableOperator() {
private String[] m_streamableOperatorOrder;
/**
* {@inheritDoc}
*/
@Override
public void runIntermediate(final PortInput[] inputs, final ExecutionContext exec) throws Exception {
BufferedDataTable orderTable = (BufferedDataTable) ((PortObjectInput) inputs[1]).getPortObject();
m_streamableOperatorOrder = readOrderFromTable(orderTable);
}
@Override
public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
RowInput dataInput = (RowInput) inputs[0];
DataTableSpec dataInputSpec = dataInput.getDataTableSpec();
ColumnRearranger rearranger = createColumnRearranger(dataInputSpec, m_streamableOperatorOrder);
StreamableFunction streamableFunction = rearranger.createStreamableFunction();
streamableFunction.runFinal(new PortInput[] { dataInput }, outputs, exec);
}
/**
* {@inheritDoc}
*/
@Override
public StreamableOperatorInternals saveInternals() {
return createStreamableOperatorInternalsFromOrder(m_streamableOperatorOrder);
}
/**
* {@inheritDoc}
*/
@Override
public void loadInternals(final StreamableOperatorInternals internals) {
m_streamableOperatorOrder = readOrderFromStreamableOperatorInternals(internals);
}
};
}
Aggregations