use of org.knime.core.node.streamable.StreamableOperator 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.StreamableOperator 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.StreamableOperator in project knime-core by knime.
the class FilterApplyNodeModel 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 out = (RowOutput) outputs[0];
PortObjectInput portObjectInput = (PortObjectInput) inputs[1];
DataTableSpec filterSpec = portObjectInput == null ? in.getDataTableSpec() : ((FilterDefinitionHandlerPortObject) portObjectInput.getPortObject()).getSpec();
FilterApplyNodeModel.this.execute(in, out, filterSpec, exec, -1);
}
};
}
use of org.knime.core.node.streamable.StreamableOperator in project knime-core by knime.
the class ColumnAggregatorNodeModel method createStreamableOperator.
/* ================= STREAMING ================= */
/**
* {@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 DataTableSpec origSpec = (DataTableSpec) inSpecs[0];
final FilterResult filterResult = m_aggregationCols.applyTo(origSpec);
final List<String> selectedCols = Arrays.asList(filterResult.getIncludes());
final GlobalSettings globalSettings = GlobalSettings.builder().setFileStoreFactory(FileStoreFactory.createWorkflowFileStoreFactory(exec)).setGroupColNames(selectedCols).setMaxUniqueValues(m_maxUniqueValues.getIntValue()).setValueDelimiter(getDefaultValueDelimiter()).setDataTableSpec(origSpec).setNoOfRows(-1).setAggregationContext(AggregationContext.COLUMN_AGGREGATION).build();
final AggregationCellFactory cellFactory = new AggregationCellFactory(origSpec, selectedCols, globalSettings, m_methods);
final ColumnRearranger cr = createRearranger(origSpec, cellFactory);
cr.createStreamableFunction().runFinal(inputs, outputs, exec);
}
};
}
use of org.knime.core.node.streamable.StreamableOperator in project knime-core by knime.
the class VirtualSubNodeInputNodeModel method createStreamableOperator.
@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 {
assert inputs.length == 0;
PortObject[] dataFromParent = ArrayUtils.remove(m_subNodeContainer.fetchInputDataFromParent(), 0);
for (int i = 0; i < outputs.length; i++) {
if (BufferedDataTable.TYPE.equals(getOutPortType(i))) {
// stream port content if it's data
BufferedDataTable bdt = (BufferedDataTable) (dataFromParent[i]);
RowOutput rowOutput = (RowOutput) outputs[i];
for (DataRow dr : bdt) {
rowOutput.push(dr);
}
rowOutput.close();
} else {
((PortObjectOutput) outputs[i]).setPortObject(dataFromParent[i]);
}
}
}
};
}
Aggregations