Quantcast
Channel: KNIME RSS
Viewing all articles
Browse latest Browse all 4157

Streaming API query

$
0
0

Hi

I have a node that has two inputs (data tables). One table needs to be processed completely before the second table can be processed. 

I use a column rearranger to generate my output table. Is there a better way than my implementation:

 

	public InputPortRole[] getInputPortRoles()
	{
		return new InputPortRole[] { InputPortRole.NONDISTRIBUTED_STREAMABLE,
				InputPortRole.NONDISTRIBUTED_NONSTREAMABLE };
	}

	/** {@inheritDoc} */
	@Override
	public OutputPortRole[] getOutputPortRoles()
	{
		return new OutputPortRole[] { OutputPortRole.NONDISTRIBUTED };
	}

	/** {@inheritDoc} */
	@Override
	public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo,
			final PortObjectSpec[] inSpecs) throws InvalidSettingsException
	{
		return new StreamableOperator()
		{

			@Override
			public void runFinal(PortInput[] inputs, PortOutput[] outputs, ExecutionContext exec) throws Exception
			{
				... actions on first data table
				
				// Classify
				RowInput reactions = (RowInput) inputs[0];
				RowOutput out = (RowOutput) outputs[0];

				StreamableFunction function = createColumnRearranger(reactions.getDataTableSpec(), spc)
						.createStreamableFunction();
				
				DataRow row;
				while ((row = reactions.poll()) != null)
				{
					DataRow computed = function.compute(row);
					out.push(computed);
				}
				reactions.close();
			}
		};
	}

 

Cheers

Sam


Viewing all articles
Browse latest Browse all 4157

Trending Articles