use of org.knime.core.node.streamable.RowInput in project knime-core by knime.
the class RuleEngineFilterNodeModel method createStreamableOperator.
/**
* {@inheritDoc}
*/
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
final DataTableSpec spec = (DataTableSpec) inSpecs[0];
try {
parseRules(spec, RuleNodeSettings.RuleFilter);
} catch (final ParseException e) {
throw new InvalidSettingsException(e);
}
return new StreamableOperator() {
private SimpleStreamableOperatorInternals m_internals;
/**
* {@inheritDoc}
*/
@Override
public void loadInternals(final StreamableOperatorInternals internals) {
m_internals = (SimpleStreamableOperatorInternals) internals;
}
/**
* {@inheritDoc}
*/
@Override
public void runIntermediate(final PortInput[] inputs, final ExecutionContext exec) throws Exception {
// count number of rows
long count = 0;
if (inputs[0] instanceof RowInput) {
final RowInput rowInput = (RowInput) inputs[0];
while (rowInput.poll() != null) {
count++;
}
} else if (inputs[0] instanceof PortObjectInput) {
final PortObjectInput portObjectInput = (PortObjectInput) inputs[0];
count += ((BufferedDataTable) portObjectInput.getPortObject()).size();
}
m_internals.getConfig().addLong(CFG_ROW_COUNT, count);
}
/**
* {@inheritDoc}
*/
@Override
public StreamableOperatorInternals saveInternals() {
return m_internals;
}
@Override
public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
long rowCount = -1L;
if (m_internals.getConfig().containsKey(CFG_ROW_COUNT)) {
rowCount = m_internals.getConfig().getLong(CFG_ROW_COUNT);
}
RowOutput[] rowOutputs = (outputs instanceof RowOutput[]) ? (RowOutput[]) outputs : outputs.length > 1 ? new RowOutput[] { (RowOutput) outputs[0], (RowOutput) outputs[1] } : new RowOutput[] { (RowOutput) outputs[0] };
execute((RowInput) inputs[0], rowOutputs, rowCount, exec);
}
};
}
use of org.knime.core.node.streamable.RowInput in project knime-core by knime.
the class AbstractConditionalStreamingNodeModel method createStreamableOperator.
/**
* {@inheritDoc}
*/
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
return new StreamableOperator() {
private SimpleStreamableOperatorInternals m_internals;
/**
* {@inheritDoc}
*/
@Override
public void loadInternals(final StreamableOperatorInternals internals) {
m_internals = (SimpleStreamableOperatorInternals) internals;
}
/**
* {@inheritDoc}
*/
@Override
public void runIntermediate(final PortInput[] inputs, final ExecutionContext exec) throws Exception {
// count number of rows
long count = 0;
RowInput rowInput = (RowInput) inputs[0];
while (rowInput.poll() != null) {
count++;
}
m_internals.getConfig().addLong(CFG_ROW_COUNT, count);
}
@Override
public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
long rowCount = -1;
if (m_internals.getConfig().containsKey(CFG_ROW_COUNT)) {
rowCount = m_internals.getConfig().getLong(CFG_ROW_COUNT);
}
StreamableFunction func = createColumnRearranger((DataTableSpec) inSpecs[0], rowCount).createStreamableFunction();
func.runFinal(inputs, outputs, exec);
}
/**
* {@inheritDoc}
*/
@Override
public StreamableOperatorInternals saveInternals() {
return m_internals;
}
};
}
use of org.knime.core.node.streamable.RowInput in project knime-core by knime.
the class NumericOutliersApplyNodeModel method createStreamableOperator.
/**
* {@inheritDoc}
*/
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
return new StreamableOperator() {
SummaryInternals m_summaryInternals;
@Override
public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
final NumericOutlierPortObject outlierPort = (NumericOutlierPortObject) ((PortObjectInput) inputs[0]).getPortObject();
NumericOutliersReviser outlierReviser = outlierPort.getOutRevBuilder().build();
outlierReviser.treatOutliers(exec, (RowInput) inputs[1], (RowOutput) outputs[0], outlierPort.getOutlierModel(((RowInput) inputs[1]).getDataTableSpec()));
m_summaryInternals = outlierReviser.getSummaryInternals();
}
/**
* {@inheritDoc}
*/
@Override
public StreamableOperatorInternals saveInternals() {
return m_summaryInternals;
}
};
}
Aggregations