use of org.knime.core.node.streamable.StreamableFunction 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.StreamableFunction 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);
}
};
}
use of org.knime.core.node.streamable.StreamableFunction in project knime-core by knime.
the class DataColumnSpecFilterPMMLNodeModel method createStreamableOperator.
/**
* {@inheritDoc}
*/
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
final ColumnRearranger corea = createColumnRearranger((DataTableSpec) inSpecs[0]);
final StreamableFunction fct = corea.createStreamableFunction();
return new StreamableOperator() {
@Override
public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
// execute streamable in- and outport (0)
fct.init(exec);
fct.runFinal(inputs, outputs, exec);
fct.finish();
DataTableSpec outSpec = corea.createSpec();
// pmml ports
PMMLPortObject pmmlIn = (PMMLPortObject) ((PortObjectInput) inputs[1]).getPortObject();
final PMMLPortObject pmmlOut = createPMMLOut(pmmlIn, outSpec, getFilterResult((DataTableSpec) inSpecs[0]));
((PortObjectOutput) outputs[1]).setPortObject(pmmlOut);
}
};
}
use of org.knime.core.node.streamable.StreamableFunction in project knime-core by knime.
the class AbstractColumnRefNodeModel 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], (DataTableSpec) inSpecs[1]);
StreamableFunction func1 = cr[0].createStreamableFunction(0, 0);
if (m_isSplitter) {
StreamableFunction func2 = cr[1].createStreamableFunction(0, 1);
RowInput rowInput = ((RowInput) inputs[0]);
RowOutput rowOutput1 = ((RowOutput) outputs[0]);
RowOutput rowOutput2 = ((RowOutput) outputs[1]);
StreamableFunction.runFinalInterwoven(rowInput, func1, rowOutput1, func2, rowOutput2, exec);
} else {
func1.runFinal(inputs, outputs, exec);
}
}
};
}
use of org.knime.core.node.streamable.StreamableFunction in project knime-core by knime.
the class SplitNodeModel2 method createStreamableOperator.
/**
* {@inheritDoc}
*/
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
if (m_conf == null) {
m_conf = createColFilterConf();
}
final DataTableSpec inSpec = (DataTableSpec) inSpecs[0];
return new StreamableOperator() {
@Override
public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
ColumnRearranger[] a = createColumnRearrangers(inSpec);
StreamableFunction func1 = a[0].createStreamableFunction(0, 0);
StreamableFunction func2 = a[1].createStreamableFunction(0, 1);
// use both functions to actually do it
RowInput rowInput = ((RowInput) inputs[0]);
RowOutput rowOutput1 = ((RowOutput) outputs[0]);
RowOutput rowOutput2 = ((RowOutput) outputs[1]);
StreamableFunction.runFinalInterwoven(rowInput, func1, rowOutput1, func2, rowOutput2, exec);
}
};
}
Aggregations