use of org.knime.core.node.streamable.RowOutput in project knime-core by knime.
the class LagColumnStreamableOperator method runFinal.
/**
* {@inheritDoc}
*/
@Override
public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
long counter = 0;
int maxLag = m_configuration.getLagInterval() * m_configuration.getLag();
RingBuffer ringBuffer = new RingBuffer(maxLag);
RowInput input = (RowInput) inputs[0];
RowOutput output = (RowOutput) outputs[0];
int skippedFirstCount = !m_configuration.isSkipInitialIncompleteRows() ? -1 : m_configuration.getLagInterval() * m_configuration.getLag();
DataRow row;
while ((row = input.poll()) != null) {
if (counter >= skippedFirstCount) {
DataCell[] newCells = getAdditionalCells(ringBuffer);
output.push(copyWithNewCells(row, newCells));
}
DataCell toBeCached = m_columnIndex < 0 ? new StringCell(row.getKey().toString()) : row.getCell(m_columnIndex);
ringBuffer.add(toBeCached);
setProgress(exec, counter, row);
counter += 1;
}
if (!m_configuration.isSkipLastIncompleteRows()) {
DataCell[] missings = new DataCell[input.getDataTableSpec().getNumColumns()];
Arrays.fill(missings, DataType.getMissingCell());
for (int i = 0; i < maxLag; i++) {
DataRow missingRow = new DefaultRow("overflow-" + i, missings);
DataCell[] newCells = getAdditionalCells(ringBuffer);
output.push(copyWithNewCells(missingRow, newCells));
ringBuffer.add(DataType.getMissingCell());
}
}
output.close();
}
use of org.knime.core.node.streamable.RowOutput 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.RowOutput 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.RowOutput 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.RowOutput in project knime-core by knime.
the class RowFilter2PortNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected BufferedDataTable[] execute(final BufferedDataTable[] inData, final ExecutionContext exec) throws Exception {
BufferedDataTable in = inData[0];
// in case the node was configured and the workflow is closed
// (and saved), the row filter isn't configured upon reloading.
// here, we give it a chance to configure itself (e.g. find the column
// index)
m_rowFilter.configure(in.getDataTableSpec());
BufferedDataContainer match = exec.createDataContainer(in.getDataTableSpec());
BufferedDataContainer miss = exec.createDataContainer(in.getDataTableSpec());
RowOutput rowOutput1 = new BufferedDataTableRowOutput(match);
RowOutput rowOutput2 = new BufferedDataTableRowOutput(miss);
RowInput rowInput = new DataTableRowInput(inData[0]);
// do it
this.execute(rowInput, rowOutput1, rowOutput2, inData[0].size(), exec);
// note: tables are closed in the private execute method
return new BufferedDataTable[] { match.getTable(), miss.getTable() };
}
Aggregations