Search in sources :

Example 26 with StreamableOperator

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);
        }
    };
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) ColumnRearranger(org.knime.core.data.container.ColumnRearranger) ExecutionContext(org.knime.core.node.ExecutionContext) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) StreamableOperator(org.knime.core.node.streamable.StreamableOperator) StreamableFunction(org.knime.core.node.streamable.StreamableFunction) PortObjectOutput(org.knime.core.node.streamable.PortObjectOutput)

Example 27 with StreamableOperator

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);
            }
        }
    };
}
Also used : RowOutput(org.knime.core.node.streamable.RowOutput) ExecutionContext(org.knime.core.node.ExecutionContext) ColumnRearranger(org.knime.core.data.container.ColumnRearranger) StreamableOperator(org.knime.core.node.streamable.StreamableOperator) StreamableFunction(org.knime.core.node.streamable.StreamableFunction) RowInput(org.knime.core.node.streamable.RowInput)

Example 28 with StreamableOperator

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);
        }
    };
}
Also used : BufferedDataTableRowOutput(org.knime.core.node.streamable.BufferedDataTableRowOutput) RowOutput(org.knime.core.node.streamable.RowOutput) DataTableSpec(org.knime.core.data.DataTableSpec) ExecutionContext(org.knime.core.node.ExecutionContext) StreamableOperator(org.knime.core.node.streamable.StreamableOperator) DataTableRowInput(org.knime.core.node.streamable.DataTableRowInput) PortObjectInput(org.knime.core.node.streamable.PortObjectInput)

Example 29 with StreamableOperator

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);
        }
    };
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) ExecutionContext(org.knime.core.node.ExecutionContext) ColumnRearranger(org.knime.core.data.container.ColumnRearranger) StreamableOperator(org.knime.core.node.streamable.StreamableOperator) GlobalSettings(org.knime.base.data.aggregation.GlobalSettings) FilterResult(org.knime.core.node.util.filter.NameFilterConfiguration.FilterResult) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 30 with StreamableOperator

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]);
                }
            }
        }
    };
}
Also used : RowOutput(org.knime.core.node.streamable.RowOutput) ExecutionContext(org.knime.core.node.ExecutionContext) StreamableOperator(org.knime.core.node.streamable.StreamableOperator) BufferedDataTable(org.knime.core.node.BufferedDataTable) InactiveBranchPortObject(org.knime.core.node.port.inactive.InactiveBranchPortObject) PortObject(org.knime.core.node.port.PortObject) DataRow(org.knime.core.data.DataRow) PortObjectOutput(org.knime.core.node.streamable.PortObjectOutput)

Aggregations

StreamableOperator (org.knime.core.node.streamable.StreamableOperator)57 ExecutionContext (org.knime.core.node.ExecutionContext)56 DataTableSpec (org.knime.core.data.DataTableSpec)32 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)32 RowInput (org.knime.core.node.streamable.RowInput)25 RowOutput (org.knime.core.node.streamable.RowOutput)23 StreamableFunction (org.knime.core.node.streamable.StreamableFunction)23 DataRow (org.knime.core.data.DataRow)13 BufferedDataTable (org.knime.core.node.BufferedDataTable)12 PMMLPortObject (org.knime.core.node.port.pmml.PMMLPortObject)11 DataTableRowInput (org.knime.core.node.streamable.DataTableRowInput)11 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)10 BufferedDataTableRowOutput (org.knime.core.node.streamable.BufferedDataTableRowOutput)10 StreamableOperatorInternals (org.knime.core.node.streamable.StreamableOperatorInternals)10 PortObjectInput (org.knime.core.node.streamable.PortObjectInput)8 SimpleStreamableOperatorInternals (org.knime.core.node.streamable.simple.SimpleStreamableOperatorInternals)8 PortInput (org.knime.core.node.streamable.PortInput)7 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)6 IOException (java.io.IOException)5 DataCell (org.knime.core.data.DataCell)5